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

Fix the panic when there is no error in a reconciler #132

Merged
merged 1 commit into from
Apr 29, 2022
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
11 changes: 5 additions & 6 deletions controllers/operatorpipeline_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,20 @@ func (r *OperatorPipelineReconciler) Reconcile(ctx context.Context, req ctrl.Req
}

requeueResult := false
errResult := make([]error, 0, len(resourceReconcilers))
var errResult error = nil
pipeline := currentPipeline.DeepCopy()
for _, r := range resourceReconcilers {
requeue, err := r.Reconcile(ctx, pipeline)
if err != nil {
if err != nil && errResult == nil {
// Only capture the first error
log.Error(err, "requeuing with error")
requeueResult = true
errResult = append(errResult, err)
continue
errResult = err
}
requeueResult = requeueResult || requeue
}

// Just return the first error reported. It's the most likely issue that needs to be solved.
return ctrl.Result{Requeue: requeueResult}, errResult[0]
return ctrl.Result{Requeue: requeueResult}, errResult
}

// SetupWithManager sets up the controller with the Manager.
Expand Down