Skip to content

Commit

Permalink
skip parent lookup since it is buggy and not needed by NR (#16)
Browse files Browse the repository at this point in the history
* skip parent lookup since it is buggy and not needed by NR

* fmt

---------

Co-authored-by: Craig Fullen <[email protected]>
  • Loading branch information
cfullen11 and cfullen authored Jun 14, 2023
1 parent 7428f35 commit d6b7ade
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions exp/api/v1beta1/azuremachinepool_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,21 @@ func (amp *AzureMachinePool) SetDefaults(client client.Client) error {
errs = append(errs, errors.Wrap(err, "failed to set default SSH public key"))
}

machinePool, err := azureutil.FindParentMachinePoolWithRetry(amp.Name, client, 5)
if err != nil {
errs = append(errs, errors.Wrap(err, "failed to find parent machine pool"))
}
// the lookups could fail due to mp not being ready. NR will always match cluster name and namespace to the amp namespace.
skipParentLookup := true
ownerAzureClusterName := amp.Namespace
ownerAzureClusterNamespace := amp.Namespace

ownerAzureClusterName, ownerAzureClusterNamespace, err := infrav1.GetOwnerAzureClusterNameAndNamespace(client, machinePool.Spec.ClusterName, machinePool.Namespace, 5)
if err != nil {
errs = append(errs, errors.Wrap(err, "failed to get owner cluster"))
if !skipParentLookup {
machinePool, err := azureutil.FindParentMachinePoolWithRetry(amp.Name, client, 5)
if err != nil {
errs = append(errs, errors.Wrap(err, "failed to find parent machine pool"))
}

ownerAzureClusterName, ownerAzureClusterNamespace, err = infrav1.GetOwnerAzureClusterNameAndNamespace(client, machinePool.Spec.ClusterName, machinePool.Namespace, 5)
if err != nil {
errs = append(errs, errors.Wrap(err, "failed to get owner cluster"))
}
}

subscriptionID, err := infrav1.GetSubscriptionID(client, ownerAzureClusterName, ownerAzureClusterNamespace, 5)
Expand Down

0 comments on commit d6b7ade

Please sign in to comment.