diff --git a/pkg/controller/volume/expand/expand_controller_test.go b/pkg/controller/volume/expand/expand_controller_test.go index a1297278645..38ac353dac2 100644 --- a/pkg/controller/volume/expand/expand_controller_test.go +++ b/pkg/controller/volume/expand/expand_controller_test.go @@ -33,12 +33,10 @@ import ( utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/client-go/informers" coretesting "k8s.io/client-go/testing" - featuregatetesting "k8s.io/component-base/featuregate/testing" csitrans "k8s.io/csi-translation-lib" csitranslationplugins "k8s.io/csi-translation-lib/plugins" "k8s.io/kubernetes/pkg/controller" controllervolumetesting "k8s.io/kubernetes/pkg/controller/volume/attachdetach/testing" - "k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume/awsebs" "k8s.io/kubernetes/pkg/volume/csimigration" @@ -49,14 +47,13 @@ import ( func TestSyncHandler(t *testing.T) { tests := []struct { - name string - csiMigrationEnabled bool - pvcKey string - pv *v1.PersistentVolume - pvc *v1.PersistentVolumeClaim - expansionCalled bool - hasError bool - expectedAnnotation map[string]string + name string + pvcKey string + pv *v1.PersistentVolume + pvc *v1.PersistentVolumeClaim + expansionCalled bool + hasError bool + expectedAnnotation map[string]string }{ { name: "when pvc has no PV binding", @@ -69,8 +66,8 @@ func TestSyncHandler(t *testing.T) { pv: getFakePersistentVolume("vol-3", csitranslationplugins.AWSEBSInTreePluginName, "1Gi", "good-pvc-vol-3"), pvc: getFakePersistentVolumeClaim("good-pvc", "vol-3", "1Gi", "2Gi", "good-pvc-vol-3"), pvcKey: "default/good-pvc", - expansionCalled: true, - expectedAnnotation: map[string]string{volumetypes.VolumeResizerKey: csitranslationplugins.AWSEBSInTreePluginName}, + expansionCalled: false, + expectedAnnotation: map[string]string{volumetypes.VolumeResizerKey: csitranslationplugins.AWSEBSDriverName}, }, { name: "if pv has pre-resize capacity annotation, generate expand operation should not be called", @@ -84,14 +81,6 @@ func TestSyncHandler(t *testing.T) { pvcKey: "default/good-pvc", expansionCalled: false, }, - { - name: "when csi migration is enabled for a in-tree plugin", - csiMigrationEnabled: true, - pv: getFakePersistentVolume("vol-4", csitranslationplugins.AWSEBSInTreePluginName, "1Gi", "csi-pvc-vol-5"), - pvc: getFakePersistentVolumeClaim("csi-pvc", "vol-4", "1Gi", "2Gi", "csi-pvc-vol-5"), - pvcKey: "default/csi-pvc", - expectedAnnotation: map[string]string{volumetypes.VolumeResizerKey: csitranslationplugins.AWSEBSDriverName}, - }, { name: "for csi plugin without migration path", pv: getFakePersistentVolume("vol-5", "com.csi.ceph", "1Gi", "ceph-csi-pvc-vol-6"), @@ -125,12 +114,6 @@ func TestSyncHandler(t *testing.T) { t.Fatalf("error creating expand controller : %v", err) } - if test.csiMigrationEnabled { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIMigrationAWS, true)() - } else { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIMigrationAWS, false)() - } - var expController *expandController expController, _ = expc.(*expandController) var expansionCalled bool diff --git a/pkg/scheduler/framework/plugins/nodevolumelimits/csi_test.go b/pkg/scheduler/framework/plugins/nodevolumelimits/csi_test.go index 97ef1849748..420493394a5 100644 --- a/pkg/scheduler/framework/plugins/nodevolumelimits/csi_test.go +++ b/pkg/scheduler/framework/plugins/nodevolumelimits/csi_test.go @@ -29,11 +29,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/rand" "k8s.io/apimachinery/pkg/util/sets" - utilfeature "k8s.io/apiserver/pkg/util/feature" - featuregatetesting "k8s.io/component-base/featuregate/testing" csitrans "k8s.io/csi-translation-lib" csilibplugins "k8s.io/csi-translation-lib/plugins" - "k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/scheduler/framework" fakeframework "k8s.io/kubernetes/pkg/scheduler/framework/fake" st "k8s.io/kubernetes/pkg/scheduler/testing" @@ -318,16 +315,6 @@ func TestCSILimits(t *testing.T) { test: "should count unbound in-tree volumes if migration is enabled", wantStatus: framework.NewStatus(framework.Unschedulable, ErrReasonMaxVolumeCountExceeded), }, - { - newPod: inTreeOneVolPod, - existingPods: []*v1.Pod{inTreeTwoVolPod}, - filterName: "csi", - maxVols: 2, - driverNames: []string{csilibplugins.AWSEBSInTreePluginName, ebsCSIDriverName}, - migrationEnabled: false, - limitSource: "csinode", - test: "should not count in-tree volume if migration is disabled", - }, { newPod: inTreeOneVolPod, existingPods: []*v1.Pod{inTreeTwoVolPod}, @@ -338,16 +325,6 @@ func TestCSILimits(t *testing.T) { limitSource: "csinode-with-no-limit", test: "should not limit pod if volume used does not report limits", }, - { - newPod: inTreeOneVolPod, - existingPods: []*v1.Pod{inTreeTwoVolPod}, - filterName: "csi", - maxVols: 2, - driverNames: []string{csilibplugins.AWSEBSInTreePluginName, ebsCSIDriverName}, - migrationEnabled: false, - limitSource: "csinode-with-no-limit", - test: "should not limit in-tree pod if migration is disabled", - }, { newPod: inTreeNonMigratableOneVolPod, existingPods: []*v1.Pod{csiEBSTwoVolPod}, @@ -413,36 +390,6 @@ func TestCSILimits(t *testing.T) { test: "should count in-tree and csi volumes if migration is enabled (when scheduling csi volumes)", wantStatus: framework.NewStatus(framework.Unschedulable, ErrReasonMaxVolumeCountExceeded), }, - { - newPod: csiEBSOneVolPod, - existingPods: []*v1.Pod{csiEBSTwoVolPod, inTreeTwoVolPod}, - filterName: "csi", - maxVols: 3, - driverNames: []string{csilibplugins.AWSEBSInTreePluginName, ebsCSIDriverName}, - migrationEnabled: false, - limitSource: "csinode", - test: "should not count in-tree and count csi volumes if migration is disabled (when scheduling csi volumes)", - }, - { - newPod: csiEBSOneVolPod, - existingPods: []*v1.Pod{csiEBSTwoVolPod, inTreeTwoVolPod, inTreeInlineVolPod}, - filterName: "csi", - maxVols: 3, - driverNames: []string{csilibplugins.AWSEBSInTreePluginName, ebsCSIDriverName}, - migrationEnabled: false, - limitSource: "csinode", - test: "should not count in-tree, inline; should count csi volumes if migration is disabled (when scheduling csi volumes)", - }, - { - newPod: inTreeOneVolPod, - existingPods: []*v1.Pod{csiEBSTwoVolPod}, - filterName: "csi", - maxVols: 2, - driverNames: []string{csilibplugins.AWSEBSInTreePluginName, ebsCSIDriverName}, - migrationEnabled: false, - limitSource: "csinode", - test: "should not count in-tree and count csi volumes if migration is disabled (when scheduling in-tree volumes)", - }, // ephemeral volumes { newPod: ephemeralVolumePod, @@ -533,11 +480,8 @@ func TestCSILimits(t *testing.T) { for _, test := range tests { t.Run(test.test, func(t *testing.T) { node, csiNode := getNodeWithPodAndVolumeLimits(test.limitSource, test.existingPods, int64(test.maxVols), test.driverNames...) - if test.migrationEnabled { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIMigrationAWS, true)() + if csiNode != nil { enableMigrationOnNode(csiNode, csilibplugins.AWSEBSInTreePluginName) - } else { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIMigrationAWS, false)() } csiTranslator := csitrans.New() p := &CSILimits{ diff --git a/pkg/volume/csimigration/plugin_manager_test.go b/pkg/volume/csimigration/plugin_manager_test.go index 3cef7595d54..9467a497b2c 100644 --- a/pkg/volume/csimigration/plugin_manager_test.go +++ b/pkg/volume/csimigration/plugin_manager_test.go @@ -101,27 +101,6 @@ func TestIsMigratable(t *testing.T) { }, }, }, - { - name: "AWS EBS PV with CSIMigration and CSIMigrationAWS disabled", - pluginFeature: features.CSIMigrationAWS, - pluginFeatureEnabled: false, - isMigratable: false, - csiMigrationEnabled: false, - spec: &volume.Spec{ - PersistentVolume: &v1.PersistentVolume{ - Spec: v1.PersistentVolumeSpec{ - PersistentVolumeSource: v1.PersistentVolumeSource{ - AWSElasticBlockStore: &v1.AWSElasticBlockStoreVolumeSource{ - VolumeID: "vol01", - FSType: "ext3", - Partition: 1, - ReadOnly: true, - }, - }, - }, - }, - }, - }, } csiTranslator := csitrans.New() for _, test := range testCases { @@ -251,28 +230,6 @@ func TestMigrationFeatureFlagStatus(t *testing.T) { csiMigrationResult: true, csiMigrationCompleteResult: true, }, - { - name: "aws-ebs migration flag disabled and migration-complete flag disabled with CSI migration flag disabled", - pluginName: "kubernetes.io/aws-ebs", - pluginFeature: features.CSIMigrationAWS, - pluginFeatureEnabled: false, - csiMigrationEnabled: false, - inTreePluginUnregister: features.InTreePluginAWSUnregister, - inTreePluginUnregisterEnabled: false, - csiMigrationResult: false, - csiMigrationCompleteResult: false, - }, - { - name: "aws-ebs migration flag disabled and migration-complete flag disabled with CSI migration flag enabled", - pluginName: "kubernetes.io/aws-ebs", - pluginFeature: features.CSIMigrationAWS, - pluginFeatureEnabled: false, - csiMigrationEnabled: true, - inTreePluginUnregister: features.InTreePluginAWSUnregister, - inTreePluginUnregisterEnabled: false, - csiMigrationResult: false, - csiMigrationCompleteResult: false, - }, { name: "aws-ebs migration flag enabled and migration-complete flag disabled with CSI migration flag enabled", pluginName: "kubernetes.io/aws-ebs",