Skip to content

Commit e1ad4dc

Browse files
authored
Merge pull request #386 from tomasaschan/respect-errorresult-from-preflight
Respect ErrorResults returned from preflight checks
2 parents 187c2bb + 133be67 commit e1ad4dc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/patterns/declarative/reconciler.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ type ErrorResult struct {
9595
}
9696

9797
func (e *ErrorResult) Error() string {
98-
return e.Err.Error()
98+
if e.Err != nil {
99+
return e.Err.Error()
100+
}
101+
102+
return ""
99103
}
100104

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

184188
if r.options.status != nil {
185189
if err := r.options.status.Preflight(ctx, instance); err != nil {
190+
if errorResult, ok := err.(*ErrorResult); ok {
191+
// the user was specific about what they wanted to return; respect that
192+
return errorResult.Result, errorResult.Err
193+
}
194+
186195
log.Error(err, "preflight check failed, not reconciling")
187196
statusInfo.Err = err
188197
return result, statusInfo.Err

0 commit comments

Comments
 (0)