Skip to content

Commit

Permalink
OCM-3303 | fix: a regression caused the external ID not to be forwarded
Browse files Browse the repository at this point in the history
  • Loading branch information
gdbranco committed Aug 6, 2024
1 parent 5659a79 commit e980f77
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions cmd/create/cluster/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,9 @@ func run(cmd *cobra.Command, _ []string) {
externalAuthProvidersEnabled := args.externalAuthProvidersEnabled
if externalAuthProvidersEnabled {
if !isHostedCP {
r.Reporter.Errorf("External authentication configuration is only supported for a Hosted Control Plane cluster.")
r.Reporter.Errorf(
"External authentication configuration is only supported for a Hosted Control Plane cluster.",
)
os.Exit(1)
}
}
Expand Down Expand Up @@ -2372,7 +2374,7 @@ func run(cmd *cobra.Command, _ []string) {
// Compute node instance type:
computeMachineType := args.computeMachineType
computeMachineTypeList, err := r.OCMClient.GetAvailableMachineTypesInRegion(region, availabilityZones, roleARN,
awsClient)
awsClient, externalID)
if err != nil {
r.Reporter.Errorf(fmt.Sprintf("%s", err))
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion cmd/list/instancetypes/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func runWithRuntime(r *rosa.Runtime, cmd *cobra.Command) error {
}

availableMachineTypes, err := r.OCMClient.GetAvailableMachineTypesInRegion(arguments.GetRegion(),
availabilityZones, roleArn, r.AWSClient)
availabilityZones, roleArn, r.AWSClient, args.externalId)
if err != nil {
return fmt.Errorf("Failed to fetch instance types: %v", err)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/machinepool/machinepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ func (m *machinePool) AddMachinePool(cmd *cobra.Command, clusterKey string, clus
availabilityZonesFilter,
cluster.AWS().STS().RoleARN(),
r.AWSClient,
cluster.AWS().STS().ExternalID(),
)
if err != nil {
return fmt.Errorf(fmt.Sprintf("%s", err))
Expand Down Expand Up @@ -811,7 +812,7 @@ func (m *machinePool) AddNodePool(cmd *cobra.Command, clusterKey string, cluster
}

instanceTypeList, err := r.OCMClient.GetAvailableMachineTypesInRegion(cluster.Region().ID(),
availabilityZonesFilter, cluster.AWS().STS().RoleARN(), r.AWSClient)
availabilityZonesFilter, cluster.AWS().STS().RoleARN(), r.AWSClient, cluster.AWS().STS().ExternalID())
if err != nil {
return fmt.Errorf(fmt.Sprintf("%s", err))
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/ocm/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ func (mt MachineType) HasQuota(multiAZ bool) bool {
// The function triggers the 'api/clusters_mgmt/v1/aws_inquiries/machine_types'
// and passes a role ARN for STS clusters or access keys for non-STS clusters.
func (c *Client) GetAvailableMachineTypesInRegion(region string, availabilityZones []string, roleARN string,
awsClient aws.Client) (MachineTypeList, error) {
cloudProviderDataBuilder, err := c.createCloudProviderDataBuilder(roleARN, awsClient, "")
awsClient aws.Client, externalId string) (MachineTypeList, error) {
cloudProviderDataBuilder, err := c.createCloudProviderDataBuilder(roleARN, awsClient, externalId)
if err != nil {
return MachineTypeList{}, err
}
Expand Down Expand Up @@ -234,7 +234,8 @@ func (mtl *MachineTypeList) UpdateAvailableQuota(quotaCosts *amsv1.QuotaCostList
}
quotaCosts.Each(func(quotaCost *amsv1.QuotaCost) bool {
for _, relatedResource := range quotaCost.RelatedResources() {
if machineType.MachineType.GenericName() == relatedResource.ResourceName() && isCompatible(relatedResource) {
if machineType.MachineType.GenericName() == relatedResource.ResourceName() &&
isCompatible(relatedResource) {
availableQuota := (quotaCost.Allowed() - quotaCost.Consumed()) / relatedResource.Cost()
machineType.Available = availableQuota > 1
machineType.availableQuota = availableQuota
Expand Down

0 comments on commit e980f77

Please sign in to comment.