Skip to content

Commit 9640fe8

Browse files
authored
Merge pull request #6233 from helio/machinepool-empty-providerIDList
🐛 permit empty/not set providerIDList
2 parents 2466594 + 49345de commit 9640fe8

File tree

5 files changed

+423
-8
lines changed

5 files changed

+423
-8
lines changed

exp/internal/controllers/machinepool_controller_noderef.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (r *MachinePoolReconciler) reconcileNodeRefs(ctx context.Context, cluster *
6868
log = log.WithValues("cluster", cluster.Name)
6969

7070
// Check that the MachinePool has valid ProviderIDList.
71-
if len(mp.Spec.ProviderIDList) == 0 {
71+
if len(mp.Spec.ProviderIDList) == 0 && (mp.Spec.Replicas == nil || *mp.Spec.Replicas != 0) {
7272
log.V(2).Info("MachinePool doesn't have any ProviderIDs yet")
7373
return ctrl.Result{}, nil
7474
}

exp/internal/controllers/machinepool_controller_phases.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,8 @@ func (r *MachinePoolReconciler) reconcileInfrastructure(ctx context.Context, clu
274274

275275
var providerIDList []string
276276
// Get Spec.ProviderIDList from the infrastructure provider.
277-
if err := util.UnstructuredUnmarshalField(infraConfig, &providerIDList, "spec", "providerIDList"); err != nil {
277+
if err := util.UnstructuredUnmarshalField(infraConfig, &providerIDList, "spec", "providerIDList"); err != nil && !errors.Is(err, util.ErrUnstructuredFieldNotFound) {
278278
return ctrl.Result{}, errors.Wrapf(err, "failed to retrieve data from infrastructure provider for MachinePool %q in namespace %q", mp.Name, mp.Namespace)
279-
} else if len(providerIDList) == 0 {
280-
log.Info("Retrieved empty Spec.ProviderIDList from infrastructure provider")
281-
return ctrl.Result{RequeueAfter: externalReadyWait}, nil
282279
}
283280

284281
// Get and set Status.Replicas from the infrastructure provider.
@@ -287,8 +284,10 @@ func (r *MachinePoolReconciler) reconcileInfrastructure(ctx context.Context, clu
287284
if err != util.ErrUnstructuredFieldNotFound {
288285
return ctrl.Result{}, errors.Wrapf(err, "failed to retrieve replicas from infrastructure provider for MachinePool %q in namespace %q", mp.Name, mp.Namespace)
289286
}
290-
} else if mp.Status.Replicas == 0 {
291-
log.Info("Retrieved unset Status.Replicas from infrastructure provider")
287+
}
288+
289+
if len(providerIDList) == 0 && mp.Status.Replicas != 0 {
290+
log.Info("Retrieved empty Spec.ProviderIDList from infrastructure provider but Status.Replicas is not zero.", "replicas", mp.Status.Replicas)
292291
return ctrl.Result{RequeueAfter: externalReadyWait}, nil
293292
}
294293

0 commit comments

Comments
 (0)