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

🌱 Avoid misleading error logs when deleting hbmh #1346

Merged
merged 1 commit into from
Jun 18, 2024
Merged
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
10 changes: 7 additions & 3 deletions controllers/hetznerbaremetalhost_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ func (r *HetznerBareMetalHostReconciler) Reconcile(ctx context.Context, req ctrl
Namespace: bmHost.Namespace,
Name: bmHost.Spec.Status.HetznerClusterRef,
}
if bmHost.Spec.Status.HetznerClusterRef == "" {
log.Info("bmHost.Spec.Status.HetznerClusterRef is empty. Looks like a stale cache read")
return reconcile.Result{Requeue: true}, nil
}
if err := r.Client.Get(ctx, hetznerClusterName, hetznerCluster); err != nil {
return reconcile.Result{}, fmt.Errorf("failed to get HetznerCluster: %w", err)
}
Expand Down Expand Up @@ -216,14 +220,14 @@ func (r *HetznerBareMetalHostReconciler) reconcileSelectedStates(ctx context.Con
// Handle StateDeleting
case infrav1.StateDeleting:
if !utils.StringInList(bmHost.Finalizers, infrav1.BareMetalHostFinalizer) {
return res, nil
return reconcile.Result{Requeue: true}, nil
}

bmHost.Finalizers = utils.FilterStringFromList(bmHost.Finalizers, infrav1.BareMetalHostFinalizer)
if err := r.Update(context.Background(), bmHost); err != nil {
if err := r.Update(ctx, bmHost); err != nil {
return reconcile.Result{}, fmt.Errorf("failed to remove finalizer: %w", err)
}
return res, nil
return reconcile.Result{Requeue: true}, nil
}
return res, nil
}
Expand Down
Loading