From e05d79e82b35206c80931c0468b222bc4529fc9a Mon Sep 17 00:00:00 2001 From: shubham Date: Fri, 27 Dec 2019 11:37:52 +0530 Subject: [PATCH] fix scopelint issue and add priorityclass Signed-off-by: shubham --- pkg/cstor/migrate/cspc_generator.go | 4 ++-- pkg/cstor/migrate/pool.go | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pkg/cstor/migrate/cspc_generator.go b/pkg/cstor/migrate/cspc_generator.go index 783bb65d6f..feb975c5c2 100644 --- a/pkg/cstor/migrate/cspc_generator.go +++ b/pkg/cstor/migrate/cspc_generator.go @@ -64,7 +64,7 @@ func getCSPCSpecForSPC(spc *apis.StoragePoolClaim, openebsNamespace string) (*ap cspcObj := &apis.CStorPoolCluster{} cspcObj.Name = spc.Name cspcObj.Annotations = map[string]string{ - // This label will be used to disable reconciliation on the dependants + // This label will be used to disable reconciliation on the dependants. // In this case that will be CSPI string(apis.OpenEBSDisableDependantsReconcileKey): "true", } @@ -95,8 +95,8 @@ func getCSPCSpecForSPC(spc *apis.StoragePoolClaim, openebsNamespace string) (*ap OverProvisioning: cspObj.Spec.PoolSpec.OverProvisioning, Resources: getCSPResources(cspDeployList.Items[0]), Tolerations: cspDeployList.Items[0].Spec.Template.Spec.Tolerations, + PriorityClassName: cspDeployList.Items[0].Spec.Template.Spec.PriorityClassName, // AuxResources: getCSPAuxResources(cspDeployList.Items[0]), - // PriorityClassName: cspDeployList.Items[0].Spec.Template.Spec.PriorityClassName, }, } // if the csp does not have a cachefile then add cachefile diff --git a/pkg/cstor/migrate/pool.go b/pkg/cstor/migrate/pool.go index 7cf1022348..f60112ed50 100644 --- a/pkg/cstor/migrate/pool.go +++ b/pkg/cstor/migrate/pool.go @@ -295,7 +295,9 @@ func updateBDCLabels(cspcName, openebsNamespace string) error { if err != nil { return err } - for _, bdcObj := range bdcList.Items { + for _, bdcItem := range bdcList.Items { + bdcItem := bdcItem // pin it + bdcObj := &bdcItem klog.Infof("Updating bdc %s with cspc labels & finalizer.", bdcObj.Name) delete(bdcObj.Labels, string(apis.StoragePoolClaimCPK)) bdcObj.Labels[string(apis.CStorPoolClusterCPK)] = cspcName @@ -308,7 +310,7 @@ func updateBDCLabels(cspcName, openebsNamespace string) error { // bdcObj.OwnerReferences[0].UID = cspcObj.UID _, err := bdc.NewKubeClient(). WithNamespace(openebsNamespace). - Update(&bdcObj) + Update(bdcObj) if err != nil { return errors.Wrapf(err, "failed to update bdc %s with cspc label & finalizer", bdcObj.Name) } @@ -325,13 +327,15 @@ func updateBDCOwnerRef(cspcObj *apis.CStorPoolCluster, openebsNamespace string) if err != nil { return err } - for _, bdcObj := range bdcList.Items { + for _, bdcItem := range bdcList.Items { + bdcItem := bdcItem // pin it + bdcObj := &bdcItem klog.Infof("Updating bdc %s with cspc ownerRef.", bdcObj.Name) bdcObj.OwnerReferences[0].Kind = "CStorPoolCluster" bdcObj.OwnerReferences[0].UID = cspcObj.UID _, err := bdc.NewKubeClient(). WithNamespace(openebsNamespace). - Update(&bdcObj) + Update(bdcObj) if err != nil { return errors.Wrapf(err, "failed to update bdc %s with cspc onwerRef", bdcObj.Name) } @@ -349,7 +353,9 @@ func updateCVRsLabels(cspName, openebsNamespace string, cspiObj *apis.CStorPoolI if err != nil { return err } - for _, cvrObj := range cvrList.Items { + for _, cvrItem := range cvrList.Items { + cvrItem := cvrItem // pin it + cvrObj := &cvrItem klog.Infof("Updating cvr %s with cspi %s info.", cvrObj.Name, cspiObj.Name) delete(cvrObj.Labels, cspNameLabel) delete(cvrObj.Labels, cspUIDLabel) @@ -358,7 +364,7 @@ func updateCVRsLabels(cspName, openebsNamespace string, cspiObj *apis.CStorPoolI delete(cvrObj.Annotations, cspHostnameAnnotation) cvrObj.Annotations[cspiHostnameAnnotation] = cspiObj.Spec.HostName _, err = cvr.NewKubeclient().WithNamespace(openebsNamespace). - Update(&cvrObj) + Update(cvrObj) if err != nil { return errors.Wrapf(err, "failed to update cvr %s with cspc info", cvrObj.Name) }