From e209d98f11e8dc0f3565f964312a63945972cf31 Mon Sep 17 00:00:00 2001 From: JacobGros Date: Thu, 9 Jan 2025 19:10:40 -0500 Subject: [PATCH 1/6] fix issue w/ min manifests --- pkg/drivers/commonconfig.go | 14 ++++++++++---- tests/e2e/testfiles/scenarios.yaml | 25 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/pkg/drivers/commonconfig.go b/pkg/drivers/commonconfig.go index 9b3adc8a..f041789f 100644 --- a/pkg/drivers/commonconfig.go +++ b/pkg/drivers/commonconfig.go @@ -71,8 +71,11 @@ func GetController(ctx context.Context, cr csmv1.ContainerStorageModule, operato } controllerYAML := driverYAML.(utils.ControllerYAML) - controllerYAML.Deployment.Spec.Replicas = &cr.Spec.Driver.Replicas + // if using a minimal manifest, replicas may not be present. + if cr.Spec.Driver.Replicas != 0 { + controllerYAML.Deployment.Spec.Replicas = &cr.Spec.Driver.Replicas + } if cr.Spec.Driver.Controller != nil && len(cr.Spec.Driver.Controller.Tolerations) != 0 { tols := make([]acorev1.TolerationApplyConfiguration, 0) for _, t := range cr.Spec.Driver.Controller.Tolerations { @@ -331,9 +334,12 @@ func GetNode(ctx context.Context, cr csmv1.ContainerStorageModule, operatorConfi utils.UpdateInitContainerApply(updatedCr.Spec.Driver.InitContainers, &initcontainers[i]) // mdm-container is exclusive to powerflex driver deamonset, will use the driver image as an init container if *initcontainers[i].Name == "mdm-container" { - if string(cr.Spec.Driver.Common.Image) != "" { - image := string(cr.Spec.Driver.Common.Image) - initcontainers[i].Image = &image + // driver minimial manifest may not have common section + if cr.Spec.Driver.Common != nil { + if string(cr.Spec.Driver.Common.Image) != "" { + image := string(cr.Spec.Driver.Common.Image) + initcontainers[i].Image = &image + } } } } diff --git a/tests/e2e/testfiles/scenarios.yaml b/tests/e2e/testfiles/scenarios.yaml index a22ea9f8..b90cb57a 100644 --- a/tests/e2e/testfiles/scenarios.yaml +++ b/tests/e2e/testfiles/scenarios.yaml @@ -2140,3 +2140,28 @@ run: - /bin/bash modify_zoning_labels.sh remove-all-zones - kubectl get nodes --show-labels + +- scenario: "Install PowerFlex Driver (Minimal, Standalone)" + paths: + - "testfiles/minimal-testfiles/storage_csm_powerflex.yaml" + tags: + - "powerflex" + - "sanity" + steps: + - "Given an environment with k8s or openshift, and CSM operator installed" + - "Create storageclass with name [op-e2e-vxflexos] and template [testfiles/powerflex-templates/powerflex-storageclass-template.yaml] for [pflex]" + - "Set up temporary secret with template [testfiles/powerflex-templates/powerflex-secret-template.yaml] name [test-vxflexos-config] in namespace [test-vxflexos] for [pflex]" + - "Apply custom resource [1]" + - "Validate custom resource [1]" + - "Validate [powerflex] driver from CR [1] is installed" + - "Validate [powerflex] driver spec from CR [1]" + - "Run custom test" + # cleanup + - "Enable forceRemoveDriver on CR [1]" + - "Delete custom resource [1]" + - "Validate [powerflex] driver from CR [1] is not installed" + - "Restore template [testfiles/powerflex-templates/powerflex-storageclass-template.yaml] for [pflex]" + customTest: + - name: Cert CSI + run: + - cert-csi test vio --sc op-e2e-vxflexos --chainNumber 2 --chainLength 2 From 89576a73588ab7a2a5f05975f1d894d969e23a31 Mon Sep 17 00:00:00 2001 From: mgandharva Date: Fri, 10 Jan 2025 08:25:44 -0500 Subject: [PATCH 2/6] fix: updated the scenarios --- tests/e2e/testfiles/scenarios.yaml | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/tests/e2e/testfiles/scenarios.yaml b/tests/e2e/testfiles/scenarios.yaml index b90cb57a..a22ea9f8 100644 --- a/tests/e2e/testfiles/scenarios.yaml +++ b/tests/e2e/testfiles/scenarios.yaml @@ -2140,28 +2140,3 @@ run: - /bin/bash modify_zoning_labels.sh remove-all-zones - kubectl get nodes --show-labels - -- scenario: "Install PowerFlex Driver (Minimal, Standalone)" - paths: - - "testfiles/minimal-testfiles/storage_csm_powerflex.yaml" - tags: - - "powerflex" - - "sanity" - steps: - - "Given an environment with k8s or openshift, and CSM operator installed" - - "Create storageclass with name [op-e2e-vxflexos] and template [testfiles/powerflex-templates/powerflex-storageclass-template.yaml] for [pflex]" - - "Set up temporary secret with template [testfiles/powerflex-templates/powerflex-secret-template.yaml] name [test-vxflexos-config] in namespace [test-vxflexos] for [pflex]" - - "Apply custom resource [1]" - - "Validate custom resource [1]" - - "Validate [powerflex] driver from CR [1] is installed" - - "Validate [powerflex] driver spec from CR [1]" - - "Run custom test" - # cleanup - - "Enable forceRemoveDriver on CR [1]" - - "Delete custom resource [1]" - - "Validate [powerflex] driver from CR [1] is not installed" - - "Restore template [testfiles/powerflex-templates/powerflex-storageclass-template.yaml] for [pflex]" - customTest: - - name: Cert CSI - run: - - cert-csi test vio --sc op-e2e-vxflexos --chainNumber 2 --chainLength 2 From 7f3c38b283793395bc7236e870905eb32273b676 Mon Sep 17 00:00:00 2001 From: JacobGros Date: Fri, 10 Jan 2025 10:39:39 -0500 Subject: [PATCH 3/6] remove bad line from scenarios.yaml --- tests/e2e/testfiles/scenarios.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/testfiles/scenarios.yaml b/tests/e2e/testfiles/scenarios.yaml index a22ea9f8..cfec3229 100644 --- a/tests/e2e/testfiles/scenarios.yaml +++ b/tests/e2e/testfiles/scenarios.yaml @@ -168,7 +168,6 @@ - "Delete custom resource [4]" - "Validate [powerflex] driver from CR [4] is not installed" - "Delete custom resource [2]" - - "Validate [authorization-proxy-server] module from CR [2] is not installed" - "Restore template [testfiles/powerflex-templates/powerflex-storageclass-template.yaml] for [pflex]" customTest: - name: Cert CSI From 52e13eb072c1f3670afe41dccf609454687e1c97 Mon Sep 17 00:00:00 2001 From: JacobGros Date: Fri, 10 Jan 2025 11:37:50 -0500 Subject: [PATCH 4/6] change replicas to 1 when deploying to control plane node --- tests/e2e/testfiles/storage_csm_powerflex_alt_vals_2.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/e2e/testfiles/storage_csm_powerflex_alt_vals_2.yaml b/tests/e2e/testfiles/storage_csm_powerflex_alt_vals_2.yaml index 995597d7..6f9e29dc 100644 --- a/tests/e2e/testfiles/storage_csm_powerflex_alt_vals_2.yaml +++ b/tests/e2e/testfiles/storage_csm_powerflex_alt_vals_2.yaml @@ -12,7 +12,8 @@ spec: # Default value: ReadWriteOnceWithFSType fSGroupPolicy: "None" configVersion: v2.13.0 - replicas: 2 + # setting replicas to 1 since this file is using control node to install deployment on control plane node + replicas: 1 dnsPolicy: ClusterFirstWithHostNet forceRemoveDriver: false common: From db118eed2dbda7497f63ab59630ec398c7e799d4 Mon Sep 17 00:00:00 2001 From: JacobGros Date: Fri, 10 Jan 2025 13:12:27 -0500 Subject: [PATCH 5/6] add UT to cover missing scenario --- pkg/drivers/common_test.go | 7 ++++++- pkg/drivers/commonconfig_test.go | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/drivers/common_test.go b/pkg/drivers/common_test.go index bc79de9b..2942160d 100644 --- a/pkg/drivers/common_test.go +++ b/pkg/drivers/common_test.go @@ -116,7 +116,7 @@ func csmWithTolerations(driver csmv1.DriverType, version string) csmv1.Container return res } -// JJL make a functino that uses the standard name and calls this function +// JJL make a function that uses the standard name and calls this function // makes a pflex csm object func csmForPowerFlex(customCSMName string) csmv1.ContainerStorageModule { res := shared.MakeCSM(customCSMName, pFlexNS, shared.PFlexConfigVersion) @@ -158,6 +158,11 @@ func csmForPowerFlex(customCSMName string) csmv1.ContainerStorageModule { // Add driver common image res.Spec.Driver.Common.Image = "driverimage" + // minimal manifests will not have a common section + if customCSMName == "no-common-section" { + res.Spec.Driver.Common = nil + } + return res } diff --git a/pkg/drivers/commonconfig_test.go b/pkg/drivers/commonconfig_test.go index 6e85ce50..acf3bde8 100644 --- a/pkg/drivers/commonconfig_test.go +++ b/pkg/drivers/commonconfig_test.go @@ -51,7 +51,8 @@ var ( {"pscale happy path", csm, csmv1.PowerScaleName, "node.yaml", ""}, {"powerscale happy path", pScaleCSM, csmv1.PowerScaleName, "node.yaml", ""}, {"pflex happy path", pFlexCSM, csmv1.PowerFlex, "node.yaml", ""}, - {"pflex no-sdc path", csmForPowerFlex("no-sdc"), csmv1.PowerFlex, "node.yaml", ""}, + {"pflex no-sdc path", csmForPowerFlex("no-common-section"), csmv1.PowerFlex, "node.yaml", ""}, + {"pflex with no common section", csmForPowerFlex("no-sdc"), csmv1.PowerFlex, "node.yaml", ""}, {"pstore happy path", pStoreCSM, csmv1.PowerStore, "node.yaml", ""}, {"unity happy path", unityCSM, csmv1.Unity, "node.yaml", ""}, {"unity happy path when secrets with certificates provided", unityCSMCertProvided, csmv1.Unity, "node.yaml", ""}, From 7a6f867d2ff67384504107ab7c8e936571227046 Mon Sep 17 00:00:00 2001 From: JacobGros Date: Fri, 10 Jan 2025 17:45:15 -0500 Subject: [PATCH 6/6] fix unit tests --- pkg/drivers/commonconfig_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/drivers/commonconfig_test.go b/pkg/drivers/commonconfig_test.go index acf3bde8..8e5b19b5 100644 --- a/pkg/drivers/commonconfig_test.go +++ b/pkg/drivers/commonconfig_test.go @@ -51,8 +51,8 @@ var ( {"pscale happy path", csm, csmv1.PowerScaleName, "node.yaml", ""}, {"powerscale happy path", pScaleCSM, csmv1.PowerScaleName, "node.yaml", ""}, {"pflex happy path", pFlexCSM, csmv1.PowerFlex, "node.yaml", ""}, - {"pflex no-sdc path", csmForPowerFlex("no-common-section"), csmv1.PowerFlex, "node.yaml", ""}, - {"pflex with no common section", csmForPowerFlex("no-sdc"), csmv1.PowerFlex, "node.yaml", ""}, + {"pflex no-sdc path", csmForPowerFlex("no-sdc"), csmv1.PowerFlex, "node.yaml", ""}, + {"pflex with no common section", csmForPowerFlex("no-common-section"), csmv1.PowerFlex, "node.yaml", ""}, {"pstore happy path", pStoreCSM, csmv1.PowerStore, "node.yaml", ""}, {"unity happy path", unityCSM, csmv1.Unity, "node.yaml", ""}, {"unity happy path when secrets with certificates provided", unityCSMCertProvided, csmv1.Unity, "node.yaml", ""}, @@ -143,7 +143,10 @@ func TestGetNode(t *testing.T) { for i := range initcontainers { if *initcontainers[i].Name == "mdm-container" { foundInitMdm = true - assert.Equal(t, string(tt.csm.Spec.Driver.Common.Image), *initcontainers[i].Image) + // if min manifest test case, there will be no common section + if tt.name != "pflex with no common section" { + assert.Equal(t, string(tt.csm.Spec.Driver.Common.Image), *initcontainers[i].Image) + } } } // if driver is powerflex, then check that mdm-container is present