@@ -33,7 +33,6 @@ import (
33
33
"k8s.io/apimachinery/pkg/util/sets"
34
34
"k8s.io/apimachinery/pkg/util/wait"
35
35
"k8s.io/apiserver/pkg/storage"
36
- utilfeature "k8s.io/apiserver/pkg/util/feature"
37
36
coreinformers "k8s.io/client-go/informers/core/v1"
38
37
storageinformers "k8s.io/client-go/informers/storage/v1"
39
38
clientset "k8s.io/client-go/kubernetes"
@@ -45,7 +44,7 @@ import (
45
44
csiplugins "k8s.io/csi-translation-lib/plugins"
46
45
"k8s.io/klog/v2"
47
46
v1helper "k8s.io/kubernetes/pkg/apis/core/v1/helper"
48
- "k8s.io/kubernetes/pkg/features "
47
+ "k8s.io/kubernetes/pkg/scheduler/framework/plugins/feature "
49
48
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/volumebinding/metrics"
50
49
"k8s.io/kubernetes/pkg/scheduler/util/assumecache"
51
50
)
@@ -203,7 +202,9 @@ type PodVolumeClaims struct {
203
202
}
204
203
205
204
type volumeBinder struct {
206
- kubeClient clientset.Interface
205
+ kubeClient clientset.Interface
206
+ enableVolumeAttributesClass bool
207
+ enableCSIMigrationPortworx bool
207
208
208
209
classLister storagelisters.StorageClassLister
209
210
podLister corelisters.PodLister
@@ -238,6 +239,7 @@ type CapacityCheck struct {
238
239
func NewVolumeBinder (
239
240
logger klog.Logger ,
240
241
kubeClient clientset.Interface ,
242
+ fts feature.Features ,
241
243
podInformer coreinformers.PodInformer ,
242
244
nodeInformer coreinformers.NodeInformer ,
243
245
csiNodeInformer storageinformers.CSINodeInformer ,
@@ -247,15 +249,17 @@ func NewVolumeBinder(
247
249
capacityCheck CapacityCheck ,
248
250
bindTimeout time.Duration ) SchedulerVolumeBinder {
249
251
b := & volumeBinder {
250
- kubeClient : kubeClient ,
251
- podLister : podInformer .Lister (),
252
- classLister : storageClassInformer .Lister (),
253
- nodeLister : nodeInformer .Lister (),
254
- csiNodeLister : csiNodeInformer .Lister (),
255
- pvcCache : NewPVCAssumeCache (logger , pvcInformer .Informer ()),
256
- pvCache : NewPVAssumeCache (logger , pvInformer .Informer ()),
257
- bindTimeout : bindTimeout ,
258
- translator : csitrans .New (),
252
+ kubeClient : kubeClient ,
253
+ enableVolumeAttributesClass : fts .EnableVolumeAttributesClass ,
254
+ enableCSIMigrationPortworx : fts .EnableCSIMigrationPortworx ,
255
+ podLister : podInformer .Lister (),
256
+ classLister : storageClassInformer .Lister (),
257
+ nodeLister : nodeInformer .Lister (),
258
+ csiNodeLister : csiNodeInformer .Lister (),
259
+ pvcCache : NewPVCAssumeCache (logger , pvcInformer .Informer ()),
260
+ pvCache : NewPVAssumeCache (logger , pvInformer .Informer ()),
261
+ bindTimeout : bindTimeout ,
262
+ translator : csitrans .New (),
259
263
}
260
264
261
265
b .csiDriverLister = capacityCheck .CSIDriverInformer .Lister ()
@@ -855,7 +859,7 @@ func (b *volumeBinder) findMatchingVolumes(logger klog.Logger, pod *v1.Pod, clai
855
859
pvs := unboundVolumesDelayBinding [storageClassName ]
856
860
857
861
// Find a matching PV
858
- pv , err := volume .FindMatchingVolume (pvc , pvs , node , chosenPVs , true , utilfeature . DefaultFeatureGate . Enabled ( features . VolumeAttributesClass ) )
862
+ pv , err := volume .FindMatchingVolume (pvc , pvs , node , chosenPVs , true , b . enableVolumeAttributesClass )
859
863
if err != nil {
860
864
return false , nil , nil , err
861
865
}
@@ -1033,7 +1037,7 @@ func (a byPVCSize) Less(i, j int) bool {
1033
1037
}
1034
1038
1035
1039
// isCSIMigrationOnForPlugin checks if CSI migration is enabled for a given plugin.
1036
- func isCSIMigrationOnForPlugin (pluginName string ) bool {
1040
+ func isCSIMigrationOnForPlugin (pluginName string , enableCSIMigrationPortworx bool ) bool {
1037
1041
switch pluginName {
1038
1042
case csiplugins .AWSEBSInTreePluginName :
1039
1043
return true
@@ -1044,7 +1048,7 @@ func isCSIMigrationOnForPlugin(pluginName string) bool {
1044
1048
case csiplugins .CinderInTreePluginName :
1045
1049
return true
1046
1050
case csiplugins .PortworxVolumePluginName :
1047
- return utilfeature . DefaultFeatureGate . Enabled ( features . CSIMigrationPortworx )
1051
+ return enableCSIMigrationPortworx
1048
1052
}
1049
1053
return false
1050
1054
}
@@ -1083,7 +1087,7 @@ func (b *volumeBinder) tryTranslatePVToCSI(logger klog.Logger, pv *v1.Persistent
1083
1087
return nil , fmt .Errorf ("could not get plugin name from pv: %v" , err )
1084
1088
}
1085
1089
1086
- if ! isCSIMigrationOnForPlugin (pluginName ) {
1090
+ if ! isCSIMigrationOnForPlugin (pluginName , b . enableCSIMigrationPortworx ) {
1087
1091
return pv , nil
1088
1092
}
1089
1093
0 commit comments