Skip to content

Commit

Permalink
Skip replication enabled SC with PowerStore Metro mode in replicator …
Browse files Browse the repository at this point in the history
…sidecar (#156)
  • Loading branch information
santhoshatdell authored Sep 3, 2024
1 parent d25d148 commit bc543b9
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 15 deletions.
3 changes: 1 addition & 2 deletions api/v1/zz_generated.deepcopy.go

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

50 changes: 49 additions & 1 deletion controllers/csi-replicator/persistentvolume_controller_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2023 Dell Inc. or its subsidiaries. All Rights Reserved.
Copyright © 2021-2024 Dell Inc. or its subsidiaries. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -249,6 +249,54 @@ func (suite *PersistentVolumeControllerTestSuite) TestPVReconcileNonReplicationE
suite.Equal(pvObj.Annotations, updatedPV.Annotations, "No updates to annotation")
}

func (suite *PersistentVolumeControllerTestSuite) TestPVReconcilePowerMaxMetro() {
ctx := context.Background()
anotherSc := "another-storage-class"
scObj := utils.GetReplicationEnabledSCWithMetroMode(suite.driver.DriverName, anotherSc, "RdfMode")
err := suite.client.Create(context.Background(), scObj)
suite.NoError(err)
pvName := utils.FakePVName
pvObj := suite.getFakePV(pvName)
pvObj.Spec.StorageClassName = anotherSc

err = suite.client.Create(ctx, pvObj)
suite.NoError(err)

req := suite.getTypicalReconcileRequest(pvName)

res, err := suite.reconciler.Reconcile(context.Background(), req)
suite.NoError(err, "No error on PV reconcile")
suite.Equal(false, res.Requeue, "Requeue should be set to false")
updatedPV := new(corev1.PersistentVolume)
err = suite.client.Get(ctx, req.NamespacedName, updatedPV)
suite.NoError(err)
suite.Equal(pvObj.Annotations, updatedPV.Annotations, "No updates to annotation")
}

func (suite *PersistentVolumeControllerTestSuite) TestPVReconcilePowerStoreMetro() {
ctx := context.Background()
anotherSc := "another-storage-class"
scObj := utils.GetReplicationEnabledSCWithMetroMode(suite.driver.DriverName, anotherSc, "mode")
err := suite.client.Create(context.Background(), scObj)
suite.NoError(err)
pvName := utils.FakePVName
pvObj := suite.getFakePV(pvName)
pvObj.Spec.StorageClassName = anotherSc

err = suite.client.Create(ctx, pvObj)
suite.NoError(err)

req := suite.getTypicalReconcileRequest(pvName)

res, err := suite.reconciler.Reconcile(context.Background(), req)
suite.NoError(err, "No error on PV reconcile")
suite.Equal(false, res.Requeue, "Requeue should be set to false")
updatedPV := new(corev1.PersistentVolume)
err = suite.client.Get(ctx, req.NamespacedName, updatedPV)
suite.NoError(err)
suite.Equal(pvObj.Annotations, updatedPV.Annotations, "No updates to annotation")
}

func (suite *PersistentVolumeControllerTestSuite) TestPVReconcileInvalidSC() {
// scenario: Storage class has replication enabled but doesn't have remote storage class name
ctx := context.Background()
Expand Down
19 changes: 11 additions & 8 deletions controllers/csi-replicator/replicator_common.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Dell Inc. or its subsidiaries. All Rights Reserved.
Copyright © 2021-2024 Dell Inc. or its subsidiaries. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -39,13 +39,16 @@ func shouldContinue(ctx context.Context, class *storageV1.StorageClass, driverNa
return false
}

// TODO: This should be removed when we start supporting RGs for SRDF Metro too
// Check for PowerMax SRDF Metro
if value, ok := class.Parameters["replication.storage.dell.com/RdfMode"]; ok {
if strings.ToUpper(value) == "METRO" {
log.V(common.InfoLevel).Info("Metro replication is not supported by Dell CSI Replication Controllers")
return false
}
// Check for PowerMax SRDF Metro and skip since it is only supported at the driver level
if value, ok := class.Parameters["replication.storage.dell.com/RdfMode"]; ok && strings.ToUpper(value) == "METRO" {
log.V(common.InfoLevel).Info("Metro replication is not supported by Dell CSI Replication Controllers")
return false
}

// Check for PowerStore Metro and skip since it is only supported at the driver level
if value, ok := class.Parameters["replication.storage.dell.com/mode"]; ok && strings.ToUpper(value) == "METRO" {
log.V(common.InfoLevel).Info("Metro replication is not supported by Dell CSI Replication Controllers")
return false
}

// Check for the remote-storage-class-param on the local storage-class
Expand Down
4 changes: 2 additions & 2 deletions pkg/csi-clients/identity/identity_fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (m *mockIdentity) GetMigrationCapabilities(_ context.Context) (MigrationCap

func getSupportedActions() (ReplicationCapabilitySet, []*replication.SupportedActions) {
capResponse := &replication.GetReplicationCapabilityResponse{}
for i := 0; i < 3; i++ {
for i := int32(0); i < 3; i++ {
capResponse.Capabilities = append(capResponse.Capabilities, &replication.ReplicationCapability{
Type: &replication.ReplicationCapability_Rpc{
Rpc: &replication.ReplicationCapability_RPC{
Expand All @@ -83,7 +83,7 @@ func getSupportedActions() (ReplicationCapabilitySet, []*replication.SupportedAc
t := rpc.GetType()
capabilitySet[t] = true
}
for i := 1; i < 20; i++ {
for i := int32(1); i < 20; i++ {
capResponse.Actions = append(capResponse.Actions, &replication.SupportedActions{
Actions: &replication.SupportedActions_Type{
Type: replication.ActionTypes(i),
Expand Down
16 changes: 15 additions & 1 deletion test/e2e-framework/utils/utils.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2023 Dell Inc. or its subsidiaries. All Rights Reserved.
Copyright © 2021-2024 Dell Inc. or its subsidiaries. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -332,6 +332,20 @@ func GetNonReplicationEnabledSC(provisionerName, scName string) *storagev1.Stora
return &scObj
}

// GetReplicationEnabledSCWithMetroMode returns replication enabled StorageClass testing object with Metro mode
func GetReplicationEnabledSCWithMetroMode(provisionerName, scName, modeParamName string) *storagev1.StorageClass {
scObj := storagev1.StorageClass{
ObjectMeta: metav1.ObjectMeta{Name: scName},
Provisioner: provisionerName,
Parameters: map[string]string{
"param": "val",
"replication.storage.dell.com/isReplicationEnabled": "true",
"replication.storage.dell.com/" + modeParamName: "Metro",
},
}
return &scObj
}

// GetRGObj returns DellCSIReplicationGroup testing object
func GetRGObj(name, driverName, remoteClusterID, pgID, remotePGID string, params,
remoteParams map[string]string,
Expand Down
2 changes: 1 addition & 1 deletion test/mock-server/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (s *Replication) ProbeController(_ context.Context, in *commonext.ProbeCont
// GetReplicationCapabilities calls stub for GetReplicationCapabilities
func (s *Replication) GetReplicationCapabilities(_ context.Context, in *replication.GetReplicationCapabilityRequest) (*replication.GetReplicationCapabilityResponse, error) {
out := &replication.GetReplicationCapabilityResponse{}
outTemp := make(map[string][]int)
outTemp := make(map[string][]int32)
err := FindStub("Replication", "GetReplicationCapabilities", in, &outTemp)
for _, capability := range outTemp["capabilities"] {
out.Capabilities = append(out.Capabilities, &replication.ReplicationCapability{
Expand Down

0 comments on commit bc543b9

Please sign in to comment.