Skip to content

Commit

Permalink
Merge pull request #386 from tomasaschan/respect-errorresult-from-pre…
Browse files Browse the repository at this point in the history
…flight

Respect ErrorResults returned from preflight checks
  • Loading branch information
k8s-ci-robot committed Jun 8, 2024
2 parents 187c2bb + 133be67 commit e1ad4dc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/patterns/declarative/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ type ErrorResult struct {
}

func (e *ErrorResult) Error() string {
return e.Err.Error()
if e.Err != nil {
return e.Err.Error()
}

return ""
}

// For mocking
Expand Down Expand Up @@ -183,6 +187,11 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (

if r.options.status != nil {
if err := r.options.status.Preflight(ctx, instance); err != nil {
if errorResult, ok := err.(*ErrorResult); ok {
// the user was specific about what they wanted to return; respect that
return errorResult.Result, errorResult.Err
}

log.Error(err, "preflight check failed, not reconciling")
statusInfo.Err = err
return result, statusInfo.Err
Expand Down

0 comments on commit e1ad4dc

Please sign in to comment.