Skip to content

Commit

Permalink
Merge pull request csi-addons#174 from red-hat-storage/sync_ds--main
Browse files Browse the repository at this point in the history
Syncing latest changes from main for kubernetes-csi-addons
  • Loading branch information
openshift-merge-bot[bot] authored Jul 25, 2024
2 parents fb506bf + 9f51b5c commit a525bd1
Show file tree
Hide file tree
Showing 33 changed files with 2,689 additions and 65 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ require (
go.uber.org/zap v1.27.0
google.golang.org/grpc v1.65.0
google.golang.org/protobuf v1.34.2
k8s.io/api v0.30.2
k8s.io/apimachinery v0.30.2
k8s.io/client-go v0.30.2
k8s.io/api v0.30.3
k8s.io/apimachinery v0.30.3
k8s.io/client-go v0.30.3
k8s.io/klog/v2 v2.130.1
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
sigs.k8s.io/controller-runtime v0.18.4
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,14 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.30.2 h1:+ZhRj+28QT4UOH+BKznu4CBgPWgkXO7XAvMcMl0qKvI=
k8s.io/api v0.30.2/go.mod h1:ULg5g9JvOev2dG0u2hig4Z7tQ2hHIuS+m8MNZ+X6EmI=
k8s.io/api v0.30.3 h1:ImHwK9DCsPA9uoU3rVh4QHAHHK5dTSv1nxJUapx8hoQ=
k8s.io/api v0.30.3/go.mod h1:GPc8jlzoe5JG3pb0KJCSLX5oAFIW3/qNJITlDj8BH04=
k8s.io/apiextensions-apiserver v0.30.1 h1:4fAJZ9985BmpJG6PkoxVRpXv9vmPUOVzl614xarePws=
k8s.io/apiextensions-apiserver v0.30.1/go.mod h1:R4GuSrlhgq43oRY9sF2IToFh7PVlF1JjfWdoG3pixk4=
k8s.io/apimachinery v0.30.2 h1:fEMcnBj6qkzzPGSVsAZtQThU62SmQ4ZymlXRC5yFSCg=
k8s.io/apimachinery v0.30.2/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc=
k8s.io/client-go v0.30.2 h1:sBIVJdojUNPDU/jObC+18tXWcTJVcwyqS9diGdWHk50=
k8s.io/client-go v0.30.2/go.mod h1:JglKSWULm9xlJLx4KCkfLLQ7XwtlbflV6uFFSHTMgVs=
k8s.io/apimachinery v0.30.3 h1:q1laaWCmrszyQuSQCfNB8cFgCuDAoPszKY4ucAjDwHc=
k8s.io/apimachinery v0.30.3/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc=
k8s.io/client-go v0.30.3 h1:bHrJu3xQZNXIi8/MoxYtZBBWQQXwy16zqJwloXXfD3k=
k8s.io/client-go v0.30.3/go.mod h1:8d4pf8vYu665/kUbsxWAQ/JDBNWqfFeZnvFiVdmx89U=
k8s.io/component-base v0.30.1 h1:bvAtlPh1UrdaZL20D9+sWxsJljMi0QZ3Lmw+kmZAaxQ=
k8s.io/component-base v0.30.1/go.mod h1:e/X9kDiOebwlI41AvBHuWdqFriSRrX50CdwA9TFaHLI=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
Expand Down
22 changes: 11 additions & 11 deletions internal/sidecar/service/volumereplication.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (rs *ReplicationServer) EnableVolumeReplication(
Parameters: req.GetParameters(),
Secrets: data,
}
err = setReplicationSource(repReq.ReplicationSource, req.GetReplicationSource())
err = setReplicationSource(&repReq.ReplicationSource, req.GetReplicationSource())
if err != nil {
klog.Errorf("Failed to set replication source: %v", err)
return nil, status.Error(codes.Internal, err.Error())
Expand Down Expand Up @@ -102,7 +102,7 @@ func (rs *ReplicationServer) DisableVolumeReplication(
Parameters: req.GetParameters(),
Secrets: data,
}
err = setReplicationSource(repReq.ReplicationSource, req.GetReplicationSource())
err = setReplicationSource(&repReq.ReplicationSource, req.GetReplicationSource())
if err != nil {
klog.Errorf("Failed to set replication source: %v", err)
return nil, status.Error(codes.Internal, err.Error())
Expand Down Expand Up @@ -135,7 +135,7 @@ func (rs *ReplicationServer) PromoteVolume(
Force: req.GetForce(),
Secrets: data,
}
err = setReplicationSource(repReq.ReplicationSource, req.GetReplicationSource())
err = setReplicationSource(&repReq.ReplicationSource, req.GetReplicationSource())
if err != nil {
klog.Errorf("Failed to set replication source: %v", err)
return nil, status.Error(codes.Internal, err.Error())
Expand Down Expand Up @@ -168,7 +168,7 @@ func (rs *ReplicationServer) DemoteVolume(
Force: req.GetForce(),
Secrets: data,
}
err = setReplicationSource(repReq.ReplicationSource, req.GetReplicationSource())
err = setReplicationSource(&repReq.ReplicationSource, req.GetReplicationSource())
if err != nil {
klog.Errorf("Failed to set replication source: %v", err)
return nil, status.Error(codes.Internal, err.Error())
Expand Down Expand Up @@ -201,7 +201,7 @@ func (rs *ReplicationServer) ResyncVolume(
Force: req.GetForce(),
Secrets: data,
}
err = setReplicationSource(repReq.ReplicationSource, req.GetReplicationSource())
err = setReplicationSource(&repReq.ReplicationSource, req.GetReplicationSource())
if err != nil {
klog.Errorf("Failed to set replication source: %v", err)
return nil, status.Error(codes.Internal, err.Error())
Expand Down Expand Up @@ -234,7 +234,7 @@ func (rs *ReplicationServer) GetVolumeReplicationInfo(
ReplicationId: req.GetReplicationId(),
Secrets: data,
}
err = setReplicationSource(repReq.ReplicationSource, req.GetReplicationSource())
err = setReplicationSource(&repReq.ReplicationSource, req.GetReplicationSource())
if err != nil {
klog.Errorf("Failed to set replication source: %v", err)
return nil, status.Error(codes.Internal, err.Error())
Expand All @@ -259,9 +259,9 @@ func (rs *ReplicationServer) GetVolumeReplicationInfo(
}

// setReplicationSource sets the replication source for the given ReplicationSource.
func setReplicationSource(src *csiReplication.ReplicationSource, req *proto.ReplicationSource) error {
if src == nil {
src = &csiReplication.ReplicationSource{}
func setReplicationSource(src **csiReplication.ReplicationSource, req *proto.ReplicationSource) error {
if *src == nil {
*src = &csiReplication.ReplicationSource{}
}

switch {
Expand All @@ -270,12 +270,12 @@ func setReplicationSource(src *csiReplication.ReplicationSource, req *proto.Repl
case req.GetVolume() == nil && req.GetVolumeGroup() == nil:
return errors.New("either volume or volume group is required")
case req.GetVolume() != nil:
src.Type = &csiReplication.ReplicationSource_Volume{Volume: &csiReplication.ReplicationSource_VolumeSource{
(*src).Type = &csiReplication.ReplicationSource_Volume{Volume: &csiReplication.ReplicationSource_VolumeSource{
VolumeId: req.GetVolume().GetVolumeId(),
}}
return nil
case req.GetVolumeGroup() != nil:
src.Type = &csiReplication.ReplicationSource_Volumegroup{Volumegroup: &csiReplication.ReplicationSource_VolumeGroupSource{
(*src).Type = &csiReplication.ReplicationSource_Volumegroup{Volumegroup: &csiReplication.ReplicationSource_VolumeGroupSource{
VolumeGroupId: req.GetVolumeGroup().GetVolumeGroupId(),
}}
return nil
Expand Down
26 changes: 20 additions & 6 deletions internal/sidecar/service/volumereplication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,27 @@ func Test_setReplicationSource(t *testing.T) {
wantErr: true,
},
{
name: "set replication source when request is not set",
name: "set replication source when request is nil",
args: args{
src: &csiReplication.ReplicationSource{},
req: &proto.ReplicationSource{},
src: nil,
req: nil,
},
wantErr: true,
},
{
name: "set replication source is nil but request is not nil",
args: args{
src: nil,
req: &proto.ReplicationSource{
Type: &proto.ReplicationSource_Volume{
Volume: &proto.ReplicationSource_VolumeSource{
VolumeId: volID,
},
},
},
},
wantErr: false,
},
{
name: "set replication source when volume is set",
args: args{
Expand Down Expand Up @@ -81,16 +95,16 @@ func Test_setReplicationSource(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := setReplicationSource(tt.args.src, tt.args.req); (err != nil) != tt.wantErr {
if err := setReplicationSource(&tt.args.src, tt.args.req); (err != nil) != tt.wantErr {
t.Errorf("setReplicationSource() error = %v, wantErr %v", err, tt.wantErr)
}
if tt.args.req.GetVolume() != nil {
if tt.args.req.GetVolume().GetVolumeId() != volID {
if tt.args.src.GetVolume().GetVolumeId() != volID {
t.Errorf("setReplicationSource() got = %v volumeID, expected = %v volumeID", tt.args.req.GetVolume().GetVolumeId(), volID)
}
}
if tt.args.req.GetVolumeGroup() != nil {
if tt.args.req.GetVolumeGroup().GetVolumeGroupId() != groupID {
if tt.args.src.GetVolumegroup().GetVolumeGroupId() != groupID {
t.Errorf("setReplicationSource() got = %v groupID, expected = %v volumeID", tt.args.req.GetVolumeGroup().GetVolumeGroupId(), groupID)
}
}
Expand Down
9 changes: 5 additions & 4 deletions tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
google.golang.org/protobuf v1.34.2
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20240102165319-7f316f1309b1
sigs.k8s.io/controller-tools v0.15.0
sigs.k8s.io/kustomize/kustomize/v5 v5.4.2
sigs.k8s.io/kustomize/kustomize/v5 v5.4.3
)

require (
Expand Down Expand Up @@ -160,6 +160,7 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
Expand Down Expand Up @@ -231,9 +232,9 @@ require (
sigs.k8s.io/controller-runtime v0.16.3 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kubebuilder/v3 v3.13.1-0.20240119130530-7fba82c768f8 // indirect
sigs.k8s.io/kustomize/api v0.17.2 // indirect
sigs.k8s.io/kustomize/cmd/config v0.14.1 // indirect
sigs.k8s.io/kustomize/kyaml v0.17.1 // indirect
sigs.k8s.io/kustomize/api v0.17.3 // indirect
sigs.k8s.io/kustomize/cmd/config v0.14.2 // indirect
sigs.k8s.io/kustomize/kyaml v0.17.2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
16 changes: 8 additions & 8 deletions tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -824,14 +824,14 @@ sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMm
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/kubebuilder/v3 v3.13.1-0.20240119130530-7fba82c768f8 h1:6dc/YGQd4QVjjVHOQEz9M9w5C3Mv+q327eyJ0l8wixY=
sigs.k8s.io/kubebuilder/v3 v3.13.1-0.20240119130530-7fba82c768f8/go.mod h1:ZhWtqslcUPr6eN/4Ww2Qn0OwxLuTt+HYLJRq/UTtJpw=
sigs.k8s.io/kustomize/api v0.17.2 h1:E7/Fjk7V5fboiuijoZHgs4aHuexi5Y2loXlVOAVAG5g=
sigs.k8s.io/kustomize/api v0.17.2/go.mod h1:UWTz9Ct+MvoeQsHcJ5e+vziRRkwimm3HytpZgIYqye0=
sigs.k8s.io/kustomize/cmd/config v0.14.1 h1:r1gRhgfPmnt7VYf4uxO8M27GX406n9kOOeScOH9IQds=
sigs.k8s.io/kustomize/cmd/config v0.14.1/go.mod h1:Sw1cPsFqh4uYczCWKlidPgMrsffLPCAB+7ytYLlauY4=
sigs.k8s.io/kustomize/kustomize/v5 v5.4.2 h1:9Zl5Gqg3XMdBEvkR54pVLCBj7FVO7W+VPNDDEzD6AyE=
sigs.k8s.io/kustomize/kustomize/v5 v5.4.2/go.mod h1:5ypfJVYlPb2MKKeoGknVLxvHemDlQT+szI4+KOhnD6k=
sigs.k8s.io/kustomize/kyaml v0.17.1 h1:TnxYQxFXzbmNG6gOINgGWQt09GghzgTP6mIurOgrLCQ=
sigs.k8s.io/kustomize/kyaml v0.17.1/go.mod h1:9V0mCjIEYjlXuCdYsSXvyoy2BTsLESH7TlGV81S282U=
sigs.k8s.io/kustomize/api v0.17.3 h1:6GCuHSsxq7fN5yhF2XrC+AAr8gxQwhexgHflOAD/JJU=
sigs.k8s.io/kustomize/api v0.17.3/go.mod h1:TuDH4mdx7jTfK61SQ/j1QZM/QWR+5rmEiNjvYlhzFhc=
sigs.k8s.io/kustomize/cmd/config v0.14.2 h1:YOCu0BnVPm2Iq6PR4fJgO6+rivg5LbR3+o/4ZUeXAvM=
sigs.k8s.io/kustomize/cmd/config v0.14.2/go.mod h1:w30rR4oCUm5wEi0tSuBCmuBMS9Z/Cq6oDdfg8fL/qls=
sigs.k8s.io/kustomize/kustomize/v5 v5.4.3 h1:SJMDq/0HYNTFPgmlBuxsGzdBB6furxhwHKHEfzBbvSw=
sigs.k8s.io/kustomize/kustomize/v5 v5.4.3/go.mod h1:vhSLBp3H7wx0oeh/hE7CMQVNft42plZxUqxhvVZxb8Q=
sigs.k8s.io/kustomize/kyaml v0.17.2 h1:+AzvoJUY0kq4QAhH/ydPHHMRLijtUKiyVyh7fOSshr0=
sigs.k8s.io/kustomize/kyaml v0.17.2/go.mod h1:9V0mCjIEYjlXuCdYsSXvyoy2BTsLESH7TlGV81S282U=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
Expand Down
25 changes: 25 additions & 0 deletions tools/vendor/github.com/sergi/go-diff/AUTHORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions tools/vendor/github.com/sergi/go-diff/CONTRIBUTORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions tools/vendor/github.com/sergi/go-diff/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a525bd1

Please sign in to comment.