Skip to content

Commit 2d9a8f9

Browse files
committed
UPSTREAM: <carry>: openshift KCM volume plugin manager uses a disjoint set of featuregates
The volume plugin manager for openshfit's Attach Detach controller in kube-controller-manager uses a set of featuregates that are NOT the same as the the other controllers in KCM and the kubelet. This means these featuregates (if we kept the old names) would be inconsistent inside of a single binary. There are now separate featuregates for the volumepluginmanger when running in the Attach Detach controller to reflect this distintion. See openshift/enhancements#549 for details. Stop <carrying> the patch when CSI migration becomes GA (i.e. features.CSIMigrationAWS / features.CSIMigrationOpenStack are GA).
1 parent dd7e566 commit 2d9a8f9

File tree

4 files changed

+78
-4
lines changed

4 files changed

+78
-4
lines changed

pkg/controller/volume/attachdetach/attach_detach_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func NewAttachDetachController(
184184

185185
csiTranslator := csitrans.New()
186186
adc.intreeToCSITranslator = csiTranslator
187-
adc.csiMigratedPluginManager = csimigration.NewPluginManager(csiTranslator, utilfeature.DefaultFeatureGate)
187+
adc.csiMigratedPluginManager = csimigration.NewADCPluginManager(csiTranslator, utilfeature.DefaultFeatureGate)
188188

189189
adc.desiredStateOfWorldPopulator = populator.NewDesiredStateOfWorldPopulator(
190190
timerConfig.DesiredStateOfWorldPopulatorLoopSleepPeriod,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package features
2+
3+
import (
4+
"k8s.io/apimachinery/pkg/util/runtime"
5+
utilfeature "k8s.io/apiserver/pkg/util/feature"
6+
"k8s.io/component-base/featuregate"
7+
)
8+
9+
var (
10+
// owner: @jsafrane
11+
// alpha: v1.21
12+
//
13+
// Enables the AWS EBS CSI migration for the Attach/Detach controller (ADC) only.
14+
ADCCSIMigrationAWS featuregate.Feature = "ADC_CSIMigrationAWS"
15+
16+
// owner: @jsafrane
17+
// alpha: v1.21
18+
//
19+
// Enables the Cinder CSI migration for the Attach/Detach controller (ADC) only.
20+
ADCCSIMigrationCinder featuregate.Feature = "ADC_CSIMigrationCinder"
21+
)
22+
23+
var ocpDefaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
24+
ADCCSIMigrationAWS: {Default: true, PreRelease: featuregate.Beta},
25+
ADCCSIMigrationCinder: {Default: true, PreRelease: featuregate.Beta},
26+
}
27+
28+
func init() {
29+
runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(ocpDefaultKubernetesFeatureGates))
30+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package csimigration
2+
3+
import (
4+
"k8s.io/component-base/featuregate"
5+
csilibplugins "k8s.io/csi-translation-lib/plugins"
6+
"k8s.io/kubernetes/pkg/features"
7+
)
8+
9+
// NewADCPluginManager returns a new PluginManager instance for the Attach Detach controller which uses different
10+
// featuregates in openshift to control enablement/disablement which *DO NOT MATCH* the featuregates for the rest of the
11+
// cluster.
12+
func NewADCPluginManager(m PluginNameMapper, featureGate featuregate.FeatureGate) PluginManager {
13+
ret := NewPluginManager(m, featureGate)
14+
ret.useADCPluginManagerFeatureGates = true
15+
return ret
16+
}
17+
18+
// adcIsMigrationEnabledForPlugin indicates whether CSI migration has been enabled
19+
// for a particular storage plugin in Attach/Detach controller.
20+
func (pm PluginManager) adcIsMigrationEnabledForPlugin(pluginName string) bool {
21+
// CSIMigration feature should be enabled along with the plugin-specific one
22+
if !pm.featureGate.Enabled(features.CSIMigration) {
23+
return false
24+
}
25+
26+
switch pluginName {
27+
case csilibplugins.AWSEBSInTreePluginName:
28+
return pm.featureGate.Enabled(features.ADCCSIMigrationAWS)
29+
case csilibplugins.CinderInTreePluginName:
30+
return pm.featureGate.Enabled(features.ADCCSIMigrationCinder)
31+
default:
32+
return pm.isMigrationEnabledForPlugin(pluginName)
33+
}
34+
}
35+
36+
// IsMigrationEnabledForPlugin indicates whether CSI migration has been enabled
37+
// for a particular storage plugin
38+
func (pm PluginManager) IsMigrationEnabledForPlugin(pluginName string) bool {
39+
if pm.useADCPluginManagerFeatureGates {
40+
return pm.adcIsMigrationEnabledForPlugin(pluginName)
41+
}
42+
43+
return pm.isMigrationEnabledForPlugin(pluginName)
44+
}

pkg/volume/csimigration/plugin_manager.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ type PluginNameMapper interface {
3838
type PluginManager struct {
3939
PluginNameMapper
4040
featureGate featuregate.FeatureGate
41+
42+
useADCPluginManagerFeatureGates bool
4143
}
4244

4345
// NewPluginManager returns a new PluginManager instance
@@ -77,9 +79,7 @@ func (pm PluginManager) IsMigrationCompleteForPlugin(pluginName string) bool {
7779
}
7880
}
7981

80-
// IsMigrationEnabledForPlugin indicates whether CSI migration has been enabled
81-
// for a particular storage plugin
82-
func (pm PluginManager) IsMigrationEnabledForPlugin(pluginName string) bool {
82+
func (pm PluginManager) isMigrationEnabledForPlugin(pluginName string) bool {
8383
// CSIMigration feature should be enabled along with the plugin-specific one
8484
if !pm.featureGate.Enabled(features.CSIMigration) {
8585
return false

0 commit comments

Comments
 (0)