From be0e68ba8481c3a7d96ed7e0dfdab2d37b4d6c5c Mon Sep 17 00:00:00 2001 From: carlory Date: Thu, 13 Nov 2025 11:46:20 +0800 Subject: [PATCH] remove featureGate from PluginManager Signed-off-by: carlory --- cmd/kube-controller-manager/app/core.go | 2 +- .../volume/attachdetach/attach_detach_controller.go | 7 ++----- pkg/controller/volume/attachdetach/metrics/metrics_test.go | 5 ++--- .../populator/desired_state_of_world_populator_test.go | 5 ++--- pkg/controller/volume/attachdetach/util/util_test.go | 3 +-- pkg/controller/volume/expand/expand_controller_test.go | 3 +-- .../volume/persistentvolume/pv_controller_base.go | 2 +- .../volume/persistentvolume/pv_controller_test.go | 4 ++-- .../volume/selinuxwarning/selinux_warning_controller.go | 3 +-- .../populator/desired_state_of_world_populator_test.go | 2 +- pkg/kubelet/volumemanager/volume_manager.go | 2 +- pkg/volume/csimigration/plugin_manager.go | 4 +--- 12 files changed, 16 insertions(+), 26 deletions(-) diff --git a/cmd/kube-controller-manager/app/core.go b/cmd/kube-controller-manager/app/core.go index 0d4ad00d60e..abed91a0c76 100644 --- a/cmd/kube-controller-manager/app/core.go +++ b/cmd/kube-controller-manager/app/core.go @@ -423,7 +423,7 @@ func newPersistentVolumeExpanderController(ctx context.Context, controllerContex controllerContext.InformerFactory.Core().V1().PersistentVolumeClaims(), plugins, csiTranslator, - csimigration.NewPluginManager(csiTranslator, utilfeature.DefaultFeatureGate), + csimigration.NewPluginManager(csiTranslator), ) if err != nil { return nil, fmt.Errorf("failed to init volume expand controller: %w", err) diff --git a/pkg/controller/volume/attachdetach/attach_detach_controller.go b/pkg/controller/volume/attachdetach/attach_detach_controller.go index e4e6865418b..bcad81c509c 100644 --- a/pkg/controller/volume/attachdetach/attach_detach_controller.go +++ b/pkg/controller/volume/attachdetach/attach_detach_controller.go @@ -31,7 +31,6 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/wait" - utilfeature "k8s.io/apiserver/pkg/util/feature" coreinformers "k8s.io/client-go/informers/core/v1" storageinformersv1 "k8s.io/client-go/informers/storage/v1" clientset "k8s.io/client-go/kubernetes" @@ -181,7 +180,7 @@ func NewAttachDetachController( csiTranslator := csitrans.New() adc.intreeToCSITranslator = csiTranslator - adc.csiMigratedPluginManager = csimigration.NewPluginManager(csiTranslator, utilfeature.DefaultFeatureGate) + adc.csiMigratedPluginManager = csimigration.NewPluginManager(csiTranslator) adc.desiredStateOfWorldPopulator = populator.NewDesiredStateOfWorldPopulator( timerConfig.DesiredStateOfWorldPopulatorLoopSleepPeriod, @@ -715,9 +714,7 @@ func (adc *attachDetachController) processVolumeAttachments(logger klog.Logger) var plugin volume.AttachableVolumePlugin volumeSpec := volume.NewSpecFromPersistentVolume(pv, false) - // Consult csiMigratedPluginManager first before querying the plugins registered during runtime in volumePluginMgr. - // In-tree plugins that provisioned PVs will not be registered anymore after migration to CSI, once the respective - // feature gate is enabled. + // If the PV has been migrated, translate the in-tree volumeSpec to CSI volumeSpec. if inTreePluginName, err := adc.csiMigratedPluginManager.GetInTreePluginNameFromSpec(pv, nil); err == nil { if adc.csiMigratedPluginManager.IsMigrationEnabledForPlugin(inTreePluginName) { // PV is migrated and should be handled by the CSI plugin instead of the in-tree one diff --git a/pkg/controller/volume/attachdetach/metrics/metrics_test.go b/pkg/controller/volume/attachdetach/metrics/metrics_test.go index a8c649f4e2e..9ad31a3c865 100644 --- a/pkg/controller/volume/attachdetach/metrics/metrics_test.go +++ b/pkg/controller/volume/attachdetach/metrics/metrics_test.go @@ -23,7 +23,6 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" k8stypes "k8s.io/apimachinery/pkg/types" - utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes/fake" csitrans "k8s.io/csi-translation-lib" @@ -120,7 +119,7 @@ func TestVolumesInUseMetricCollection(t *testing.T) { nil, nil, fakeVolumePluginMgr, - csimigration.NewPluginManager(csiTranslator, utilfeature.DefaultFeatureGate), + csimigration.NewPluginManager(csiTranslator), csiTranslator) logger, _ := ktesting.NewTestContext(t) nodeUseMap := metricCollector.getVolumeInUseCount(logger) @@ -163,7 +162,7 @@ func TestTotalVolumesMetricCollection(t *testing.T) { asw, dsw, fakeVolumePluginMgr, - csimigration.NewPluginManager(csiTranslator, utilfeature.DefaultFeatureGate), + csimigration.NewPluginManager(csiTranslator), csiTranslator) totalVolumesMap := metricCollector.getTotalVolumesCount() diff --git a/pkg/controller/volume/attachdetach/populator/desired_state_of_world_populator_test.go b/pkg/controller/volume/attachdetach/populator/desired_state_of_world_populator_test.go index 788091681c1..00ae3253b94 100644 --- a/pkg/controller/volume/attachdetach/populator/desired_state_of_world_populator_test.go +++ b/pkg/controller/volume/attachdetach/populator/desired_state_of_world_populator_test.go @@ -23,7 +23,6 @@ import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" k8stypes "k8s.io/apimachinery/pkg/types" - utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes/fake" csitrans "k8s.io/csi-translation-lib" @@ -86,7 +85,7 @@ func TestFindAndAddActivePods_FindAndRemoveDeletedPods(t *testing.T) { podLister: fakePodInformer.Lister(), pvcLister: pvcLister, pvLister: pvLister, - csiMigratedPluginManager: csimigration.NewPluginManager(csiTranslator, utilfeature.DefaultFeatureGate), + csiMigratedPluginManager: csimigration.NewPluginManager(csiTranslator), intreeToCSITranslator: csiTranslator, } @@ -191,7 +190,7 @@ func TestFindAndRemoveNonattachableVolumes(t *testing.T) { podLister: fakePodInformer.Lister(), pvcLister: pvcLister, pvLister: pvLister, - csiMigratedPluginManager: csimigration.NewPluginManager(csiTranslator, utilfeature.DefaultFeatureGate), + csiMigratedPluginManager: csimigration.NewPluginManager(csiTranslator), intreeToCSITranslator: csiTranslator, } diff --git a/pkg/controller/volume/attachdetach/util/util_test.go b/pkg/controller/volume/attachdetach/util/util_test.go index d14e2e3b89a..ec2445fe667 100644 --- a/pkg/controller/volume/attachdetach/util/util_test.go +++ b/pkg/controller/volume/attachdetach/util/util_test.go @@ -35,7 +35,6 @@ import ( "k8s.io/kubernetes/pkg/volume/csimigration" "k8s.io/kubernetes/pkg/volume/fc" - utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/client-go/kubernetes/fake" utiltesting "k8s.io/client-go/util/testing" "k8s.io/kubernetes/pkg/volume" @@ -291,7 +290,7 @@ func setup(nodeName string, t *testing.T) (*volume.VolumePluginMgr, csimigration *fsVolumeMode = v1.PersistentVolumeFilesystem csiTranslator := csitrans.New() - intreeToCSITranslator := csimigration.NewPluginManager(csiTranslator, utilfeature.DefaultFeatureGate) + intreeToCSITranslator := csimigration.NewPluginManager(csiTranslator) kubeClient := fake.NewSimpleClientset() factory := informers.NewSharedInformerFactory(kubeClient, time.Minute) diff --git a/pkg/controller/volume/expand/expand_controller_test.go b/pkg/controller/volume/expand/expand_controller_test.go index be9d0847ec2..bb59f0a4623 100644 --- a/pkg/controller/volume/expand/expand_controller_test.go +++ b/pkg/controller/volume/expand/expand_controller_test.go @@ -30,7 +30,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/strategicpatch" - utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/client-go/informers" coretesting "k8s.io/client-go/testing" csitrans "k8s.io/csi-translation-lib" @@ -108,7 +107,7 @@ func TestSyncHandler(t *testing.T) { } allPlugins := []volume.VolumePlugin{} translator := csitrans.New() - expc, err := NewExpandController(tCtx, fakeKubeClient, pvcInformer, allPlugins, translator, csimigration.NewPluginManager(translator, utilfeature.DefaultFeatureGate)) + expc, err := NewExpandController(tCtx, fakeKubeClient, pvcInformer, allPlugins, translator, csimigration.NewPluginManager(translator)) if err != nil { t.Fatalf("error creating expand controller : %v", err) } diff --git a/pkg/controller/volume/persistentvolume/pv_controller_base.go b/pkg/controller/volume/persistentvolume/pv_controller_base.go index 3324d627192..32427aa2892 100644 --- a/pkg/controller/volume/persistentvolume/pv_controller_base.go +++ b/pkg/controller/volume/persistentvolume/pv_controller_base.go @@ -141,7 +141,7 @@ func NewController(ctx context.Context, p ControllerParameters) (*PersistentVolu csiTranslator := csitrans.New() controller.translator = csiTranslator - controller.csiMigratedPluginManager = csimigration.NewPluginManager(csiTranslator, utilfeature.DefaultFeatureGate) + controller.csiMigratedPluginManager = csimigration.NewPluginManager(csiTranslator) return controller, nil } diff --git a/pkg/controller/volume/persistentvolume/pv_controller_test.go b/pkg/controller/volume/persistentvolume/pv_controller_test.go index 6d60d3d2f14..1e3fcb3dde5 100644 --- a/pkg/controller/volume/persistentvolume/pv_controller_test.go +++ b/pkg/controller/volume/persistentvolume/pv_controller_test.go @@ -583,7 +583,7 @@ func TestAnnealMigrationAnnotations(t *testing.T) { } translator := csitrans.New() - cmpm := csimigration.NewPluginManager(translator, utilfeature.DefaultFeatureGate) + cmpm := csimigration.NewPluginManager(translator) logger, _ := ktesting.NewTestContext(t) for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { @@ -745,7 +745,7 @@ func TestModifyDeletionFinalizers(t *testing.T) { } translator := csitrans.New() - cmpm := csimigration.NewPluginManager(translator, utilfeature.DefaultFeatureGate) + cmpm := csimigration.NewPluginManager(translator) logger, _ := ktesting.NewTestContext(t) for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { diff --git a/pkg/controller/volume/selinuxwarning/selinux_warning_controller.go b/pkg/controller/volume/selinuxwarning/selinux_warning_controller.go index 1281074dc06..249a954e196 100644 --- a/pkg/controller/volume/selinuxwarning/selinux_warning_controller.go +++ b/pkg/controller/volume/selinuxwarning/selinux_warning_controller.go @@ -29,7 +29,6 @@ import ( errorutils "k8s.io/apimachinery/pkg/util/errors" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/wait" - utilfeature "k8s.io/apiserver/pkg/util/feature" coreinformers "k8s.io/client-go/informers/core/v1" storageinformersv1 "k8s.io/client-go/informers/storage/v1" clientset "k8s.io/client-go/kubernetes" @@ -130,7 +129,7 @@ func NewController( } csiTranslator := csitrans.New() c.csiTranslator = csiTranslator - c.cmpm = csimigration.NewPluginManager(csiTranslator, utilfeature.DefaultFeatureGate) + c.cmpm = csimigration.NewPluginManager(csiTranslator) // Index pods by its PVC keys. Then we don't need to iterate all pods every time to find // pods which reference given PVC. diff --git a/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator_test.go b/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator_test.go index 005c3bf71c1..6ee8b64d1c8 100644 --- a/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator_test.go +++ b/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator_test.go @@ -1613,7 +1613,7 @@ func createDswpWithVolumeWithCustomPluginMgr(pv *v1.PersistentVolume, pvc *v1.Pe actualStateOfWorld: fakeASW, pods: processedPods{ processedPods: make(map[types.UniquePodName]bool)}, - csiMigratedPluginManager: csimigration.NewPluginManager(csiTranslator, utilfeature.DefaultFeatureGate), + csiMigratedPluginManager: csimigration.NewPluginManager(csiTranslator), intreeToCSITranslator: csiTranslator, volumePluginMgr: fakeVolumePluginMgr, } diff --git a/pkg/kubelet/volumemanager/volume_manager.go b/pkg/kubelet/volumemanager/volume_manager.go index bda332e6116..40bde02f562 100644 --- a/pkg/kubelet/volumemanager/volume_manager.go +++ b/pkg/kubelet/volumemanager/volume_manager.go @@ -207,7 +207,7 @@ func NewVolumeManager( } intreeToCSITranslator := csitrans.New() - csiMigratedPluginManager := csimigration.NewPluginManager(intreeToCSITranslator, utilfeature.DefaultFeatureGate) + csiMigratedPluginManager := csimigration.NewPluginManager(intreeToCSITranslator) vm.intreeToCSITranslator = intreeToCSITranslator vm.csiMigratedPluginManager = csiMigratedPluginManager diff --git a/pkg/volume/csimigration/plugin_manager.go b/pkg/volume/csimigration/plugin_manager.go index 675699e636a..1111fb9a59e 100644 --- a/pkg/volume/csimigration/plugin_manager.go +++ b/pkg/volume/csimigration/plugin_manager.go @@ -37,14 +37,12 @@ type PluginNameMapper interface { // PluginManager keeps track of migrated state of in-tree plugins type PluginManager struct { PluginNameMapper - featureGate featuregate.FeatureGate } // NewPluginManager returns a new PluginManager instance -func NewPluginManager(m PluginNameMapper, featureGate featuregate.FeatureGate) PluginManager { +func NewPluginManager(m PluginNameMapper) PluginManager { return PluginManager{ PluginNameMapper: m, - featureGate: featureGate, } }