Skip to content

Commit

Permalink
Merge pull request #156 from csi-addons/main
Browse files Browse the repository at this point in the history
sync downstream main with upstream main
  • Loading branch information
openshift-merge-bot[bot] authored Jun 20, 2024
2 parents 2aaf4b0 + 2265555 commit 5cec76b
Show file tree
Hide file tree
Showing 15 changed files with 787 additions and 416 deletions.
26 changes: 26 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,32 @@ rules:
- get
- patch
- update
- apiGroups:
- replication.storage.openshift.io
resources:
- volumegroupreplicationcontents
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumegroupreplicationcontents/finalizers
verbs:
- update
- apiGroups:
- replication.storage.openshift.io
resources:
- volumegroupreplicationcontents/status
verbs:
- get
- patch
- update
- apiGroups:
- replication.storage.openshift.io
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ type VolumeGroupReplicationContentReconciler struct {
Scheme *runtime.Scheme
}

// +kubebuilder:rbac:groups=replication.storage.openshift.io,resources=volumegroupreplicationcontents,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=replication.storage.openshift.io,resources=volumegroupreplicationcontents/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=replication.storage.openshift.io,resources=volumegroupreplicationcontents/finalizers,verbs=update
//+kubebuilder:rbac:groups=replication.storage.openshift.io,resources=volumegroupreplicationcontents,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=replication.storage.openshift.io,resources=volumegroupreplicationcontents/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=replication.storage.openshift.io,resources=volumegroupreplicationcontents/finalizers,verbs=update

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
func (r *VolumeGroupReplicationContentReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
_ = log.FromContext(ctx)

Expand Down
26 changes: 26 additions & 0 deletions deploy/controller/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,32 @@ rules:
- get
- patch
- update
- apiGroups:
- replication.storage.openshift.io
resources:
- volumegroupreplicationcontents
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumegroupreplicationcontents/finalizers
verbs:
- update
- apiGroups:
- replication.storage.openshift.io
resources:
- volumegroupreplicationcontents/status
verbs:
- get
- patch
- update
- apiGroups:
- replication.storage.openshift.io
resources:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22.0

require (
github.com/container-storage-interface/spec v1.9.0
github.com/csi-addons/spec v0.2.1-0.20230606140122-d20966d2e444
github.com/csi-addons/spec v0.2.1-0.20240619103729-12c61f25a2a5
github.com/go-logr/logr v1.4.2
github.com/kubernetes-csi/csi-lib-utils v0.18.1
github.com/onsi/ginkgo v1.16.5
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ github.com/cncf/xds/go v0.0.0-20240318125728-8a4994d93e50/go.mod h1:5e1+Vvlzido6
github.com/container-storage-interface/spec v1.9.0 h1:zKtX4STsq31Knz3gciCYCi1SXtO2HJDecIjDVboYavY=
github.com/container-storage-interface/spec v1.9.0/go.mod h1:ZfDu+3ZRyeVqxZM0Ds19MVLkN2d1XJ5MAfi1L3VjlT0=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/csi-addons/spec v0.2.1-0.20230606140122-d20966d2e444 h1:hWVCrZWVHctpWt6cQxV1I6dW3wpBDMg3Vrvu9uAuUxw=
github.com/csi-addons/spec v0.2.1-0.20230606140122-d20966d2e444/go.mod h1:Mwq4iLiUV4s+K1bszcWU6aMsR5KPsbIYzzszJ6+56vI=
github.com/csi-addons/spec v0.2.1-0.20240613070511-6a5ff0906b5a h1:UQQNA/VUz3zIXmDHI0bRUBPql2Xx+LvoZpDL7DbFS0k=
github.com/csi-addons/spec v0.2.1-0.20240613070511-6a5ff0906b5a/go.mod h1:Mwq4iLiUV4s+K1bszcWU6aMsR5KPsbIYzzszJ6+56vI=
github.com/csi-addons/spec v0.2.1-0.20240619103729-12c61f25a2a5 h1:/pXa+X+YKDPRI2JG8WEnxGKk6PcVZRhcLqdPks+bQa8=
github.com/csi-addons/spec v0.2.1-0.20240619103729-12c61f25a2a5/go.mod h1:Mwq4iLiUV4s+K1bszcWU6aMsR5KPsbIYzzszJ6+56vI=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
152 changes: 108 additions & 44 deletions internal/sidecar/service/volumereplication.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,24 @@ func (rs *ReplicationServer) EnableVolumeReplication(
klog.Errorf("Failed to get secret %s in namespace %s: %v", req.GetSecretName(), req.GetSecretNamespace(), err)
return nil, status.Error(codes.Internal, err.Error())
}
repReq := &csiReplication.EnableVolumeReplicationRequest{
ReplicationId: req.GetReplicationId(),
Parameters: req.GetParameters(),
Secrets: data,
}
if req.VolumeId != "" {
// setting repReq.VolumeId for backward compatibility for volume replication of a given volume
repReq.VolumeId = req.GetVolumeId() // nolint:staticcheck
repReq.ReplicationSource = &csiReplication.ReplicationSource{
Type: &csiReplication.ReplicationSource_Volume{
Volume: &csiReplication.ReplicationSource_VolumeSource{
VolumeId: req.GetVolumeId(),
},
},
}
}
_, err = rs.controllerClient.EnableVolumeReplication(ctx, repReq)

_, err = rs.controllerClient.EnableVolumeReplication(ctx,
&csiReplication.EnableVolumeReplicationRequest{
VolumeId: req.VolumeId,
ReplicationId: req.ReplicationId,
Parameters: req.Parameters,
Secrets: data,
})
if err != nil {
klog.Errorf("Failed to enable volume replication: %v", err)
return nil, err
Expand All @@ -91,13 +101,24 @@ func (rs *ReplicationServer) DisableVolumeReplication(
return nil, status.Error(codes.Internal, err.Error())
}

_, err = rs.controllerClient.DisableVolumeReplication(ctx,
&csiReplication.DisableVolumeReplicationRequest{
VolumeId: req.VolumeId,
ReplicationId: req.ReplicationId,
Parameters: req.Parameters,
Secrets: data,
})
repReq := &csiReplication.DisableVolumeReplicationRequest{
ReplicationId: req.GetReplicationId(),
Parameters: req.GetParameters(),
Secrets: data,
}
if req.GetVolumeId() != "" {
// setting repReq.VolumeId for backward compatibility for volume replication of a given volume
repReq.VolumeId = req.GetVolumeId() // nolint:staticcheck
repReq.ReplicationSource = &csiReplication.ReplicationSource{
Type: &csiReplication.ReplicationSource_Volume{
Volume: &csiReplication.ReplicationSource_VolumeSource{
VolumeId: req.GetVolumeId(),
},
},
}
}

_, err = rs.controllerClient.DisableVolumeReplication(ctx, repReq)
if err != nil {
klog.Errorf("Failed to disable volume replication: %v", err)
return nil, err
Expand All @@ -118,14 +139,25 @@ func (rs *ReplicationServer) PromoteVolume(
return nil, status.Error(codes.Internal, err.Error())
}

_, err = rs.controllerClient.PromoteVolume(ctx,
&csiReplication.PromoteVolumeRequest{
VolumeId: req.VolumeId,
ReplicationId: req.ReplicationId,
Force: req.Force,
Parameters: req.Parameters,
Secrets: data,
})
repReq := &csiReplication.PromoteVolumeRequest{
ReplicationId: req.GetReplicationId(),
Parameters: req.GetParameters(),
Force: req.GetForce(),
Secrets: data,
}
if req.GetVolumeId() != "" {
// setting repReq.VolumeId for backward compatibility for volume replication of a given volume
repReq.VolumeId = req.GetVolumeId() // nolint:staticcheck
repReq.ReplicationSource = &csiReplication.ReplicationSource{
Type: &csiReplication.ReplicationSource_Volume{
Volume: &csiReplication.ReplicationSource_VolumeSource{
VolumeId: req.GetVolumeId(),
},
},
}
}

_, err = rs.controllerClient.PromoteVolume(ctx, repReq)
if err != nil {
klog.Errorf("Failed to promote volume: %v", err)
return nil, err
Expand All @@ -146,14 +178,24 @@ func (rs *ReplicationServer) DemoteVolume(
return nil, status.Error(codes.Internal, err.Error())
}

_, err = rs.controllerClient.DemoteVolume(ctx,
&csiReplication.DemoteVolumeRequest{
VolumeId: req.VolumeId,
ReplicationId: req.ReplicationId,
Force: req.Force,
Parameters: req.Parameters,
Secrets: data,
})
repReq := &csiReplication.DemoteVolumeRequest{
ReplicationId: req.GetReplicationId(),
Parameters: req.GetParameters(),
Force: req.GetForce(),
Secrets: data,
}
if req.GetVolumeId() != "" {
// setting repReq.VolumeId for backward compatibility for volume replication of a given volume
repReq.VolumeId = req.GetVolumeId() // nolint:staticcheck
repReq.ReplicationSource = &csiReplication.ReplicationSource{
Type: &csiReplication.ReplicationSource_Volume{
Volume: &csiReplication.ReplicationSource_VolumeSource{
VolumeId: req.GetVolumeId(),
},
},
}
}
_, err = rs.controllerClient.DemoteVolume(ctx, repReq)
if err != nil {
klog.Errorf("Failed to demote volume: %v", err)
return nil, err
Expand All @@ -174,14 +216,25 @@ func (rs *ReplicationServer) ResyncVolume(
return nil, status.Error(codes.Internal, err.Error())
}

resp, err := rs.controllerClient.ResyncVolume(ctx,
&csiReplication.ResyncVolumeRequest{
VolumeId: req.VolumeId,
ReplicationId: req.ReplicationId,
Force: req.Force,
Parameters: req.Parameters,
Secrets: data,
})
repReq := &csiReplication.ResyncVolumeRequest{
ReplicationId: req.GetReplicationId(),
Parameters: req.GetParameters(),
Force: req.GetForce(),
Secrets: data,
}
if req.GetVolumeId() != "" {
// setting repReq.VolumeId for backward compatibility for volume replication of a given volume
repReq.VolumeId = req.GetVolumeId() // nolint:staticcheck
repReq.ReplicationSource = &csiReplication.ReplicationSource{
Type: &csiReplication.ReplicationSource_Volume{
Volume: &csiReplication.ReplicationSource_VolumeSource{
VolumeId: req.GetVolumeId(),
},
},
}
}

resp, err := rs.controllerClient.ResyncVolume(ctx, repReq)
if err != nil {
klog.Errorf("Failed to resync volume: %v", err)
return nil, err
Expand All @@ -204,12 +257,23 @@ func (rs *ReplicationServer) GetVolumeReplicationInfo(
return nil, status.Error(codes.Internal, err.Error())
}

resp, err := rs.controllerClient.GetVolumeReplicationInfo(ctx,
&csiReplication.GetVolumeReplicationInfoRequest{
VolumeId: req.VolumeId,
Secrets: data,
ReplicationId: req.ReplicationId,
})
repReq := &csiReplication.GetVolumeReplicationInfoRequest{
ReplicationId: req.GetReplicationId(),
Secrets: data,
}
if req.GetVolumeId() != "" {
// setting repReq.VolumeId for backward compatibility for volume replication of a given volume
repReq.VolumeId = req.GetVolumeId() // nolint:staticcheck
repReq.ReplicationSource = &csiReplication.ReplicationSource{
Type: &csiReplication.ReplicationSource_Volume{
Volume: &csiReplication.ReplicationSource_VolumeSource{
VolumeId: req.GetVolumeId(),
},
},
}
}

resp, err := rs.controllerClient.GetVolumeReplicationInfo(ctx, repReq)
if err != nil {
klog.Errorf("Failed to get volume replication info: %v", err)
return nil, err
Expand Down
9 changes: 2 additions & 7 deletions vendor/github.com/csi-addons/spec/lib/go/fence/fence.pb.go

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

Loading

0 comments on commit 5cec76b

Please sign in to comment.