Skip to content

Combine work-request errors into single reconcileError event. #385

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

Merged
merged 4 commits into from
Sep 19, 2024
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
6 changes: 4 additions & 2 deletions controllers/ocimachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ func (r *OCIMachineReconciler) recordErrorsOnFailedWorkRequest(ctx context.Conte
r.Recorder.Event(machine, corev1.EventTypeWarning, "ReconcileError", errors.Wrapf(err, "Failed to reconcile OCIMachine").Error())
return reconcile.Result{}, errors.Wrapf(err, "failed to list workrequests for OCI Machine %s/%s", machineScope.OCIMachine.Namespace, machineScope.OCIMachine.Name)
}
final_error := ""
for _, wrqst := range wresp.Items {
if wrqst.Status == "FAILED" {
logger.Info("Fetching work-request errors for the all failed work-requests for the instance")
Expand All @@ -316,12 +317,13 @@ func (r *OCIMachineReconciler) recordErrorsOnFailedWorkRequest(ctx context.Conte
r.Recorder.Event(machine, corev1.EventTypeWarning, "ReconcileError", errors.Wrapf(err, "Failed to normal reconcile OCIMachine").Error())
return reconcile.Result{}, errors.Wrapf(err, "failed to normal reconcile OCI Machine %s/%s", machineScope.OCIMachine.Namespace, machineScope.OCIMachine.Name)
}
final_error = fmt.Sprintf("%s Workrequest %s failed.", final_error, *wrqst.Id)
for _, wr_err := range wr_errs.Items {
r.Recorder.Eventf(machine, corev1.EventTypeWarning, "ReconcileError", *wr_err.Message)
final_error = fmt.Sprintf("%s %s", final_error, *wr_err.Message)
}
}
}
r.Recorder.Eventf(machine, corev1.EventTypeWarning, "ReconcileError", "Instance has invalid lifecycle state %s", instance.LifecycleState)
r.Recorder.Eventf(machine, corev1.EventTypeWarning, "ReconcileError", "%s. Instance has invalid lifecycle state %s", final_error, instance.LifecycleState)
return reconcile.Result{}, errors.New(fmt.Sprintf("instance has invalid lifecycle state %s", instance.LifecycleState))
}

Expand Down