From 17013a3d5c75a455182bfca58587441b89d3b785 Mon Sep 17 00:00:00 2001 From: abhi16394 Date: Tue, 21 May 2024 19:40:50 -0400 Subject: [PATCH 01/12] Support downgrade --- operatorconfig/driverconfig/powerflex/v2.10.0/upgrade-path.yaml | 2 +- operatorconfig/driverconfig/powerflex/v2.8.0/upgrade-path.yaml | 2 +- operatorconfig/driverconfig/powerflex/v2.9.0/upgrade-path.yaml | 2 +- operatorconfig/driverconfig/powerflex/v2.9.1/upgrade-path.yaml | 2 +- operatorconfig/driverconfig/powerflex/v2.9.2/upgrade-path.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/operatorconfig/driverconfig/powerflex/v2.10.0/upgrade-path.yaml b/operatorconfig/driverconfig/powerflex/v2.10.0/upgrade-path.yaml index add639c8b..1a1170a4f 100644 --- a/operatorconfig/driverconfig/powerflex/v2.10.0/upgrade-path.yaml +++ b/operatorconfig/driverconfig/powerflex/v2.10.0/upgrade-path.yaml @@ -1,2 +1,2 @@ -minUpgradePath: v2.9.1 +minUpgradePath: v2.8.0 diff --git a/operatorconfig/driverconfig/powerflex/v2.8.0/upgrade-path.yaml b/operatorconfig/driverconfig/powerflex/v2.8.0/upgrade-path.yaml index f6ba20f92..624d827ab 100644 --- a/operatorconfig/driverconfig/powerflex/v2.8.0/upgrade-path.yaml +++ b/operatorconfig/driverconfig/powerflex/v2.8.0/upgrade-path.yaml @@ -1,2 +1,2 @@ -minUpgradePath: v2.7.0 +minUpgradePath: v2.6.0 diff --git a/operatorconfig/driverconfig/powerflex/v2.9.0/upgrade-path.yaml b/operatorconfig/driverconfig/powerflex/v2.9.0/upgrade-path.yaml index 1a1170a4f..f6ba20f92 100644 --- a/operatorconfig/driverconfig/powerflex/v2.9.0/upgrade-path.yaml +++ b/operatorconfig/driverconfig/powerflex/v2.9.0/upgrade-path.yaml @@ -1,2 +1,2 @@ -minUpgradePath: v2.8.0 +minUpgradePath: v2.7.0 diff --git a/operatorconfig/driverconfig/powerflex/v2.9.1/upgrade-path.yaml b/operatorconfig/driverconfig/powerflex/v2.9.1/upgrade-path.yaml index 1a1170a4f..f6ba20f92 100644 --- a/operatorconfig/driverconfig/powerflex/v2.9.1/upgrade-path.yaml +++ b/operatorconfig/driverconfig/powerflex/v2.9.1/upgrade-path.yaml @@ -1,2 +1,2 @@ -minUpgradePath: v2.8.0 +minUpgradePath: v2.7.0 diff --git a/operatorconfig/driverconfig/powerflex/v2.9.2/upgrade-path.yaml b/operatorconfig/driverconfig/powerflex/v2.9.2/upgrade-path.yaml index 1a1170a4f..f6ba20f92 100644 --- a/operatorconfig/driverconfig/powerflex/v2.9.2/upgrade-path.yaml +++ b/operatorconfig/driverconfig/powerflex/v2.9.2/upgrade-path.yaml @@ -1,2 +1,2 @@ -minUpgradePath: v2.8.0 +minUpgradePath: v2.7.0 From a1496a28bd306f945c6c845d83c6668f0756774c Mon Sep 17 00:00:00 2001 From: root Date: Fri, 24 May 2024 18:46:06 +0000 Subject: [PATCH 02/12] Variable changes and comments for downgrade --- deploy/operator.yaml | 2 +- pkg/utils/utils.go | 10 +++++----- samples/storage_csm_powerflex_v2100.yaml | 2 +- samples/storage_csm_powerflex_v290.yaml | 2 +- scripts/external-snapshotter | 1 + 5 files changed, 9 insertions(+), 8 deletions(-) create mode 160000 scripts/external-snapshotter diff --git a/deploy/operator.yaml b/deploy/operator.yaml index 260030729..920426826 100644 --- a/deploy/operator.yaml +++ b/deploy/operator.yaml @@ -1312,7 +1312,7 @@ spec: value: docker.io/dellemc/connectivity-client-docker-k8s:1.2.3 - name: RELATED_IMAGE_cert-persister value: docker.io/dellemc/connectivity-cert-persister-k8s:0.11.0 - image: docker.io/dellemc/dell-csm-operator:v1.5.0 + image: amaas-eos-mw1.cec.lab.emc.com:5036/csm-operator:update1 imagePullPolicy: Always livenessProbe: httpGet: diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index ccbc62a3f..aba40f06f 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -863,18 +863,18 @@ func versionParser(version string) (int, int, error) { // MinVersionCheck takes a driver name and a version of the form "vA.B.C" and checks it against the minimum version for the specified driver func MinVersionCheck(minVersion string, version string) (bool, error) { - minVersionA, minVersionB, err := versionParser(minVersion) + minMajorVersion, minMinorVersion, err := versionParser(minVersion) if err != nil { return false, err } - versionA, versionB, err := versionParser(version) + majorVersion, minorVersion , err := versionParser(version) if err != nil { return false, err } // compare each part according to minimum driver version - if versionA >= minVersionA && versionB >= minVersionB { + if majorVersion >= minMajorVersion && minorVersion >= minMinorVersion { return true, nil } return false, nil @@ -1136,12 +1136,12 @@ func IsValidUpgrade[T csmv1.CSMComponentType](ctx context.Context, oldVersion, n isUpgradeValid, _ := MinVersionCheck(minUpgradePath, oldVersion) if isUpgradeValid { - log.Infof("proceeding with valid upgrade of %s from version %s to version %s", csmComponentType, oldVersion, newVersion) + log.Infof("proceeding with valid upgrade/downgrade of %s from version %s to version %s", csmComponentType, oldVersion, newVersion) return isUpgradeValid, nil } log.Infof("not proceeding with invalid driver/module upgrade") - return isUpgradeValid, fmt.Errorf("upgrade of %s from version %s to %s not valid", csmComponentType, oldVersion, newVersion) + return isUpgradeValid, fmt.Errorf("upgrade/downgrade of %s from version %s to %s not valid", csmComponentType, oldVersion, newVersion) } func getUpgradeInfo[T csmv1.CSMComponentType](ctx context.Context, operatorConfig OperatorConfig, csmCompType T, oldVersion string) (string, error) { diff --git a/samples/storage_csm_powerflex_v2100.yaml b/samples/storage_csm_powerflex_v2100.yaml index 72539741d..63b08e730 100644 --- a/samples/storage_csm_powerflex_v2100.yaml +++ b/samples/storage_csm_powerflex_v2100.yaml @@ -221,7 +221,7 @@ spec: name: sdc envs: - name: MDM - value: "10.xx.xx.xx,10.xx.xx.xx" #provide MDM value + value: "10.247.13.230,10.247.13.232" #provide MDM value modules: # Authorization: enable csm-authorization for RBAC diff --git a/samples/storage_csm_powerflex_v290.yaml b/samples/storage_csm_powerflex_v290.yaml index 915b23a45..073459125 100644 --- a/samples/storage_csm_powerflex_v290.yaml +++ b/samples/storage_csm_powerflex_v290.yaml @@ -199,7 +199,7 @@ spec: name: sdc envs: - name: MDM - value: "10.xx.xx.xx,10.xx.xx.xx" #provide MDM value + value: "10.247.13.230,10.247.13.232" #provide MDM value modules: # Authorization: enable csm-authorization for RBAC diff --git a/scripts/external-snapshotter b/scripts/external-snapshotter new file mode 160000 index 000000000..f6f16cdbd --- /dev/null +++ b/scripts/external-snapshotter @@ -0,0 +1 @@ +Subproject commit f6f16cdbd5f958209a4b279a78d52ad4214ca82c From 73bee5d91a504c44436bce94cc9e35884b825134 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 24 May 2024 19:07:22 +0000 Subject: [PATCH 03/12] Add CODEOWNERS FILE --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 42f69dfdd..dba5e3e0e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -13,6 +13,7 @@ # Bharath Sreekanth (bharathsreekanth) # Chiman Jain (chimanjain) # Coulombel Florian (coulof) +# Daniyal Iqbal (daniyaliqbal2024) # Deepak Ghivari (Deepak-Ghivari) # Gallacher Sean (gallacher) # Harish H (HarishH-DELL) From 799223a63ee8592f56a779778e24ea68c21c5d10 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 24 May 2024 21:10:52 +0000 Subject: [PATCH 04/12] Variable changes and comments for downgrade --- .github/CODEOWNERS | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index dba5e3e0e..42f69dfdd 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -13,7 +13,6 @@ # Bharath Sreekanth (bharathsreekanth) # Chiman Jain (chimanjain) # Coulombel Florian (coulof) -# Daniyal Iqbal (daniyaliqbal2024) # Deepak Ghivari (Deepak-Ghivari) # Gallacher Sean (gallacher) # Harish H (HarishH-DELL) From f2508763fd1cd97c442cad06a4f96052d2427f86 Mon Sep 17 00:00:00 2001 From: abhi16394 Date: Tue, 28 May 2024 13:49:35 -0400 Subject: [PATCH 05/12] Fix Annotation CSMVersion --- controllers/csm_controller.go | 30 +++++++++++++++++++++++++++--- pkg/utils/utils.go | 10 +++++----- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/controllers/csm_controller.go b/controllers/csm_controller.go index 855515cf4..ff2d6de3e 100644 --- a/controllers/csm_controller.go +++ b/controllers/csm_controller.go @@ -1283,7 +1283,7 @@ func (r *ContainerStorageModuleReconciler) PreChecks(ctx context.Context, cr *cs return fmt.Errorf("unsupported driver type %s", cr.Spec.Driver.CSIDriverType) } - upgradeValid, err := checkUpgrade(ctx, cr, operatorConfig) + upgradeValid, err := r.checkUpgrade(ctx, cr, operatorConfig) if err != nil { return fmt.Errorf("failed upgrade check: %v", err) } else if !upgradeValid { @@ -1357,7 +1357,7 @@ func (r *ContainerStorageModuleReconciler) PreChecks(ctx context.Context, cr *cs } // Check for upgrade/if upgrade is appropriate -func checkUpgrade(ctx context.Context, cr *csmv1.ContainerStorageModule, operatorConfig utils.OperatorConfig) (bool, error) { +func (r *ContainerStorageModuleReconciler) checkUpgrade(ctx context.Context, cr *csmv1.ContainerStorageModule, operatorConfig utils.OperatorConfig) (bool, error) { log := logger.GetLogger(ctx) // If it is an upgrade/downgrade, check to see if we meet the minimum version using GetUpgradeInfo, which returns the minimum version required @@ -1377,7 +1377,24 @@ func checkUpgrade(ctx context.Context, cr *csmv1.ContainerStorageModule, operato driverType = csmv1.PowerScaleName } newVersion := cr.Spec.Driver.ConfigVersion - return utils.IsValidUpgrade(ctx, oldVersion, newVersion, driverType, operatorConfig) + isValidUpgrade, err := utils.IsValidUpgrade(ctx, oldVersion, newVersion, driverType, operatorConfig) + if err != nil { + return false, err + } + if !isValidUpgrade { + return false, fmt.Errorf("invalid upgrade path") + } + // Call applyConfigVersionAnnotations during upgrade + isUpdated := applyConfigVersionAnnotations(ctx, cr) + if isUpdated { + err = r.GetClient().Update(ctx, cr) + if err != nil { + log.Error(err, "Failed to update CR with annotation") + return false, err + } + } + return true, nil + //return utils.IsValidUpgrade(ctx, oldVersion, newVersion, driverType, operatorConfig) } log.Infow("proceeding with fresh driver install") return true, nil @@ -1390,6 +1407,7 @@ func applyConfigVersionAnnotations(ctx context.Context, instance *csmv1.Containe // If driver/module has not been initialized yet, we first annotate the component with the config version annotation annotations := instance.GetAnnotations() + var configVersion string isUpdated := false if annotations == nil { annotations = make(map[string]string) @@ -1407,6 +1425,12 @@ func applyConfigVersionAnnotations(ctx context.Context, instance *csmv1.Containe isUpdated = true log.Infof("Installing csm component %s with config Version %s. Updating Annotations with Config Version", instance.GetName(), configVersion) + } else { + configVersion = instance.Spec.Driver.ConfigVersion + annotations[configVersionKey] = configVersion + isUpdated = true + log.Infof("Installing csm component %s with config Version %s. Updating Annotations with Config Version", + instance.GetName(), configVersion) } instance.SetAnnotations(annotations) return isUpdated diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index ccbc62a3f..fe34c439b 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -863,18 +863,18 @@ func versionParser(version string) (int, int, error) { // MinVersionCheck takes a driver name and a version of the form "vA.B.C" and checks it against the minimum version for the specified driver func MinVersionCheck(minVersion string, version string) (bool, error) { - minVersionA, minVersionB, err := versionParser(minVersion) + minMajorversion, minMinorversion, err := versionParser(minVersion) if err != nil { return false, err } - versionA, versionB, err := versionParser(version) + majorVersion, minorVersion, err := versionParser(version) if err != nil { return false, err } // compare each part according to minimum driver version - if versionA >= minVersionA && versionB >= minVersionB { + if majorVersion >= minMajorversion && minorVersion >= minMinorversion { return true, nil } return false, nil @@ -1136,12 +1136,12 @@ func IsValidUpgrade[T csmv1.CSMComponentType](ctx context.Context, oldVersion, n isUpgradeValid, _ := MinVersionCheck(minUpgradePath, oldVersion) if isUpgradeValid { - log.Infof("proceeding with valid upgrade of %s from version %s to version %s", csmComponentType, oldVersion, newVersion) + log.Infof("proceeding with valid upgrade/downgrade of %s from version %s to version %s", csmComponentType, oldVersion, newVersion) return isUpgradeValid, nil } log.Infof("not proceeding with invalid driver/module upgrade") - return isUpgradeValid, fmt.Errorf("upgrade of %s from version %s to %s not valid", csmComponentType, oldVersion, newVersion) + return isUpgradeValid, fmt.Errorf("upgrade/downgrade of %s from version %s to %s not valid", csmComponentType, oldVersion, newVersion) } func getUpgradeInfo[T csmv1.CSMComponentType](ctx context.Context, operatorConfig OperatorConfig, csmCompType T, oldVersion string) (string, error) { From 681979030719f3239b9c97a225a730dfd58d84c2 Mon Sep 17 00:00:00 2001 From: abhi16394 Date: Tue, 28 May 2024 14:01:02 -0400 Subject: [PATCH 06/12] removing comment --- controllers/csm_controller.go | 1 - 1 file changed, 1 deletion(-) diff --git a/controllers/csm_controller.go b/controllers/csm_controller.go index ff2d6de3e..4b89efb1d 100644 --- a/controllers/csm_controller.go +++ b/controllers/csm_controller.go @@ -1394,7 +1394,6 @@ func (r *ContainerStorageModuleReconciler) checkUpgrade(ctx context.Context, cr } } return true, nil - //return utils.IsValidUpgrade(ctx, oldVersion, newVersion, driverType, operatorConfig) } log.Infow("proceeding with fresh driver install") return true, nil From 09d496bc08956933f8cadfb7d1c7eaee6f6326e5 Mon Sep 17 00:00:00 2001 From: abhi16394 Date: Tue, 28 May 2024 16:33:22 -0400 Subject: [PATCH 07/12] Fixing unit-test --- controllers/csm_controller.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/controllers/csm_controller.go b/controllers/csm_controller.go index 4b89efb1d..d6dafc711 100644 --- a/controllers/csm_controller.go +++ b/controllers/csm_controller.go @@ -1360,6 +1360,8 @@ func (r *ContainerStorageModuleReconciler) PreChecks(ctx context.Context, cr *cs func (r *ContainerStorageModuleReconciler) checkUpgrade(ctx context.Context, cr *csmv1.ContainerStorageModule, operatorConfig utils.OperatorConfig) (bool, error) { log := logger.GetLogger(ctx) + var driverType csmv1.DriverType + newVersion := "" // If it is an upgrade/downgrade, check to see if we meet the minimum version using GetUpgradeInfo, which returns the minimum version required // for the desired upgrade. If the upgrade path is not valid fail // Existing version @@ -1368,15 +1370,16 @@ func (r *ContainerStorageModuleReconciler) checkUpgrade(ctx context.Context, cr // If annotation exists, we are doing an upgrade or modify if configVersionExists { if cr.HasModule(csmv1.AuthorizationServer) { - newVersion := cr.GetModule(csmv1.AuthorizationServer).ConfigVersion - return utils.IsValidUpgrade(ctx, oldVersion, newVersion, csmv1.Authorization, operatorConfig) - } - driverType := cr.Spec.Driver.CSIDriverType - if driverType == csmv1.PowerScale { - // use powerscale instead of isilon as the folder name is powerscale - driverType = csmv1.PowerScaleName + newVersion = cr.GetModule(csmv1.AuthorizationServer).ConfigVersion + //return utils.IsValidUpgrade(ctx, oldVersion, newVersion, csmv1.Authorization, operatorConfig) + } else { + driverType = cr.Spec.Driver.CSIDriverType + if driverType == csmv1.PowerScale { + // use powerscale instead of isilon as the folder name is powerscale + driverType = csmv1.PowerScaleName + } + newVersion = cr.Spec.Driver.ConfigVersion } - newVersion := cr.Spec.Driver.ConfigVersion isValidUpgrade, err := utils.IsValidUpgrade(ctx, oldVersion, newVersion, driverType, operatorConfig) if err != nil { return false, err @@ -1425,7 +1428,12 @@ func applyConfigVersionAnnotations(ctx context.Context, instance *csmv1.Containe log.Infof("Installing csm component %s with config Version %s. Updating Annotations with Config Version", instance.GetName(), configVersion) } else { - configVersion = instance.Spec.Driver.ConfigVersion + if instance.HasModule(csmv1.AuthorizationServer) { + configVersion = instance.GetModule(csmv1.AuthorizationServer).ConfigVersion + } else { + configVersion = instance.Spec.Driver.ConfigVersion + } + //configVersion = instance.Spec.Driver.ConfigVersion annotations[configVersionKey] = configVersion isUpdated = true log.Infof("Installing csm component %s with config Version %s. Updating Annotations with Config Version", From 3690d99af5dd283c535658dcefef677950165c49 Mon Sep 17 00:00:00 2001 From: abhi16394 Date: Tue, 28 May 2024 17:26:29 -0400 Subject: [PATCH 08/12] increase unit-test coverage --- controllers/csm_controller.go | 31 ++++++------------------ deploy/operator.yaml | 2 +- pkg/utils/utils.go | 4 +-- samples/storage_csm_powerflex_v2100.yaml | 2 +- samples/storage_csm_powerflex_v290.yaml | 2 +- 5 files changed, 12 insertions(+), 29 deletions(-) diff --git a/controllers/csm_controller.go b/controllers/csm_controller.go index d6dafc711..af2698307 100644 --- a/controllers/csm_controller.go +++ b/controllers/csm_controller.go @@ -1360,8 +1360,8 @@ func (r *ContainerStorageModuleReconciler) PreChecks(ctx context.Context, cr *cs func (r *ContainerStorageModuleReconciler) checkUpgrade(ctx context.Context, cr *csmv1.ContainerStorageModule, operatorConfig utils.OperatorConfig) (bool, error) { log := logger.GetLogger(ctx) - var driverType csmv1.DriverType - newVersion := "" + //var driverType csmv1.DriverType + //newVersion := "" // If it is an upgrade/downgrade, check to see if we meet the minimum version using GetUpgradeInfo, which returns the minimum version required // for the desired upgrade. If the upgrade path is not valid fail // Existing version @@ -1370,33 +1370,17 @@ func (r *ContainerStorageModuleReconciler) checkUpgrade(ctx context.Context, cr // If annotation exists, we are doing an upgrade or modify if configVersionExists { if cr.HasModule(csmv1.AuthorizationServer) { - newVersion = cr.GetModule(csmv1.AuthorizationServer).ConfigVersion - //return utils.IsValidUpgrade(ctx, oldVersion, newVersion, csmv1.Authorization, operatorConfig) + newVersion := cr.GetModule(csmv1.AuthorizationServer).ConfigVersion + return utils.IsValidUpgrade(ctx, oldVersion, newVersion, csmv1.Authorization, operatorConfig) } else { - driverType = cr.Spec.Driver.CSIDriverType + driverType := cr.Spec.Driver.CSIDriverType if driverType == csmv1.PowerScale { // use powerscale instead of isilon as the folder name is powerscale driverType = csmv1.PowerScaleName } - newVersion = cr.Spec.Driver.ConfigVersion + newVersion := cr.Spec.Driver.ConfigVersion + return utils.IsValidUpgrade(ctx, oldVersion, newVersion, driverType, operatorConfig) } - isValidUpgrade, err := utils.IsValidUpgrade(ctx, oldVersion, newVersion, driverType, operatorConfig) - if err != nil { - return false, err - } - if !isValidUpgrade { - return false, fmt.Errorf("invalid upgrade path") - } - // Call applyConfigVersionAnnotations during upgrade - isUpdated := applyConfigVersionAnnotations(ctx, cr) - if isUpdated { - err = r.GetClient().Update(ctx, cr) - if err != nil { - log.Error(err, "Failed to update CR with annotation") - return false, err - } - } - return true, nil } log.Infow("proceeding with fresh driver install") return true, nil @@ -1433,7 +1417,6 @@ func applyConfigVersionAnnotations(ctx context.Context, instance *csmv1.Containe } else { configVersion = instance.Spec.Driver.ConfigVersion } - //configVersion = instance.Spec.Driver.ConfigVersion annotations[configVersionKey] = configVersion isUpdated = true log.Infof("Installing csm component %s with config Version %s. Updating Annotations with Config Version", diff --git a/deploy/operator.yaml b/deploy/operator.yaml index 920426826..260030729 100644 --- a/deploy/operator.yaml +++ b/deploy/operator.yaml @@ -1312,7 +1312,7 @@ spec: value: docker.io/dellemc/connectivity-client-docker-k8s:1.2.3 - name: RELATED_IMAGE_cert-persister value: docker.io/dellemc/connectivity-cert-persister-k8s:0.11.0 - image: amaas-eos-mw1.cec.lab.emc.com:5036/csm-operator:update1 + image: docker.io/dellemc/dell-csm-operator:v1.5.0 imagePullPolicy: Always livenessProbe: httpGet: diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index aba40f06f..53fe69beb 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -868,13 +868,13 @@ func MinVersionCheck(minVersion string, version string) (bool, error) { return false, err } - majorVersion, minorVersion , err := versionParser(version) + majorVersion, minorVersion, err := versionParser(version) if err != nil { return false, err } // compare each part according to minimum driver version - if majorVersion >= minMajorVersion && minorVersion >= minMinorVersion { + if majorVersion >= minMajorVersion && minorVersion >= minMinorVersion { return true, nil } return false, nil diff --git a/samples/storage_csm_powerflex_v2100.yaml b/samples/storage_csm_powerflex_v2100.yaml index 63b08e730..72539741d 100644 --- a/samples/storage_csm_powerflex_v2100.yaml +++ b/samples/storage_csm_powerflex_v2100.yaml @@ -221,7 +221,7 @@ spec: name: sdc envs: - name: MDM - value: "10.247.13.230,10.247.13.232" #provide MDM value + value: "10.xx.xx.xx,10.xx.xx.xx" #provide MDM value modules: # Authorization: enable csm-authorization for RBAC diff --git a/samples/storage_csm_powerflex_v290.yaml b/samples/storage_csm_powerflex_v290.yaml index 073459125..915b23a45 100644 --- a/samples/storage_csm_powerflex_v290.yaml +++ b/samples/storage_csm_powerflex_v290.yaml @@ -199,7 +199,7 @@ spec: name: sdc envs: - name: MDM - value: "10.247.13.230,10.247.13.232" #provide MDM value + value: "10.xx.xx.xx,10.xx.xx.xx" #provide MDM value modules: # Authorization: enable csm-authorization for RBAC From cedd4502babdbec4f325386404db57c6ed2cf72b Mon Sep 17 00:00:00 2001 From: abhi16394 Date: Tue, 28 May 2024 17:35:52 -0400 Subject: [PATCH 09/12] Fix lint errors --- controllers/csm_controller.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/controllers/csm_controller.go b/controllers/csm_controller.go index af2698307..21fa07151 100644 --- a/controllers/csm_controller.go +++ b/controllers/csm_controller.go @@ -1360,8 +1360,6 @@ func (r *ContainerStorageModuleReconciler) PreChecks(ctx context.Context, cr *cs func (r *ContainerStorageModuleReconciler) checkUpgrade(ctx context.Context, cr *csmv1.ContainerStorageModule, operatorConfig utils.OperatorConfig) (bool, error) { log := logger.GetLogger(ctx) - //var driverType csmv1.DriverType - //newVersion := "" // If it is an upgrade/downgrade, check to see if we meet the minimum version using GetUpgradeInfo, which returns the minimum version required // for the desired upgrade. If the upgrade path is not valid fail // Existing version @@ -1372,15 +1370,15 @@ func (r *ContainerStorageModuleReconciler) checkUpgrade(ctx context.Context, cr if cr.HasModule(csmv1.AuthorizationServer) { newVersion := cr.GetModule(csmv1.AuthorizationServer).ConfigVersion return utils.IsValidUpgrade(ctx, oldVersion, newVersion, csmv1.Authorization, operatorConfig) - } else { - driverType := cr.Spec.Driver.CSIDriverType - if driverType == csmv1.PowerScale { - // use powerscale instead of isilon as the folder name is powerscale - driverType = csmv1.PowerScaleName - } - newVersion := cr.Spec.Driver.ConfigVersion - return utils.IsValidUpgrade(ctx, oldVersion, newVersion, driverType, operatorConfig) } + driverType := cr.Spec.Driver.CSIDriverType + if driverType == csmv1.PowerScale { + // use powerscale instead of isilon as the folder name is powerscale + driverType = csmv1.PowerScaleName + } + newVersion := cr.Spec.Driver.ConfigVersion + return utils.IsValidUpgrade(ctx, oldVersion, newVersion, driverType, operatorConfig) + } log.Infow("proceeding with fresh driver install") return true, nil From e8497282d567150ffee5dea6c9ca033a6b86b832 Mon Sep 17 00:00:00 2001 From: abhi16394 Date: Wed, 29 May 2024 21:47:16 -0400 Subject: [PATCH 10/12] Fix bug in versioncheck --- controllers/csm_controller.go | 37 ++++++++++++----------------------- pkg/utils/utils.go | 29 +++++++++++++++++++++------ 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/controllers/csm_controller.go b/controllers/csm_controller.go index 21fa07151..d1560dbf2 100644 --- a/controllers/csm_controller.go +++ b/controllers/csm_controller.go @@ -1384,44 +1384,33 @@ func (r *ContainerStorageModuleReconciler) checkUpgrade(ctx context.Context, cr return true, nil } -// TODO: refactor this +// applyConfigVersionAnnotations - applies the config version annotation to the instance. func applyConfigVersionAnnotations(ctx context.Context, instance *csmv1.ContainerStorageModule) bool { log := logger.GetLogger(ctx) - // If driver/module has not been initialized yet, we first annotate the component with the config version annotation - annotations := instance.GetAnnotations() - var configVersion string - isUpdated := false if annotations == nil { annotations = make(map[string]string) } + annotations[CSMVersionKey] = CSMVersion - if _, ok := annotations[configVersionKey]; !ok { - configVersion := "" - if instance.HasModule(csmv1.AuthorizationServer) { - configVersion = instance.GetModule(csmv1.AuthorizationServer).ConfigVersion - } else { - configVersion = instance.Spec.Driver.ConfigVersion - } - annotations[configVersionKey] = configVersion - isUpdated = true - log.Infof("Installing csm component %s with config Version %s. Updating Annotations with Config Version", - instance.GetName(), configVersion) + var configVersion string + if instance.HasModule(csmv1.AuthorizationServer) { + configVersion = instance.GetModule(csmv1.AuthorizationServer).ConfigVersion } else { - if instance.HasModule(csmv1.AuthorizationServer) { - configVersion = instance.GetModule(csmv1.AuthorizationServer).ConfigVersion - } else { - configVersion = instance.Spec.Driver.ConfigVersion - } + configVersion = instance.Spec.Driver.ConfigVersion + } + + if annotations[configVersionKey] != configVersion { annotations[configVersionKey] = configVersion - isUpdated = true log.Infof("Installing csm component %s with config Version %s. Updating Annotations with Config Version", instance.GetName(), configVersion) + instance.SetAnnotations(annotations) + return true } - instance.SetAnnotations(annotations) - return isUpdated + + return false } // GetClient - returns the split client diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 53fe69beb..834e34ce0 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -874,7 +874,9 @@ func MinVersionCheck(minVersion string, version string) (bool, error) { } // compare each part according to minimum driver version - if majorVersion >= minMajorVersion && minorVersion >= minMinorVersion { + if majorVersion > minMajorVersion { + return true, nil + } else if majorVersion == minMajorVersion && minorVersion >= minMinorVersion { return true, nil } return false, nil @@ -1126,15 +1128,30 @@ func IsValidUpgrade[T csmv1.CSMComponentType](ctx context.Context, oldVersion, n return true, nil } - // if not equal, it is an upgrade/downgrade - // get minimum required version for upgrade - minUpgradePath, err := getUpgradeInfo(ctx, operatorConfig, csmComponentType, newVersion) + var minUpgradePath string + var err error + var isUpgradeValid bool + + log.Info("####oldVersion: ", oldVersion, " ###newVersion: ", newVersion) + + isVersionCheck, _ := MinVersionCheck(oldVersion, newVersion) + + // if it is an upgrade + if isVersionCheck { + log.Info("proceeding with valid upgrade of driver/module") + minUpgradePath, err = getUpgradeInfo(ctx, operatorConfig, csmComponentType, newVersion) + isUpgradeValid, _ = MinVersionCheck(minUpgradePath, oldVersion) + } else { + // if it is a downgrade + log.Info("proceeding with valid downgrade of driver/module") + minUpgradePath, err = getUpgradeInfo(ctx, operatorConfig, csmComponentType, oldVersion) + isUpgradeValid, _ = MinVersionCheck(minUpgradePath, newVersion) + } + if err != nil { log.Infow("getUpgradeInfo not successful") return false, err } - - isUpgradeValid, _ := MinVersionCheck(minUpgradePath, oldVersion) if isUpgradeValid { log.Infof("proceeding with valid upgrade/downgrade of %s from version %s to version %s", csmComponentType, oldVersion, newVersion) return isUpgradeValid, nil From 9d6ba4f019d7a247dc9f4668e34a39d00d2c5b0b Mon Sep 17 00:00:00 2001 From: abhi16394 Date: Fri, 31 May 2024 12:55:40 -0400 Subject: [PATCH 11/12] Change variable name --- pkg/utils/utils.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 834e34ce0..76ca9740d 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -1129,30 +1129,32 @@ func IsValidUpgrade[T csmv1.CSMComponentType](ctx context.Context, oldVersion, n } var minUpgradePath string + var minDowngradePath string var err error var isUpgradeValid bool + var isDowngradeValid bool log.Info("####oldVersion: ", oldVersion, " ###newVersion: ", newVersion) - isVersionCheck, _ := MinVersionCheck(oldVersion, newVersion) + isUpgrade, _ := MinVersionCheck(oldVersion, newVersion) // if it is an upgrade - if isVersionCheck { + if isUpgrade { log.Info("proceeding with valid upgrade of driver/module") minUpgradePath, err = getUpgradeInfo(ctx, operatorConfig, csmComponentType, newVersion) isUpgradeValid, _ = MinVersionCheck(minUpgradePath, oldVersion) } else { // if it is a downgrade log.Info("proceeding with valid downgrade of driver/module") - minUpgradePath, err = getUpgradeInfo(ctx, operatorConfig, csmComponentType, oldVersion) - isUpgradeValid, _ = MinVersionCheck(minUpgradePath, newVersion) + minDowngradePath, err = getUpgradeInfo(ctx, operatorConfig, csmComponentType, oldVersion) + isDowngradeValid, _ = MinVersionCheck(minDowngradePath, newVersion) } if err != nil { log.Infow("getUpgradeInfo not successful") return false, err } - if isUpgradeValid { + if isUpgradeValid || isDowngradeValid { log.Infof("proceeding with valid upgrade/downgrade of %s from version %s to version %s", csmComponentType, oldVersion, newVersion) return isUpgradeValid, nil } From 6aedcb3165e457c4fe82bf1ba028cf9a589174ea Mon Sep 17 00:00:00 2001 From: abhi16394 Date: Fri, 31 May 2024 13:13:26 -0400 Subject: [PATCH 12/12] Fix changes --- pkg/utils/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 76ca9740d..1ec868e59 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -1156,7 +1156,7 @@ func IsValidUpgrade[T csmv1.CSMComponentType](ctx context.Context, oldVersion, n } if isUpgradeValid || isDowngradeValid { log.Infof("proceeding with valid upgrade/downgrade of %s from version %s to version %s", csmComponentType, oldVersion, newVersion) - return isUpgradeValid, nil + return isUpgradeValid || isDowngradeValid, nil } log.Infof("not proceeding with invalid driver/module upgrade")