diff --git a/pkg/installer/custominstallconfig.go b/pkg/installer/custominstallconfig.go index a392ee4bb..487a3dc96 100644 --- a/pkg/installer/custominstallconfig.go +++ b/pkg/installer/custominstallconfig.go @@ -91,7 +91,7 @@ func (m *manager) applyInstallConfigCustomisations(ctx context.Context, installC IngressIP: m.oc.Properties.IngressProfiles[0].IP, } - if m.oc.Properties.NetworkProfile.GatewayPrivateEndpointIP != "" { + if m.oc.Properties.FeatureProfile.GatewayEnabled && m.oc.Properties.NetworkProfile.GatewayPrivateEndpointIP != "" { localdnsConfig.GatewayPrivateEndpointIP = m.oc.Properties.NetworkProfile.GatewayPrivateEndpointIP localdnsConfig.GatewayDomains = m.getGatewayDomains(m.env, m.oc) } diff --git a/pkg/installer/custominstallconfig_test.go b/pkg/installer/custominstallconfig_test.go index a06efe6f8..7ace1d57a 100644 --- a/pkg/installer/custominstallconfig_test.go +++ b/pkg/installer/custominstallconfig_test.go @@ -95,6 +95,9 @@ func fakeCluster() *api.OpenShiftCluster { Properties: api.OpenShiftClusterProperties{ InfraID: "test-infra-id", ImageRegistryStorageAccountName: "test-image-registry-storage-acct", + FeatureProfile: api.FeatureProfile{ + GatewayEnabled: true, + }, APIServerProfile: api.APIServerProfile{ IntIP: apiIntIP, }, @@ -311,6 +314,51 @@ func TestApplyInstallConfigCustomisations(t *testing.T) { verifyDNSPointerIgnition(t, bootstrapAsset) } +func TestApplyInstallConfigCustomisationsGatewayDisabled(t *testing.T) { + ctx := context.Background() + m := fakeManager() + m.oc.Properties.FeatureProfile.GatewayEnabled = false + inInstallConfig := makeInstallConfig() + + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + mockClient := mock.NewMockAPI(mockCtrl) + inInstallConfig.Azure.UseMockClient(mockClient) + mockClientCalls(mockClient) + + graph, err := m.applyInstallConfigCustomisations(ctx, inInstallConfig, makeImage()) + require.NoError(t, err) + + bootstrapAsset := graph.Get(&bootstrap.Bootstrap{}).(*bootstrap.Bootstrap) + var temp map[string]any + err = json.Unmarshal(bootstrapAsset.Files()[0].Data, &temp) + require.NoError(t, err) + + files := (temp["storage"].(map[string]any))["files"].([]any) + storageFileList := map[string]string{} + for _, file := range files { + contents, found := file.(map[string]any)["contents"] + if !found { + contents = file.(map[string]any)["append"].([]any)[0] + } + storageFileList[file.(map[string]any)["path"].(string)] = contents.(map[string]any)["source"].(string) + } + + for path, source := range storageFileList { + parts := strings.Split(source, ",") + if len(parts) < 2 { + continue + } + + decoded, err := base64.StdEncoding.DecodeString(parts[1]) + require.NoError(t, err) + + content := string(decoded) + assert.NotContains(t, content, "gateway.mock1.example.com", "unexpected gateway domain in %s", path) + assert.NotContains(t, content, "gateway.mock2.example.com", "unexpected gateway domain in %s", path) + } +} + func verifyIgnitionFiles(t *testing.T, temp map[string]any, storageFiles []string, systemdFiles []string, fileName string) { files := (temp["storage"].(map[string]any))["files"].([]any) systemd := (temp["systemd"].(map[string]any))["units"].([]any) diff --git a/pkg/installer/deployresources_resources.go b/pkg/installer/deployresources_resources.go index 77f574ff2..b245530ab 100644 --- a/pkg/installer/deployresources_resources.go +++ b/pkg/installer/deployresources_resources.go @@ -105,7 +105,7 @@ func (m *manager) computeBootstrapVM(installConfig *installconfig.InstallConfig) } else { sasURL = `https://cluster` + m.oc.Properties.StorageSuffix + `.blob.` + m.env.Environment().StorageEndpointSuffix + `/ignition/bootstrap.ign?', listAccountSas(resourceId('Microsoft.Storage/storageAccounts', 'cluster` + m.oc.Properties.StorageSuffix + `'), '2019-04-01', parameters('sas')).accountSasToken, '` } - if m.oc.Properties.NetworkProfile.GatewayPrivateEndpointIP != "" { + if m.oc.Properties.FeatureProfile.GatewayEnabled && m.oc.Properties.NetworkProfile.GatewayPrivateEndpointIP != "" { customData = `[base64(concat('{"ignition":{"version":"3.2.0","proxy":{"httpsProxy":"http://` + m.oc.Properties.NetworkProfile.GatewayPrivateEndpointIP + `"},"config":{"replace":{"source":"` + sasURL + `"}}}}'))]` } else { customData = `[base64(concat('{"ignition":{"version":"3.2.0","config":{"replace":{"source":"` + sasURL + `"}}}}'))]`