@@ -38,6 +38,12 @@ var dualStackPlatforms = sets.NewString(
3838 string (configv1 .OpenStackPlatformType ),
3939)
4040
41+ var conversionToDualStackPlatforms = sets .NewString (
42+ string (configv1 .BareMetalPlatformType ),
43+ string (configv1 .NonePlatformType ),
44+ string (configv1 .VSpherePlatformType ),
45+ )
46+
4147const (
4248 pluginName = "networking-console-plugin"
4349)
@@ -47,6 +53,9 @@ func Render(operConf *operv1.NetworkSpec, clusterConf *configv1.NetworkSpec, man
4753 var progressing bool
4854 objs := []* uns.Unstructured {}
4955
56+ // Update the list of supported DualStack platforms based on enabled feature gates.
57+ updateDualStackPlatforms (featureGates )
58+
5059 // render cloud network config controller **before** the network plugin.
5160 // the network plugin is dependent upon having the cloud network CRD
5261 // defined as to initialize its watcher, otherwise it will error and crash
@@ -400,13 +409,13 @@ func isNetworkChangeSafe(prev, next *operv1.NetworkSpec, infraRes *bootstrap.Inf
400409 return isClusterNetworkChangeSafe (prev , next )
401410 }
402411
403- // Validate that this is either a BareMetal or None PlatformType. For all other
404- // PlatformTypes, migration to DualStack is prohibited
412+ // Validate that this is a platform that supports DualStack. If it does, then check if
413+ // migration to DualStack on day-2 is allowed.
405414 if len (prev .ServiceNetwork ) < len (next .ServiceNetwork ) {
406415 if ! isSupportedDualStackPlatform (infraRes .PlatformType ) {
407416 return errors .Errorf ("%s is not one of the supported platforms for dual stack (%s)" , infraRes .PlatformType ,
408417 strings .Join (dualStackPlatforms .List (), ", " ))
409- } else if string ( configv1 . OpenStackPlatformType ) == string (infraRes .PlatformType ) {
418+ } else if ! isConversionSupportedDualStackPlatform (infraRes .PlatformType ) {
410419 return errors .Errorf ("%s does not allow conversion to dual-stack cluster" , infraRes .PlatformType )
411420 }
412421 }
@@ -977,6 +986,10 @@ func isSupportedDualStackPlatform(platformType configv1.PlatformType) bool {
977986 return dualStackPlatforms .Has (string (platformType ))
978987}
979988
989+ func isConversionSupportedDualStackPlatform (platformType configv1.PlatformType ) bool {
990+ return conversionToDualStackPlatforms .Has (string (platformType ))
991+ }
992+
980993func renderAdditionalRoutingCapabilities (conf * operv1.NetworkSpec , manifestDir string ) ([]* uns.Unstructured , error ) {
981994 if conf == nil || conf .AdditionalRoutingCapabilities == nil {
982995 return nil , nil
@@ -999,3 +1012,16 @@ func renderAdditionalRoutingCapabilities(conf *operv1.NetworkSpec, manifestDir s
9991012
10001013 return out , nil
10011014}
1015+
1016+ // updateDualStackPlatforms checks for enabled feature gates and adds to the list
1017+ // of platforms that support DualStack on Day-0. Currently the 2 platforms added here
1018+ // donot support conversion to DualStack on Day-2. When that happens, we will need to
1019+ // update `conversionToDualStackPlatforms` too.
1020+ func updateDualStackPlatforms (featureGates featuregates.FeatureGate ) {
1021+ if featureGates .Enabled (apifeatures .FeatureGateAWSDualStackInstall ) {
1022+ dualStackPlatforms .Insert (string (configv1 .AWSPlatformType ))
1023+ }
1024+ if featureGates .Enabled (apifeatures .FeatureGateAzureDualStackInstall ) {
1025+ dualStackPlatforms .Insert (string (configv1 .AzurePlatformType ))
1026+ }
1027+ }
0 commit comments