Skip to content

Commit 43ceb4d

Browse files
committed
Allow AWS and Azure as platforms that support dual-stack on Day-0
1. Added AWS and Azure as platforms that support DualStack on Day-0 2. Created another set of platforms that support DualStack on Day-2 3. Updated Render logic to take enabled featuregates into consideration to determine supported DualStack platforms 4. Updated tests to reflect the newly supported platforms and when they support DualStack.
1 parent 26708c9 commit 43ceb4d

File tree

3 files changed

+41
-11
lines changed

3 files changed

+41
-11
lines changed

pkg/network/cluster_config_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,11 @@ func TestValidateClusterConfigDualStack(t *testing.T) {
371371
err = ValidateClusterConfig(&configv1.Network{Spec: cc}, client)
372372
g.Expect(err).NotTo(HaveOccurred())
373373

374-
// You can't use dual-stack if this is anything else but BareMetal or NonePlatformType
375-
infrastructure.Status.PlatformStatus.Type = configv1.AzurePlatformType
374+
// You can't use dual-stack if enabled on an unsupported platform
375+
infrastructure.Status.PlatformStatus.Type = configv1.GCPPlatformType
376+
infrastructure.Status.PlatformStatus.GCP = &configv1.GCPPlatformStatus{
377+
Region: "us-west1",
378+
}
376379
client = fake.NewFakeClient(infrastructure)
377380
err = createProxy(client)
378381
g.Expect(err).NotTo(HaveOccurred())

pkg/network/render.go

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
4147
const (
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+
980993
func 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+
}

pkg/network/render_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"testing"
1616

1717
configv1 "github.com/openshift/api/config/v1"
18+
apifeatures "github.com/openshift/api/features"
1819
operv1 "github.com/openshift/api/operator/v1"
1920
"github.com/openshift/cluster-network-operator/pkg/bootstrap"
2021
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -234,19 +235,19 @@ func TestDisallowMultipleClusterNetworksOfOldIPFamily(t *testing.T) {
234235
g.Expect(err).To(MatchError(ContainSubstring("cannot add additional ClusterNetwork values of original IP family when migrating to dual stack")))
235236
}
236237

237-
func TestAllowMigrationOnlyForBareMetalOrNoneType(t *testing.T) {
238+
func TestAllowMigrationOnlyForSupportedTypes(t *testing.T) {
238239
g, infra, prev, next := setupTestInfraAndBasicRenderConfigs(t, OVNKubernetesConfig, OVNKubernetesConfig)
239240

240-
// You can't migrate from single-stack to dual-stack if this is anything else but
241-
// BareMetal or NonePlatformType
242-
infra.PlatformType = configv1.AzurePlatformType
243-
244241
next.ServiceNetwork = append(next.ServiceNetwork, "fd02::/112")
245242
next.ClusterNetwork = append(next.ClusterNetwork, operv1.ClusterNetworkEntry{
246243
CIDR: "fd01::/48",
247244
HostPrefix: 64,
248245
},
249246
)
247+
// You can't migrate from single-stack to dual-stack if this is anything else but
248+
// BareMetal, NonePlatformType, and VSphere
249+
infra.PlatformType = configv1.GCPPlatformType
250+
250251
err := IsChangeSafe(prev, next, infra)
251252
g.Expect(err).To(MatchError(ContainSubstring(fmt.Sprintf("%s is not one of the supported platforms for dual stack (%s)", infra.PlatformType,
252253
strings.Join(dualStackPlatforms.List(), ", ")))))
@@ -401,7 +402,7 @@ func TestRenderUnknownNetwork(t *testing.T) {
401402
bootstrapResult, err := Bootstrap(&config, client)
402403
g.Expect(err).NotTo(HaveOccurred())
403404

404-
featureGatesCNO := featuregates.NewFeatureGate([]configv1.FeatureGateName{}, []configv1.FeatureGateName{})
405+
featureGatesCNO := featuregates.NewFeatureGate([]configv1.FeatureGateName{apifeatures.FeatureGateAWSDualStackInstall, apifeatures.FeatureGateAzureDualStackInstall}, []configv1.FeatureGateName{})
405406

406407
objs, _, err := Render(prev, &configv1.NetworkSpec{}, manifestDir, client, featureGatesCNO, bootstrapResult)
407408
g.Expect(err).NotTo(HaveOccurred())

0 commit comments

Comments
 (0)