Skip to content

Commit 50fa515

Browse files
committed
fix: prevent nodepool update when one is running
Signed-off-by: Carlos Salas <[email protected]>
1 parent da6987e commit 50fa515

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

cloud/services/container/nodepools/reconcile.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ func (s *Service) Reconcile(ctx context.Context) (ctrl.Result, error) {
147147
needUpdateConfig, nodePoolUpdateConfigRequest := s.checkDiffAndPrepareUpdateConfig(nodePool)
148148
if needUpdateConfig {
149149
log.Info("Node pool config update required", "request", nodePoolUpdateConfigRequest)
150+
// TODO: this is where it fails
151+
// do not trigger an update to node pools if there's one already in progress or the machine pool is being removed
152+
fmt.Println("###### GKEMachinePoolDeletingCondition: ", conditions.IsTrue(s.scope.GCPManagedMachinePool, infrav1exp.GKEMachinePoolDeletingCondition))
153+
if conditions.IsTrue(s.scope.GCPManagedMachinePool, infrav1exp.GKEMachinePoolUpdatingCondition) || conditions.IsTrue(s.scope.GCPManagedMachinePool, infrav1exp.GKEMachinePoolDeletingCondition) {
154+
log.Info("Another node pool config update operation is already in progress, requeuing")
155+
return ctrl.Result{RequeueAfter: reconciler.DefaultRetryTime}, nil
156+
}
150157
err = s.updateNodePoolConfig(ctx, nodePoolUpdateConfigRequest)
151158
if err != nil {
152159
return ctrl.Result{}, fmt.Errorf("node pool config update (either version/labels/taints/locations/image type/network tag/linux node config or all) failed: %s", err)

exp/controllers/gcpmanagedmachinepool_controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,12 @@ func (r *GCPManagedMachinePoolReconciler) reconcile(ctx context.Context, managed
333333
log.V(4).Info("Calling reconciler", "reconciler", name)
334334
res, err := r.Reconcile(ctx)
335335
if err != nil {
336+
// Ensure the ready condition is false, but do not overwrite an existing
337+
// error condition which might provide more details.
338+
if conditions.IsTrue(managedMachinePoolScope.GCPManagedMachinePool, infrav1exp.GKEMachinePoolReadyCondition) {
339+
conditions.MarkFalse(managedMachinePoolScope.GCPManagedMachinePool, infrav1exp.GKEMachinePoolReadyCondition, infrav1exp.GKEMachinePoolErrorReason, clusterv1.ConditionSeverityError, err.Error())
340+
}
341+
336342
var e *apierror.APIError
337343
if ok := errors.As(err, &e); ok {
338344
if e.GRPCStatus().Code() == codes.FailedPrecondition {
@@ -341,6 +347,7 @@ func (r *GCPManagedMachinePoolReconciler) reconcile(ctx context.Context, managed
341347
}
342348
}
343349
log.Error(err, "Reconcile error", "reconciler", name)
350+
344351
record.Warnf(managedMachinePoolScope.GCPManagedMachinePool, "GCPManagedMachinePoolReconcile", "Reconcile error - %v", err)
345352
return ctrl.Result{}, err
346353
}

0 commit comments

Comments
 (0)