Skip to content

CORS-3855: Remove ARO build flag from installer #9124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 18, 2025
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
19 changes: 8 additions & 11 deletions pkg/asset/installconfig/azure/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,18 +713,15 @@ func validateResourceGroup(client API, fieldPath *field.Path, platform *aztypes.
allErrs = append(allErrs, field.Invalid(fieldPath.Child("resourceGroupName"), platform.ResourceGroupName, fmt.Sprintf("resource group has conflicting tags %s", strings.Join(conflictingTagKeys, ", "))))
}

// ARO provisions Azure resources before resolving the asset graph.
if !platform.IsARO() {
ids, err := client.ListResourceIDsByGroup(context.TODO(), platform.ResourceGroupName)
if err != nil {
return append(allErrs, field.InternalError(fieldPath.Child("resourceGroupName"), fmt.Errorf("failed to list resources in the resource group: %w", err)))
}
if l := len(ids); l > 0 {
if len(ids) > 2 {
ids = ids[:2]
}
allErrs = append(allErrs, field.Invalid(fieldPath.Child("resourceGroupName"), platform.ResourceGroupName, fmt.Sprintf("resource group must be empty but it has %d resources like %s ...", l, strings.Join(ids, ", "))))
ids, err := client.ListResourceIDsByGroup(context.TODO(), platform.ResourceGroupName)
if err != nil {
return append(allErrs, field.InternalError(fieldPath.Child("resourceGroupName"), fmt.Errorf("failed to list resources in the resource group: %w", err)))
}
if l := len(ids); l > 0 {
if len(ids) > 2 {
ids = ids[:2]
}
allErrs = append(allErrs, field.Invalid(fieldPath.Child("resourceGroupName"), platform.ResourceGroupName, fmt.Sprintf("resource group must be empty but it has %d resources like %s ...", l, strings.Join(ids, ", "))))
}
return allErrs
}
Expand Down
5 changes: 1 addition & 4 deletions pkg/asset/installconfig/azure/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,10 +698,7 @@ func Test_validateResourceGroup(t *testing.T) {
err: `^\Qplatform.azure.resourceGroupName: Invalid value: "valid-resource-group-conf-tags": resource group has conflicting tags kubernetes.io_cluster.test-cluster-12345\E$`,
}, {
groupName: "valid-resource-group-with-resources",
// ARO provisions Azure resources before resolving the asset graph,
// so there will always be resources in its resource group.
wantSkip: (&azure.Platform{}).IsARO(),
err: `^\Qplatform.azure.resourceGroupName: Invalid value: "valid-resource-group-with-resources": resource group must be empty but it has 3 resources like id1, id2 ...\E$`,
err: `^\Qplatform.azure.resourceGroupName: Invalid value: "valid-resource-group-with-resources": resource group must be empty but it has 3 resources like id1, id2 ...\E$`,
}}

mockCtrl := gomock.NewController(t)
Expand Down
5 changes: 0 additions & 5 deletions pkg/asset/installconfig/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,6 @@ func (a *InstallConfig) finish(ctx context.Context, filename string) error {
// that have already been checked by validation.ValidateInstallConfig().
func (a *InstallConfig) platformValidation(ctx context.Context) error {
if a.Config.Platform.Azure != nil {
if a.Config.Platform.Azure.IsARO() {
// ARO performs platform validation in the Resource Provider before
// the Installer is called
return nil
}
client, err := a.Azure.Client()
if err != nil {
return err
Expand Down
1 change: 0 additions & 1 deletion pkg/asset/manifests/cloudproviderconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ func (cpc *CloudProviderConfig) Generate(ctx context.Context, dependencies asset
VirtualNetworkName: vnet,
SubnetName: subnet,
ResourceManagerEndpoint: installConfig.Config.Azure.ARMEndpoint,
ARO: installConfig.Config.Azure.IsARO(),
}.JSON()
if err != nil {
return errors.Wrap(err, "could not create cloud provider config")
Expand Down
31 changes: 0 additions & 31 deletions pkg/asset/manifests/openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,37 +280,6 @@ func (o *Openshift) Generate(ctx context.Context, dependencies asset.Parents) er
assetData["99_baremetal-provisioning-config.yaml"] = applyTemplateData(baremetalConfig.Files()[0].Data, bmTemplateData)
}

if platform == azuretypes.Name && installConfig.Config.Azure.IsARO() && installConfig.Config.CredentialsMode != types.ManualCredentialsMode {
// config is used to created compatible secret to trigger azure cloud
// controller config merge behaviour
// https://github.com/openshift/origin/blob/90c050f5afb4c52ace82b15e126efe98fa798d88/vendor/k8s.io/legacy-cloud-providers/azure/azure_config.go#L83
session, err := installConfig.Azure.Session()
if err != nil {
return err
}
config := struct {
AADClientID string `json:"aadClientId" yaml:"aadClientId"`
AADClientSecret string `json:"aadClientSecret" yaml:"aadClientSecret"`
}{
AADClientID: session.Credentials.ClientID,
AADClientSecret: session.Credentials.ClientSecret,
}

b, err := yaml.Marshal(config)
if err != nil {
return err
}

azureCloudProviderSecret := &openshift.AzureCloudProviderSecret{}
dependencies.Get(azureCloudProviderSecret)
for _, f := range azureCloudProviderSecret.Files() {
name := strings.TrimSuffix(filepath.Base(f.Filename), ".template")
assetData[name] = applyTemplateData(f.Data, map[string]string{
"CloudConfig": string(b),
})
}
}

o.FileList = []*asset.File{}
for name, data := range assetData {
if len(data) == 0 {
Expand Down
5 changes: 0 additions & 5 deletions pkg/types/azure/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,6 @@ func (p *Platform) NetworkSecurityGroupName(infraID string) string {
return fmt.Sprintf("%s-nsg", infraID)
}

// IsARO returns true if ARO-only modifications are enabled
func (p *Platform) IsARO() bool {
return aro
}

// GetStorageAccountName takes an infraID and generates a
// storage account name, which can't be more than 24 characters.
func GetStorageAccountName(infraID string) string {
Expand Down
2 changes: 1 addition & 1 deletion pkg/types/azure/validation/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func ValidatePlatform(p *azure.Platform, publish types.PublishingStrategy, fldPa
if p.Region == "" {
allErrs = append(allErrs, field.Required(fldPath.Child("region"), "region should be set to one of the supported Azure regions"))
}
if !p.IsARO() && publish != types.InternalPublishingStrategy {
if publish != types.InternalPublishingStrategy {
if p.BaseDomainResourceGroupName == "" {
allErrs = append(allErrs, field.Required(fldPath.Child("baseDomainResourceGroupName"), "baseDomainResourceGroupName is the resource group name where the azure dns zone is deployed"))
}
Expand Down
18 changes: 0 additions & 18 deletions pkg/types/azure/validation/platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,13 @@ func TestValidatePlatform(t *testing.T) {
},
{
name: "invalid baseDomainResourceGroupName",
wantSkip: func(p *azure.Platform) bool {
// This test case doesn't apply to ARO
// so we want to skip it when run tests for ARO build
return p.IsARO()
},
platform: func() *azure.Platform {
p := validPlatform()
p.BaseDomainResourceGroupName = ""
return p
}(),
expected: `^test-path\.baseDomainResourceGroupName: Required value: baseDomainResourceGroupName is the resource group name where the azure dns zone is deployed$`,
},
{
name: "do not require baseDomainResourceGroupName on ARO",
wantSkip: func(p *azure.Platform) bool {
// This is a ARO-specific test case
// so want to skip when running non-ARO builds
return !p.IsARO()
},
platform: func() *azure.Platform {
p := validPlatform()
p.BaseDomainResourceGroupName = ""
return p
}(),
},
{
name: "minimal",
platform: validPlatform(),
Expand Down