Skip to content

Commit

Permalink
Merge pull request metal3-io#2083 from metal3-io-bot/cherry-pick-1792…
Browse files Browse the repository at this point in the history
…-to-release-0.8

🌱 Added Error message when reconciling loop is triggered more than once
  • Loading branch information
metal3-io-bot authored Nov 25, 2024
2 parents 83b6e74 + 16e7624 commit 1098d95
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
14 changes: 9 additions & 5 deletions controllers/metal3.io/baremetalhost_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const (
subResourceNotReadyRetryDelay = time.Second * 60
clarifySoftPoweroffFailure = "Continuing with hard poweroff after soft poweroff fails. More details: "
hardwareDataFinalizer = metal3api.BareMetalHostFinalizer + "/hardwareData"
NotReady = "Not ready"
)

// BareMetalHostReconciler reconciles a BareMetalHost object.
Expand Down Expand Up @@ -212,12 +213,15 @@ func (r *BareMetalHostReconciler) Reconcile(ctx context.Context, request ctrl.Re
}

ready, err := prov.TryInit()
if err != nil {
return ctrl.Result{}, errors.Wrap(err, "failed to check services availability")
}
if !ready {
if err != nil || !ready {
var msg string
if err == nil {
msg = NotReady
} else {
msg = err.Error()
}
provisionerNotReady.Inc()
reqLogger.Info("provisioner is not ready", "RequeueAfter:", provisionerNotReadyRetryDelay)
reqLogger.Info("provisioner is not ready", "Error:", msg, "RequeueAfter:", provisionerNotReadyRetryDelay)
return ctrl.Result{Requeue: true, RequeueAfter: provisionerNotReadyRetryDelay}, nil
}

Expand Down
28 changes: 16 additions & 12 deletions controllers/metal3.io/bmceventsubscription_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ func (r *BMCEventSubscriptionReconciler) Reconcile(ctx context.Context, request

prov, ready, err := r.getProvisioner(ctx, request, host)

if err != nil {
return ctrl.Result{}, errors.Wrap(err, "failed to create provisioner")
}

if !ready {
reqLogger.Info("provisioner is not ready", "RequeueAfter:", provisionerNotReadyRetryDelay)
if err != nil || !ready {
var msg string
if err == nil {
msg = NotReady
} else {
msg = err.Error()
}
reqLogger.Info("provisioner is not ready", "Error:", msg, "RequeueAfter:", provisionerNotReadyRetryDelay)
return ctrl.Result{RequeueAfter: provisionerNotReadyRetryDelay}, nil
}

Expand Down Expand Up @@ -220,12 +222,14 @@ func (r *BMCEventSubscriptionReconciler) getProvisioner(ctx context.Context, req
}

ready, err = prov.TryInit()
if err != nil {
return prov, ready, errors.Wrap(err, "failed to check services availability")
}

if !ready {
reqLogger.Info("provisioner is not ready", "RequeueAfter:", provisionerNotReadyRetryDelay)
if err != nil || !ready {
var msg string
if err == nil {
msg = NotReady
} else {
msg = err.Error()
}
reqLogger.Info("provisioner is not ready", "Error:", msg, "RequeueAfter:", provisionerNotReadyRetryDelay)
return prov, ready, nil
}

Expand Down

0 comments on commit 1098d95

Please sign in to comment.