Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent nodepool update when one is running #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cloud/services/container/nodepools/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (s *Service) Reconcile(ctx context.Context) (ctrl.Result, error) {
log.Info("Node pool config update required", "request", nodePoolUpdateConfigRequest)
err = s.updateNodePoolConfig(ctx, nodePoolUpdateConfigRequest)
if err != nil {
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)
return ctrl.Result{}, fmt.Errorf("node pool config update (either version/labels/taints/locations/image type/network tag/linux node config or all) failed: %w", err)
}
log.Info("Node pool config updating in progress")
s.scope.GCPManagedMachinePool.Status.Ready = true
Expand Down
10 changes: 9 additions & 1 deletion exp/controllers/gcpmanagedmachinepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,12 @@ func (r *GCPManagedMachinePoolReconciler) reconcile(ctx context.Context, managed
var e *apierror.APIError
if ok := errors.As(err, &e); ok {
if e.GRPCStatus().Code() == codes.FailedPrecondition {
log.Info("Cannot perform update when there's other operation, retry later", "reconciler", name)
log.Info("Cannot perform update while another operation is running, requeuing", "reconciler", name)
return ctrl.Result{RequeueAfter: reconciler.DefaultRetryTime}, nil
}
}
log.Error(err, "Reconcile error", "reconciler", name)

record.Warnf(managedMachinePoolScope.GCPManagedMachinePool, "GCPManagedMachinePoolReconcile", "Reconcile error - %v", err)
return ctrl.Result{}, err
}
Expand Down Expand Up @@ -369,6 +370,13 @@ func (r *GCPManagedMachinePoolReconciler) reconcileDelete(ctx context.Context, m
log.V(4).Info("Calling reconciler delete", "reconciler", name)
res, err := r.Delete(ctx)
if err != nil {
var e *apierror.APIError
if ok := errors.As(err, &e); ok {
if e.GRPCStatus().Code() == codes.FailedPrecondition {
log.Info("Cannot perform delete while another operation is running, requeuing", "reconciler", name)
return ctrl.Result{RequeueAfter: reconciler.DefaultRetryTime}, nil
}
}
log.Error(err, "Reconcile error", "reconciler", name)
record.Warnf(managedMachinePoolScope.GCPManagedMachinePool, "GCPManagedMachinePoolReconcile", "Reconcile error - %v", err)
return ctrl.Result{}, err
Expand Down