Skip to content

Commit

Permalink
ARO: Remove ARO build flag from installer
Browse files Browse the repository at this point in the history
Removing the ARO build flag from the installer to achieve the goal
of moving ARO installs closer to the installer. Ideally, these
ARO specific changes to the installs/installer need to be done
either in the wrapper or hive.
  • Loading branch information
rna-afk committed Oct 23, 2024
1 parent 9422034 commit 67fb5b2
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 40 deletions.
19 changes: 8 additions & 11 deletions pkg/asset/installconfig/azure/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,18 +711,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: 0 additions & 5 deletions pkg/asset/installconfig/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,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
2 changes: 1 addition & 1 deletion pkg/asset/machines/azure/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func provider(platform *azure.Platform, mpool *azure.MachinePool, osImage string
}

managedIdentity := fmt.Sprintf("%s-identity", clusterID)
if platform.IsARO() || platform.CloudName == azure.StackCloud {
if platform.CloudName == azure.StackCloud {
managedIdentity = ""
}

Expand Down
5 changes: 0 additions & 5 deletions pkg/asset/manifests/azure/cloudproviderconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type CloudProviderConfig struct {
VirtualNetworkName string
SubnetName string
ResourceManagerEndpoint string
ARO bool
}

// JSON generates the cloud provider json config for the azure platform.
Expand Down Expand Up @@ -64,10 +63,6 @@ func (params CloudProviderConfig) JSON() (string, error) {
ExcludeMasterFromStandardLB: &excludeMasterFromStandardLB,
}

if params.ARO {
config.authConfig.UseManagedIdentityExtension = false
}

if params.CloudName == azure.StackCloud {
config.authConfig.ResourceManagerEndpoint = params.ResourceManagerEndpoint
config.authConfig.UseManagedIdentityExtension = false
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 @@ -151,7 +151,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
2 changes: 1 addition & 1 deletion pkg/asset/manifests/openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ 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 {
if 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
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 @@ -192,8 +192,3 @@ func (p *Platform) ComputeSubnetName(infraID string) string {
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
}
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
10 changes: 0 additions & 10 deletions pkg/types/azure/validation/platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ 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 = ""
Expand All @@ -72,11 +67,6 @@ func TestValidatePlatform(t *testing.T) {
},
{
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 = ""
Expand Down

0 comments on commit 67fb5b2

Please sign in to comment.