Skip to content

Commit

Permalink
Combine work-request errors into single reconcileError event. (#385)
Browse files Browse the repository at this point in the history
* changed wrClient to nlb and lb client to fetch core work-requests.

* combine error events into single message

* concatention changes
  • Loading branch information
sindhusri16 authored and joekr committed Sep 19, 2024
1 parent 031cf13 commit d634751
Showing 1 changed file with 4 additions and 2 deletions.
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

0 comments on commit d634751

Please sign in to comment.