Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func NewAttachDetachController(

csiTranslator := csitrans.New()
adc.intreeToCSITranslator = csiTranslator
adc.csiMigratedPluginManager = csimigration.NewPluginManager(csiTranslator, utilfeature.DefaultFeatureGate)
adc.csiMigratedPluginManager = csimigration.NewADCPluginManager(csiTranslator, utilfeature.DefaultFeatureGate)

adc.desiredStateOfWorldPopulator = populator.NewDesiredStateOfWorldPopulator(
timerConfig.DesiredStateOfWorldPopulatorLoopSleepPeriod,
Expand Down
30 changes: 30 additions & 0 deletions pkg/features/patch_kube_features.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package features

import (
"k8s.io/apimachinery/pkg/util/runtime"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/component-base/featuregate"
)

var (
// owner: @jsafrane
// alpha: v1.21
//
// Enables the AWS EBS CSI migration for the Attach/Detach controller (ADC) only.
ADCCSIMigrationAWS featuregate.Feature = "ADC_CSIMigrationAWS"

// owner: @jsafrane
// alpha: v1.21
//
// Enables the Cinder CSI migration for the Attach/Detach controller (ADC) only.
ADCCSIMigrationCinder featuregate.Feature = "ADC_CSIMigrationCinder"
)

var ocpDefaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
ADCCSIMigrationAWS: {Default: true, PreRelease: featuregate.Beta},
ADCCSIMigrationCinder: {Default: true, PreRelease: featuregate.Beta},
}

func init() {
runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(ocpDefaultKubernetesFeatureGates))
}
44 changes: 44 additions & 0 deletions pkg/volume/csimigration/patch_adc_plugin_manager.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package csimigration

import (
"k8s.io/component-base/featuregate"
csilibplugins "k8s.io/csi-translation-lib/plugins"
"k8s.io/kubernetes/pkg/features"
)

// NewADCPluginManager returns a new PluginManager instance for the Attach Detach controller which uses different
// featuregates in openshift to control enablement/disablement which *DO NOT MATCH* the featuregates for the rest of the
// cluster.
func NewADCPluginManager(m PluginNameMapper, featureGate featuregate.FeatureGate) PluginManager {
ret := NewPluginManager(m, featureGate)
ret.useADCPluginManagerFeatureGates = true
return ret
}

// adcIsMigrationEnabledForPlugin indicates whether CSI migration has been enabled
// for a particular storage plugin in Attach/Detach controller.
func (pm PluginManager) adcIsMigrationEnabledForPlugin(pluginName string) bool {
// CSIMigration feature should be enabled along with the plugin-specific one
if !pm.featureGate.Enabled(features.CSIMigration) {
return false
}

switch pluginName {
case csilibplugins.AWSEBSInTreePluginName:
return pm.featureGate.Enabled(features.ADCCSIMigrationAWS)
case csilibplugins.CinderInTreePluginName:
return pm.featureGate.Enabled(features.ADCCSIMigrationCinder)
default:
return pm.isMigrationEnabledForPlugin(pluginName)
}
}

// IsMigrationEnabledForPlugin indicates whether CSI migration has been enabled
// for a particular storage plugin
func (pm PluginManager) IsMigrationEnabledForPlugin(pluginName string) bool {
if pm.useADCPluginManagerFeatureGates {
return pm.adcIsMigrationEnabledForPlugin(pluginName)
}

return pm.isMigrationEnabledForPlugin(pluginName)
}
6 changes: 3 additions & 3 deletions pkg/volume/csimigration/plugin_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type PluginNameMapper interface {
type PluginManager struct {
PluginNameMapper
featureGate featuregate.FeatureGate

useADCPluginManagerFeatureGates bool
}

// NewPluginManager returns a new PluginManager instance
Expand Down Expand Up @@ -77,9 +79,7 @@ func (pm PluginManager) IsMigrationCompleteForPlugin(pluginName string) bool {
}
}

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