Skip to content

Commit

Permalink
Added Error message when reconciling loop is triggered more than once
Browse files Browse the repository at this point in the history
Signed-off-by: “babugeet <abhinandhbg@gmail.com>”
  • Loading branch information
babugeet committed Jun 20, 2024
1 parent 7767a23 commit 877d9f7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
13 changes: 8 additions & 5 deletions controllers/metal3.io/baremetalhost_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,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 = "Not ready"

Check failure on line 218 in controllers/metal3.io/baremetalhost_controller.go

View workflow job for this annotation

GitHub Actions / golangci-lint / lint

string `Not ready` has 4 occurrences, make it a constant (goconst)
} 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 = "Not ready"
} 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 = "Not ready"
} else {
msg = err.Error()
}
reqLogger.Info("provisioner is not ready", "Error", msg, "RequeueAfter:", provisionerNotReadyRetryDelay)
return prov, ready, nil
}

Expand Down

0 comments on commit 877d9f7

Please # to comment.