From d50f0ae0576d526dd837798692d2b3cf27152da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Mon, 25 Nov 2024 19:43:17 +0800 Subject: [PATCH] remove deadcode --- pkg/modifycontroller/controller.go | 19 ------------------- pkg/modifycontroller/controller_test.go | 5 ++++- pkg/resizer/csi_resizer.go | 8 -------- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/pkg/modifycontroller/controller.go b/pkg/modifycontroller/controller.go index cae14c14e..4ee6e0646 100644 --- a/pkg/modifycontroller/controller.go +++ b/pkg/modifycontroller/controller.go @@ -179,25 +179,6 @@ func (ctrl *modifyController) deletePVC(obj interface{}) { ctrl.claimQueue.Forget(objKey) } -// modifyPVC modifies the PVC and PV based on VAC -func (ctrl *modifyController) modifyPVC(pvc *v1.PersistentVolumeClaim, pv *v1.PersistentVolume) error { - var err error - if isFirstTimeModifyVolumeWithPVC(pvc, pv) { - // If it is first time adding a vac, always validate and then call modify volume - _, _, err, _ = ctrl.validateVACAndModifyVolumeWithTarget(pvc, pv) - } else { - _, _, err, _ = ctrl.modify(pvc, pv) - } - return err -} - -func isFirstTimeModifyVolumeWithPVC(pvc *v1.PersistentVolumeClaim, pv *v1.PersistentVolume) bool { - if pv.Spec.VolumeAttributesClassName == nil && pvc.Spec.VolumeAttributesClassName != nil { - return true - } - return false -} - func (ctrl *modifyController) init(ctx context.Context) bool { informersSyncd := []cache.InformerSynced{ctrl.pvListerSynced, ctrl.pvcListerSynced} informersSyncd = append(informersSyncd, ctrl.vacListerSynced) diff --git a/pkg/modifycontroller/controller_test.go b/pkg/modifycontroller/controller_test.go index ce9e95188..ccf43abde 100644 --- a/pkg/modifycontroller/controller_test.go +++ b/pkg/modifycontroller/controller_test.go @@ -111,7 +111,10 @@ func TestController(t *testing.T) { } } time.Sleep(time.Second * 2) - err = ctrlInstance.modifyPVC(test.pvc, test.pv) + _, _, err, _ = ctrlInstance.modify(test.pvc, test.pv) + if err != nil { + t.Fatalf("for %s: unexpected error: %v", test.name, err) + } modifyCallCount := client.GetModifyCount() if test.callCSIModify && modifyCallCount == 0 { diff --git a/pkg/resizer/csi_resizer.go b/pkg/resizer/csi_resizer.go index 569fd054b..6ea272b32 100644 --- a/pkg/resizer/csi_resizer.go +++ b/pkg/resizer/csi_resizer.go @@ -281,11 +281,3 @@ func getCredentials(k8sClient kubernetes.Interface, ref *v1.SecretReference) (ma } return credentials, nil } - -func uniqueAccessModes(pvSpec v1.PersistentVolumeSpec) map[v1.PersistentVolumeAccessMode]bool { - m := map[v1.PersistentVolumeAccessMode]bool{} - for _, mode := range pvSpec.AccessModes { - m[mode] = true - } - return m -}