Skip to content

Commit 3e4316e

Browse files
committed
Set "ClusterHostedDNS" in the Infra CR to "Enabled"
When userProvisionedDNS is enabled on GCP, set `ClusterHostedDNS` in the GCP PlatformStatus of the Infra CR to Enabled.
1 parent 528887f commit 3e4316e

File tree

2 files changed

+73
-3
lines changed

2 files changed

+73
-3
lines changed

pkg/asset/manifests/infrastructure.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ func (i *Infrastructure) Generate(dependencies asset.Parents) error {
194194
}
195195
config.Status.PlatformStatus.GCP.ResourceTags = resourceTags
196196
}
197+
// If the user has requested the use of a DNS provisioned by them, then OpenShift needs to
198+
// start an in-cluster DNS for the installation to succeed. The user can then configure their
199+
// DNS post-install.
200+
config.Status.PlatformStatus.GCP.ClusterHostedDNS = configv1.DisabledClusterHostedDNS
201+
if installConfig.Config.GCP.UserProvisionedDNS == gcp.UserProvisionedDNSEnabled {
202+
config.Status.PlatformStatus.GCP.ClusterHostedDNS = configv1.EnabledClusterHostedDNS
203+
}
197204
case ibmcloud.Name:
198205
config.Spec.PlatformSpec.Type = configv1.IBMCloudPlatformType
199206
var cisInstanceCRN, dnsInstanceCRN string

pkg/asset/manifests/infrastructure_test.go

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/openshift/installer/pkg/types"
1414
awstypes "github.com/openshift/installer/pkg/types/aws"
1515
azuretypes "github.com/openshift/installer/pkg/types/azure"
16+
gcptypes "github.com/openshift/installer/pkg/types/gcp"
1617
nonetypes "github.com/openshift/installer/pkg/types/none"
1718
)
1819

@@ -21,6 +22,7 @@ func TestGenerateInfrastructure(t *testing.T) {
2122
name string
2223
installConfig *types.InstallConfig
2324
expectedInfrastructure *configv1.Infrastructure
25+
expectedFilesGenerated int
2426
}{{
2527
name: "vanilla aws",
2628
installConfig: icBuild.build(icBuild.forAWS()),
@@ -29,6 +31,7 @@ func TestGenerateInfrastructure(t *testing.T) {
2931
infraBuild.withAWSPlatformSpec(),
3032
infraBuild.withAWSPlatformStatus(),
3133
),
34+
expectedFilesGenerated: 1,
3235
}, {
3336
name: "service endpoints",
3437
installConfig: icBuild.build(
@@ -39,6 +42,7 @@ func TestGenerateInfrastructure(t *testing.T) {
3942
infraBuild.forPlatform(configv1.AWSPlatformType),
4043
infraBuild.withServiceEndpoint("service", "https://endpoint"),
4144
),
45+
expectedFilesGenerated: 1,
4246
}, {
4347
name: "azure resource tags",
4448
installConfig: icBuild.build(
@@ -49,6 +53,26 @@ func TestGenerateInfrastructure(t *testing.T) {
4953
infraBuild.forPlatform(configv1.AzurePlatformType),
5054
infraBuild.withResourceTags([]configv1.AzureResourceTag{{Key: "key", Value: "value"}}),
5155
),
56+
expectedFilesGenerated: 1,
57+
}, {
58+
name: "default GCP custom DNS",
59+
installConfig: icBuild.build(icBuild.forGCP()),
60+
expectedInfrastructure: infraBuild.build(
61+
infraBuild.forPlatform(configv1.GCPPlatformType),
62+
infraBuild.withGCPClusterHostedDNS("Disabled"),
63+
),
64+
expectedFilesGenerated: 2,
65+
}, {
66+
name: "GCP custom DNS",
67+
installConfig: icBuild.build(
68+
icBuild.forGCP(),
69+
icBuild.withGCPUserProvisionedDNS("Enabled"),
70+
),
71+
expectedInfrastructure: infraBuild.build(
72+
infraBuild.forPlatform(configv1.GCPPlatformType),
73+
infraBuild.withGCPClusterHostedDNS("Enabled"),
74+
),
75+
expectedFilesGenerated: 2,
5276
}}
5377
for _, tc := range cases {
5478
t.Run(tc.name, func(t *testing.T) {
@@ -67,12 +91,13 @@ func TestGenerateInfrastructure(t *testing.T) {
6791
if !assert.NoError(t, err, "failed to generate asset") {
6892
return
6993
}
70-
if !assert.Len(t, infraAsset.FileList, 1, "expected only one file to be generated") {
94+
95+
if !assert.Len(t, infraAsset.FileList, tc.expectedFilesGenerated, "did not generate expected amount of files") {
7196
return
7297
}
73-
assert.Equal(t, infraAsset.FileList[0].Filename, "manifests/cluster-infrastructure-02-config.yml")
98+
assert.Equal(t, infraAsset.FileList[tc.expectedFilesGenerated-1].Filename, "manifests/cluster-infrastructure-02-config.yml")
7499
var actualInfra configv1.Infrastructure
75-
err = yaml.Unmarshal(infraAsset.FileList[0].Data, &actualInfra)
100+
err = yaml.Unmarshal(infraAsset.FileList[tc.expectedFilesGenerated-1].Data, &actualInfra)
76101
if !assert.NoError(t, err, "failed to unmarshal infra manifest") {
77102
return
78103
}
@@ -110,6 +135,15 @@ func (b icBuildNamespace) forAWS() icOption {
110135
}
111136
}
112137

138+
func (b icBuildNamespace) forGCP() icOption {
139+
return func(ic *types.InstallConfig) {
140+
if ic.Platform.GCP != nil {
141+
return
142+
}
143+
ic.Platform.GCP = &gcptypes.Platform{}
144+
}
145+
}
146+
113147
func (b icBuildNamespace) forNone() icOption {
114148
return func(ic *types.InstallConfig) {
115149
if ic.Platform.None != nil {
@@ -139,6 +173,16 @@ func (b icBuildNamespace) withLBType(lbType configv1.AWSLBType) icOption {
139173
}
140174
}
141175

176+
func (b icBuildNamespace) withGCPUserProvisionedDNS(enabled string) icOption {
177+
return func(ic *types.InstallConfig) {
178+
b.forGCP()(ic)
179+
if enabled == "Enabled" {
180+
ic.Platform.GCP.UserProvisionedDNS = gcptypes.UserProvisionedDNSEnabled
181+
ic.FeatureGates = []string{"GCPClusterHostedDNS=true"}
182+
}
183+
}
184+
}
185+
142186
type infraOption func(*configv1.Infrastructure)
143187

144188
type infraBuildNamespace struct{}
@@ -243,3 +287,22 @@ func (b infraBuildNamespace) withResourceTags(tags []configv1.AzureResourceTag)
243287
infra.Status.PlatformStatus.Azure.ResourceTags = tags
244288
}
245289
}
290+
291+
func (b infraBuildNamespace) withGCPPlatformStatus() infraOption {
292+
return func(infra *configv1.Infrastructure) {
293+
if infra.Status.PlatformStatus.GCP != nil {
294+
return
295+
}
296+
infra.Status.PlatformStatus.GCP = &configv1.GCPPlatformStatus{}
297+
}
298+
}
299+
300+
func (b infraBuildNamespace) withGCPClusterHostedDNS(enabled string) infraOption {
301+
return func(infra *configv1.Infrastructure) {
302+
b.withGCPPlatformStatus()(infra)
303+
infra.Status.PlatformStatus.GCP.ClusterHostedDNS = configv1.DisabledClusterHostedDNS
304+
if enabled == "Enabled" {
305+
infra.Status.PlatformStatus.GCP.ClusterHostedDNS = configv1.EnabledClusterHostedDNS
306+
}
307+
}
308+
}

0 commit comments

Comments
 (0)