From 22505f5f9268e410fd5d8938fe326e3e01e04605 Mon Sep 17 00:00:00 2001 From: abhi16394 Date: Mon, 21 Feb 2022 17:22:00 -0500 Subject: [PATCH 1/8] Adding unit-test for resources --- controllers/csm_controller_test.go | 270 ++++++++++++++++++ .../powerscale/v2.1.0/csidriver.yaml | 2 +- .../powerscale/v2.1.0/csidriver.yaml | 11 + 3 files changed, 282 insertions(+), 1 deletion(-) diff --git a/controllers/csm_controller_test.go b/controllers/csm_controller_test.go index c514c0599..ab3085d4f 100644 --- a/controllers/csm_controller_test.go +++ b/controllers/csm_controller_test.go @@ -2,6 +2,7 @@ package controllers import ( "context" + "errors" "fmt" "path/filepath" "strings" @@ -16,6 +17,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + rbacv1 "k8s.io/api/rbac/v1" + storagev1 "k8s.io/api/storage/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" @@ -33,6 +37,21 @@ var ( } unittestLogger = zap.New(zap.UseFlagOptions(&opts)).WithName("controllers").WithName("unit-test") + createCMError bool + getCMError bool + updateCMError bool + createCSIError bool + getCSIError bool + updateCSIError bool + getCRError bool + updateCRError bool + createCRError bool + getCRBError bool + updateCRBError bool + createCRBError bool + createSAError bool + getSAError bool + updateSAError bool ) // CSMContrllerTestSuite implements testify suite @@ -65,6 +84,11 @@ func (suite *CSMControllerTestSuite) SetupTest() { func (suite *CSMControllerTestSuite) TestReconcile() { suite.makeFakeCSM("csm", suite.namespace) suite.runFakeCSMManager("csm", suite.namespace) + suite.runFakeConfigManager("csm", suite.namespace) + //suite.runFakeCsiManager("csm", suite.namespace) + suite.runFakeClusterroleManager("csm", suite.namespace) + suite.runFakeClusterrolebindingManager("csm", suite.namespace) + suite.runFakeServiceaccountManager("csm", suite.namespace) } // helper method to create and run reconciler @@ -127,6 +151,184 @@ func (suite *CSMControllerTestSuite) runFakeCSMManager(reqName, expectedErr stri // in unit test listener does not get triggered suite.handleDaemonsetTest(reconciler, "csm-node") suite.handleDeploymentTest(reconciler, "csm-controller") + + res, err = reconciler.Reconcile(context.Background(), req) + res, err = reconciler.Reconcile(context.Background(), req) +} + +func (suite *CSMControllerTestSuite) runFakeConfigManager(reqName, expectedErr string) { + reconciler := suite.createReconciler() + + req := reconcile.Request{ + NamespacedName: types.NamespacedName{ + Namespace: suite.namespace, + Name: reqName, + }, + } + + // invoke controller Reconcile to test. Typically k8s would call this when resource is changed + res, err := reconciler.Reconcile(context.Background(), req) + + ctrl.Log.Info("reconcile response", "res is: ", res) + + if expectedErr == "" { + assert.NoError(suite.T(), err) + } + + if err != nil { + ctrl.Log.Error(err, "Error returned") + assert.True(suite.T(), strings.Contains(err.Error(), expectedErr)) + } + + getCMError = true + res, err = reconciler.Reconcile(context.Background(), req) + getCMError = false + createCMError = true + res, err = reconciler.Reconcile(context.Background(), req) + createCMError = false + updateCMError = true + res, err = reconciler.Reconcile(context.Background(), req) + updateCMError = false +} + +/*func (suite *CSMControllerTestSuite) runFakeCsiManager(reqName, expectedErr string) { + reconciler := suite.createReconciler() + + req := reconcile.Request{ + NamespacedName: types.NamespacedName{ + Namespace: suite.namespace, + Name: reqName, + }, + } + + // invoke controller Reconcile to test. Typically k8s would call this when resource is changed + res, err := reconciler.Reconcile(context.Background(), req) + + ctrl.Log.Info("reconcile response", "res is: ", res) + + if expectedErr == "" { + assert.NoError(suite.T(), err) + } + + if err != nil { + ctrl.Log.Error(err, "Error returned") + assert.True(suite.T(), strings.Contains(err.Error(), expectedErr)) + } + + getCSIError = true + res, err = reconciler.Reconcile(context.Background(), req) + getCSIError = false + createCSIError = true + res, err = reconciler.Reconcile(context.Background(), req) + createCSIError = false + updateCSIError = true + res, err = reconciler.Reconcile(context.Background(), req) + updateCSIError = false +}*/ + +func (suite *CSMControllerTestSuite) runFakeClusterroleManager(reqName, expectedErr string) { + reconciler := suite.createReconciler() + + req := reconcile.Request{ + NamespacedName: types.NamespacedName{ + Namespace: suite.namespace, + Name: reqName, + }, + } + + // invoke controller Reconcile to test. Typically k8s would call this when resource is changed + res, err := reconciler.Reconcile(context.Background(), req) + + ctrl.Log.Info("reconcile response", "res is: ", res) + + if expectedErr == "" { + assert.NoError(suite.T(), err) + } + + if err != nil { + ctrl.Log.Error(err, "Error returned") + assert.True(suite.T(), strings.Contains(err.Error(), expectedErr)) + } + + getCRError = true + res, err = reconciler.Reconcile(context.Background(), req) + getCRError = false + createCRError = true + res, err = reconciler.Reconcile(context.Background(), req) + createCRError = false + updateCRError = true + res, err = reconciler.Reconcile(context.Background(), req) + updateCRError = false +} + +func (suite *CSMControllerTestSuite) runFakeClusterrolebindingManager(reqName, expectedErr string) { + reconciler := suite.createReconciler() + + req := reconcile.Request{ + NamespacedName: types.NamespacedName{ + Namespace: suite.namespace, + Name: reqName, + }, + } + + // invoke controller Reconcile to test. Typically k8s would call this when resource is changed + res, err := reconciler.Reconcile(context.Background(), req) + + ctrl.Log.Info("reconcile response", "res is: ", res) + + if expectedErr == "" { + assert.NoError(suite.T(), err) + } + + if err != nil { + ctrl.Log.Error(err, "Error returned") + assert.True(suite.T(), strings.Contains(err.Error(), expectedErr)) + } + + getCRBError = true + res, err = reconciler.Reconcile(context.Background(), req) + getCRBError = false + createCRBError = true + res, err = reconciler.Reconcile(context.Background(), req) + createCRBError = false + updateCRBError = true + res, err = reconciler.Reconcile(context.Background(), req) + updateCRBError = false +} + +func (suite *CSMControllerTestSuite) runFakeServiceaccountManager(reqName, expectedErr string) { + reconciler := suite.createReconciler() + + req := reconcile.Request{ + NamespacedName: types.NamespacedName{ + Namespace: suite.namespace, + Name: reqName, + }, + } + + // invoke controller Reconcile to test. Typically k8s would call this when resource is changed + res, err := reconciler.Reconcile(context.Background(), req) + + ctrl.Log.Info("reconcile response", "res is: ", res) + + if expectedErr == "" { + assert.NoError(suite.T(), err) + } + + if err != nil { + ctrl.Log.Error(err, "Error returned") + assert.True(suite.T(), strings.Contains(err.Error(), expectedErr)) + } + + getSAError = true + res, err = reconciler.Reconcile(context.Background(), req) + getSAError = false + createSAError = true + res, err = reconciler.Reconcile(context.Background(), req) + createSAError = false + updateSAError = true + res, err = reconciler.Reconcile(context.Background(), req) + updateSAError = false } func (suite *CSMControllerTestSuite) handleDaemonsetTest(r *ContainerStorageModuleReconciler, name string) { @@ -165,6 +367,74 @@ func (suite *CSMControllerTestSuite) makeFakeCSM(name, ns string) { func (suite *CSMControllerTestSuite) ShouldFail(method string, obj runtime.Object) error { // Needs to implement based on need + switch v := obj.(type) { + case *corev1.ConfigMap: + cm := obj.(*corev1.ConfigMap) + if method == "Create" && createCMError { + fmt.Printf("[ShouldFail] force Configmap error for configmap named %+v\n", cm.Name) + fmt.Printf("[ShouldFail] force Configmap error for obj of type %+v\n", v) + return errors.New("unable to create ConfigMap") + } else if method == "Update" && updateCMError { + fmt.Printf("[ShouldFail] force update configmap error for obj of type %+v\n", v) + return errors.New("unable to update ConfigMap") + } else if method == "Get" && getCMError { + fmt.Printf("[ShouldFail] force get configmap error for obj of type %+v\n", v) + return errors.New("unable to get ConfigMap") + } + case *storagev1.CSIDriver: + csi := obj.(*storagev1.CSIDriver) + if method == "Create" && createCSIError { + fmt.Printf("[ShouldFail] force Csidriver error for csidriver named %+v\n", csi.Name) + fmt.Printf("[ShouldFail] force Csidriver error for obj of type %+v\n", v) + return errors.New("unable to create Csidriver") + } else if method == "Update" && updateCSIError { + fmt.Printf("[ShouldFail] force update Csidriver error for obj of type %+v\n", v) + return errors.New("unable to update Csidriver") + } else if method == "Get" && getCSIError { + fmt.Printf("[ShouldFail] force get Csidriver error for obj of type %+v\n", v) + return errors.New("unable to get Csidriver") + } + case *rbacv1.ClusterRole: + cr := obj.(*rbacv1.ClusterRole) + if method == "Create" && createCRError { + fmt.Printf("[ShouldFail] force ClusterRole error for ClusterRole named %+v\n", cr.Name) + fmt.Printf("[ShouldFail] force ClusterRole error for obj of type %+v\n", v) + return errors.New("unable to create ClusterRole") + } else if method == "Update" && updateCRError { + fmt.Printf("[ShouldFail] force update ClusterRole error for obj of type %+v\n", v) + return errors.New("unable to update ClusterRole") + } else if method == "Get" && getCRError { + fmt.Printf("[ShouldFail] force get ClusterRole error for obj of type %+v\n", v) + return errors.New("unable to get ClusterRole") + } + case *rbacv1.ClusterRoleBinding: + crb := obj.(*rbacv1.ClusterRoleBinding) + if method == "Create" && createCRBError { + fmt.Printf("[ShouldFail] force ClusterRoleBinding error for ClusterRoleBinding named %+v\n", crb.Name) + fmt.Printf("[ShouldFail] force ClusterRoleBinding error for obj of type %+v\n", v) + return errors.New("unable to create ClusterRoleBinding") + } else if method == "Update" && updateCRBError { + fmt.Printf("[ShouldFail] force update ClusterRoleBinding error for obj of type %+v\n", v) + return errors.New("unable to update ClusterRoleBinding") + } else if method == "Get" && getCRBError { + fmt.Printf("[ShouldFail] force get ClusterRoleBinding error for obj of type %+v\n", v) + return errors.New("unable to get ClusterRoleBinding") + } + case *corev1.ServiceAccount: + sa := obj.(*corev1.ServiceAccount) + if method == "Create" && createSAError { + fmt.Printf("[ShouldFail] force ServiceAccount error for ServiceAccount named %+v\n", sa.Name) + fmt.Printf("[ShouldFail] force ServiceAccount error for obj of type %+v\n", v) + return errors.New("unable to create ServiceAccount") + } else if method == "Update" && updateSAError { + fmt.Printf("[ShouldFail] force update ServiceAccount error for obj of type %+v\n", v) + return errors.New("unable to update ServiceAccount") + } else if method == "Get" && getSAError { + fmt.Printf("[ShouldFail] force get ServiceAccount error for obj of type %+v\n", v) + return errors.New("unable to get ServiceAccount") + } + default: + } return nil } diff --git a/operatorconfig/driverconfig/powerscale/v2.1.0/csidriver.yaml b/operatorconfig/driverconfig/powerscale/v2.1.0/csidriver.yaml index 3e3d8a732..fec9264ff 100644 --- a/operatorconfig/driverconfig/powerscale/v2.1.0/csidriver.yaml +++ b/operatorconfig/driverconfig/powerscale/v2.1.0/csidriver.yaml @@ -1,4 +1,4 @@ -apiVersion: storage.k8s.io/v1beta1 +apiVersion: storage.k8s.io/v1 kind: CSIDriver metadata: name: csi-isilon.dellemc.com diff --git a/tests/config/driverconfig/powerscale/v2.1.0/csidriver.yaml b/tests/config/driverconfig/powerscale/v2.1.0/csidriver.yaml index e69de29bb..b1a3c7261 100644 --- a/tests/config/driverconfig/powerscale/v2.1.0/csidriver.yaml +++ b/tests/config/driverconfig/powerscale/v2.1.0/csidriver.yaml @@ -0,0 +1,11 @@ +apiVersion: storage.k8s.io/v1 +kind: CSIDriver +metadata: + name: csi-isilon.dellemc.com + +spec: + attachRequired: true + podInfoOnMount: true + volumeLifecycleModes: + - Persistent + - Ephemeral \ No newline at end of file From 08c06b26254c68675e84b02b15d4f75ae8643a3c Mon Sep 17 00:00:00 2001 From: abhi16394 Date: Tue, 22 Feb 2022 22:44:50 -0500 Subject: [PATCH 2/8] Addig csidriver tests --- controllers/csm_controller_test.go | 6 +++--- tests/config/driverconfig/powerscale/v2.1.0/csidriver.yaml | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/controllers/csm_controller_test.go b/controllers/csm_controller_test.go index ab3085d4f..4a30fdcc0 100644 --- a/controllers/csm_controller_test.go +++ b/controllers/csm_controller_test.go @@ -85,7 +85,7 @@ func (suite *CSMControllerTestSuite) TestReconcile() { suite.makeFakeCSM("csm", suite.namespace) suite.runFakeCSMManager("csm", suite.namespace) suite.runFakeConfigManager("csm", suite.namespace) - //suite.runFakeCsiManager("csm", suite.namespace) + suite.runFakeCsiManager("csm", suite.namespace) suite.runFakeClusterroleManager("csm", suite.namespace) suite.runFakeClusterrolebindingManager("csm", suite.namespace) suite.runFakeServiceaccountManager("csm", suite.namespace) @@ -191,7 +191,7 @@ func (suite *CSMControllerTestSuite) runFakeConfigManager(reqName, expectedErr s updateCMError = false } -/*func (suite *CSMControllerTestSuite) runFakeCsiManager(reqName, expectedErr string) { +func (suite *CSMControllerTestSuite) runFakeCsiManager(reqName, expectedErr string) { reconciler := suite.createReconciler() req := reconcile.Request{ @@ -224,7 +224,7 @@ func (suite *CSMControllerTestSuite) runFakeConfigManager(reqName, expectedErr s updateCSIError = true res, err = reconciler.Reconcile(context.Background(), req) updateCSIError = false -}*/ +} func (suite *CSMControllerTestSuite) runFakeClusterroleManager(reqName, expectedErr string) { reconciler := suite.createReconciler() diff --git a/tests/config/driverconfig/powerscale/v2.1.0/csidriver.yaml b/tests/config/driverconfig/powerscale/v2.1.0/csidriver.yaml index b1a3c7261..2c313236c 100644 --- a/tests/config/driverconfig/powerscale/v2.1.0/csidriver.yaml +++ b/tests/config/driverconfig/powerscale/v2.1.0/csidriver.yaml @@ -2,10 +2,13 @@ apiVersion: storage.k8s.io/v1 kind: CSIDriver metadata: name: csi-isilon.dellemc.com - + ownerReferences: + - apiVersion: cache.example.com/v1alpha1 + kind: Memcached + name: example-memcached spec: attachRequired: true - podInfoOnMount: true + podInfoOnMount: trues volumeLifecycleModes: - Persistent - Ephemeral \ No newline at end of file From 379294a328d97426c5c8e0d10686c5a3191ecad7 Mon Sep 17 00:00:00 2001 From: abhi16394 <32352976+abhi16394@users.noreply.github.com> Date: Tue, 22 Feb 2022 23:30:07 -0500 Subject: [PATCH 3/8] Adding status column --- api/v1alpha1/csm_types.go | 1 + 1 file changed, 1 insertion(+) diff --git a/api/v1alpha1/csm_types.go b/api/v1alpha1/csm_types.go index dbb529fdb..84c16cd7c 100644 --- a/api/v1alpha1/csm_types.go +++ b/api/v1alpha1/csm_types.go @@ -52,6 +52,7 @@ type ContainerStorageModuleStatus struct { // +kubebuilder:printcolumn:name="CreationTime",type=date,JSONPath=`.metadata.creationTimestamp` // +kubebuilder:printcolumn:name="CSIDriverType",type=string,JSONPath=`.spec.driver.csiDriverType`,description="Type of CSIDriver" // +kubebuilder:printcolumn:name="ConfigVersion",type=string,JSONPath=`.spec.driver.configVersion`,description="Version of CSIDriver" +// +kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state`,description="State of Installation" //+kubebuilder:object:root=true //+kubebuilder:subresource:status From d54aa3350e84c54ae40a566c91d809b33e35d6df Mon Sep 17 00:00:00 2001 From: abhi16394 Date: Tue, 22 Feb 2022 23:36:23 -0500 Subject: [PATCH 4/8] Adding status column --- api/v1alpha1/csm_types.go | 1 + ...rage.dell.com_containerstoragemodules.yaml | 4 ++++ ...rage.dell.com_containerstoragemodules.yaml | 21 ++++++++++++------- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/api/v1alpha1/csm_types.go b/api/v1alpha1/csm_types.go index dbb529fdb..84c16cd7c 100644 --- a/api/v1alpha1/csm_types.go +++ b/api/v1alpha1/csm_types.go @@ -52,6 +52,7 @@ type ContainerStorageModuleStatus struct { // +kubebuilder:printcolumn:name="CreationTime",type=date,JSONPath=`.metadata.creationTimestamp` // +kubebuilder:printcolumn:name="CSIDriverType",type=string,JSONPath=`.spec.driver.csiDriverType`,description="Type of CSIDriver" // +kubebuilder:printcolumn:name="ConfigVersion",type=string,JSONPath=`.spec.driver.configVersion`,description="Version of CSIDriver" +// +kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state`,description="State of Installation" //+kubebuilder:object:root=true //+kubebuilder:subresource:status diff --git a/config/crd/bases/storage.dell.com_containerstoragemodules.yaml b/config/crd/bases/storage.dell.com_containerstoragemodules.yaml index e131fd376..28d5d810f 100644 --- a/config/crd/bases/storage.dell.com_containerstoragemodules.yaml +++ b/config/crd/bases/storage.dell.com_containerstoragemodules.yaml @@ -30,6 +30,10 @@ spec: jsonPath: .spec.driver.configVersion name: ConfigVersion type: string + - description: State of Installation + jsonPath: .status.state + name: State + type: string name: v1alpha1 schema: openAPIV3Schema: diff --git a/deploy/crds/storage.dell.com_containerstoragemodules.yaml b/deploy/crds/storage.dell.com_containerstoragemodules.yaml index cc49e9c4e..82b85d45e 100644 --- a/deploy/crds/storage.dell.com_containerstoragemodules.yaml +++ b/deploy/crds/storage.dell.com_containerstoragemodules.yaml @@ -26,7 +26,11 @@ spec: type: string - description: Version of CSIDriver jsonPath: .spec.driver.configVersion - name: CONFIGVERSION + name: ConfigVersion + type: string + - description: State of Installation + jsonPath: .status.state + name: State type: string name: v1alpha1 schema: @@ -70,7 +74,7 @@ spec: description: Name of the environment variable. Must be a C_IDENTIFIER. type: string value: - description: 'Variable references $(VAR_NAME) are expanded using the previously defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' + description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' type: string valueFrom: description: Source for the environment variable's value. Cannot be used if value is not empty. @@ -202,7 +206,7 @@ spec: description: Name of the environment variable. Must be a C_IDENTIFIER. type: string value: - description: 'Variable references $(VAR_NAME) are expanded using the previously defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' + description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' type: string valueFrom: description: Source for the environment variable's value. Cannot be used if value is not empty. @@ -317,6 +321,9 @@ spec: dnsPolicy: description: DNSPolicy is the dnsPolicy of the daemonset for Node plugin type: string + forceRemoveDriver: + description: ForceRemoveDriver is the boolean flag used to remove driver deployment when CR is deleted + type: boolean forceUpdate: description: ForceUpdate is the boolean flag used to force an update of the driver instance type: boolean @@ -342,7 +349,7 @@ spec: description: Name of the environment variable. Must be a C_IDENTIFIER. type: string value: - description: 'Variable references $(VAR_NAME) are expanded using the previously defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' + description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' type: string valueFrom: description: Source for the environment variable's value. Cannot be used if value is not empty. @@ -472,7 +479,7 @@ spec: description: Name of the environment variable. Must be a C_IDENTIFIER. type: string value: - description: 'Variable references $(VAR_NAME) are expanded using the previously defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' + description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' type: string valueFrom: description: Source for the environment variable's value. Cannot be used if value is not empty. @@ -607,7 +614,7 @@ spec: description: Name of the environment variable. Must be a C_IDENTIFIER. type: string value: - description: 'Variable references $(VAR_NAME) are expanded using the previously defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' + description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' type: string valueFrom: description: Source for the environment variable's value. Cannot be used if value is not empty. @@ -763,7 +770,7 @@ spec: description: Name of the environment variable. Must be a C_IDENTIFIER. type: string value: - description: 'Variable references $(VAR_NAME) are expanded using the previously defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' + description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' type: string valueFrom: description: Source for the environment variable's value. Cannot be used if value is not empty. From d03c28aeabb22368c009a6a2e9cd093333928d07 Mon Sep 17 00:00:00 2001 From: abhi16394 Date: Tue, 22 Feb 2022 23:39:36 -0500 Subject: [PATCH 5/8] fix formatting issue --- controllers/csm_controller_test.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/controllers/csm_controller_test.go b/controllers/csm_controller_test.go index e7b1cf091..9db487c16 100644 --- a/controllers/csm_controller_test.go +++ b/controllers/csm_controller_test.go @@ -53,8 +53,7 @@ var ( createSAError bool getSAError bool updateSAError bool - csmName = "csm" - + csmName = "csm" ) // CSMContrllerTestSuite implements testify suite @@ -91,7 +90,7 @@ func (suite *CSMControllerTestSuite) TestReconcile() { suite.runFakeCsiManager(csmName, suite.namespace) suite.runFakeClusterroleManager(csmName, suite.namespace) suite.runFakeClusterrolebindingManager(csmName, suite.namespace) - suite.runFakeServiceaccountManager(csmName, suite.namespace) + suite.runFakeServiceaccountManager(csmName, suite.namespace) suite.runFakeCSMManager(csmName, suite.namespace, false) suite.deleteCSM(context.Background(), csmName) suite.runFakeCSMManager(csmName, suite.namespace, true) @@ -155,7 +154,7 @@ func (suite *CSMControllerTestSuite) runFakeCSMManager(reqName, expectedErr stri // after reconcile being run, we update deployment and daemonset // then call handleDeployment/DaemonsetUpdate explicitly because // in unit test listener does not get triggered - // If delete, we shouldn't call these methods since reconcile + // If delete, we shouldn't call these methods since reconcile // would return before this if !reconcileDelete { suite.handleDaemonsetTest(reconciler, "csm-node") From 91ea5a2aa930cc459b21942db730243338a483a3 Mon Sep 17 00:00:00 2001 From: abhi16394 Date: Tue, 22 Feb 2022 23:43:51 -0500 Subject: [PATCH 6/8] merge --- ...rage.dell.com_containerstoragemodules.yaml | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/deploy/crds/storage.dell.com_containerstoragemodules.yaml b/deploy/crds/storage.dell.com_containerstoragemodules.yaml index b72e95d11..28d5d810f 100644 --- a/deploy/crds/storage.dell.com_containerstoragemodules.yaml +++ b/deploy/crds/storage.dell.com_containerstoragemodules.yaml @@ -87,9 +87,6 @@ spec: be a C_IDENTIFIER. type: string value: -<<<<<<< HEAD - description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' -======= description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. @@ -99,7 +96,6 @@ spec: Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' ->>>>>>> 379294a328d97426c5c8e0d10686c5a3191ecad7 type: string valueFrom: description: Source for the environment variable's value. @@ -283,9 +279,6 @@ spec: be a C_IDENTIFIER. type: string value: -<<<<<<< HEAD - description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' -======= description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. @@ -295,7 +288,6 @@ spec: Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' ->>>>>>> 379294a328d97426c5c8e0d10686c5a3191ecad7 type: string valueFrom: description: Source for the environment variable's value. @@ -459,12 +451,8 @@ spec: plugin type: string forceRemoveDriver: -<<<<<<< HEAD - description: ForceRemoveDriver is the boolean flag used to remove driver deployment when CR is deleted -======= description: ForceRemoveDriver is the boolean flag used to remove driver deployment when CR is deleted ->>>>>>> 379294a328d97426c5c8e0d10686c5a3191ecad7 type: boolean forceUpdate: description: ForceUpdate is the boolean flag used to force an @@ -496,9 +484,6 @@ spec: be a C_IDENTIFIER. type: string value: -<<<<<<< HEAD - description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' -======= description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment @@ -508,7 +493,6 @@ spec: $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' ->>>>>>> 379294a328d97426c5c8e0d10686c5a3191ecad7 type: string valueFrom: description: Source for the environment variable's @@ -689,9 +673,6 @@ spec: be a C_IDENTIFIER. type: string value: -<<<<<<< HEAD - description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' -======= description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. @@ -701,7 +682,6 @@ spec: Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' ->>>>>>> 379294a328d97426c5c8e0d10686c5a3191ecad7 type: string valueFrom: description: Source for the environment variable's value. @@ -887,9 +867,6 @@ spec: be a C_IDENTIFIER. type: string value: -<<<<<<< HEAD - description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' -======= description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment @@ -899,7 +876,6 @@ spec: $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' ->>>>>>> 379294a328d97426c5c8e0d10686c5a3191ecad7 type: string valueFrom: description: Source for the environment variable's @@ -1109,9 +1085,6 @@ spec: be a C_IDENTIFIER. type: string value: -<<<<<<< HEAD - description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' -======= description: 'Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment @@ -1121,7 +1094,6 @@ spec: $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' ->>>>>>> 379294a328d97426c5c8e0d10686c5a3191ecad7 type: string valueFrom: description: Source for the environment variable's From 26e0d4ec2079dabad7a00bfdda1edc47aa552946 Mon Sep 17 00:00:00 2001 From: abhi16394 Date: Tue, 22 Feb 2022 23:47:05 -0500 Subject: [PATCH 7/8] Fixing unit-test --- .../driverconfig/badDriver/v2.1.0/driver-config-params.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/config/driverconfig/badDriver/v2.1.0/driver-config-params.yaml b/tests/config/driverconfig/badDriver/v2.1.0/driver-config-params.yaml index f90b8b7a7..55d520672 100644 --- a/tests/config/driverconfig/badDriver/v2.1.0/driver-config-params.yaml +++ b/tests/config/driverconfig/badDriver/v2.1.0/driver-config-params.yaml @@ -2,3 +2,4 @@ this snfoiasga is 843*&(*(% invalid YAml + \ No newline at end of file From 8de0d85a006334d71a10b9a2ac7eb5722fda851e Mon Sep 17 00:00:00 2001 From: abhi16394 Date: Wed, 23 Feb 2022 11:18:24 -0500 Subject: [PATCH 8/8] Fix driver-test --- tests/config/driverconfig/powerscale/v2.1.0/csidriver.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/config/driverconfig/powerscale/v2.1.0/csidriver.yaml b/tests/config/driverconfig/powerscale/v2.1.0/csidriver.yaml index 2c313236c..98de3cdad 100644 --- a/tests/config/driverconfig/powerscale/v2.1.0/csidriver.yaml +++ b/tests/config/driverconfig/powerscale/v2.1.0/csidriver.yaml @@ -2,13 +2,13 @@ apiVersion: storage.k8s.io/v1 kind: CSIDriver metadata: name: csi-isilon.dellemc.com - ownerReferences: + ownerReferences: - apiVersion: cache.example.com/v1alpha1 kind: Memcached name: example-memcached spec: attachRequired: true - podInfoOnMount: trues + podInfoOnMount: true volumeLifecycleModes: - Persistent - Ephemeral \ No newline at end of file