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

🐛 Remove dataImage finalizer if BMH is missing #1974

Merged
merged 2 commits into from
Nov 28, 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
15 changes: 11 additions & 4 deletions controllers/metal3.io/dataimage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ import (
)

const (
dataImageRetryDelay = time.Second * 60
dataImageUpdateDelay = time.Second * 30
dataImageRetryDelay = time.Second * 60
dataImageUpdateDelay = time.Second * 30
dataImageUnmanagedRetryDelay = time.Second * 20
)

// DataImageReconciler reconciles a DataImage object.
Expand Down Expand Up @@ -111,7 +112,13 @@ func (r *DataImageReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
if err := r.Get(ctx, req.NamespacedName, bmh); err != nil {
// There might not be any BareMetalHost for the DataImage
if k8serrors.IsNotFound(err) {
reqLogger.Info("bareMetalHost not found for the dataImage")
reqLogger.Info("bareMetalHost not found for the dataImage, remove finalizer if it exists")
di.Finalizers = utils.FilterStringFromList(
di.Finalizers, metal3api.DataImageFinalizer)

if err := r.Update(ctx, di); err != nil {
return ctrl.Result{Requeue: true, RequeueAfter: dataImageRetryDelay}, fmt.Errorf("failed to update resource after remove finalizer, %w", err)
}
return ctrl.Result{}, nil
}

Expand All @@ -123,7 +130,7 @@ func (r *DataImageReconciler) Reconcile(ctx context.Context, req ctrl.Request) (

if hasDetachedAnnotation(bmh) {
reqLogger.Info("the host is detached, not running reconciler")
return ctrl.Result{Requeue: true, RequeueAfter: unmanagedRetryDelay}, nil
return ctrl.Result{Requeue: true, RequeueAfter: dataImageUnmanagedRetryDelay}, nil
}

// If the reconciliation is paused, requeue
Expand Down