Skip to content

Commit d634751

Browse files
sindhusri16joekr
authored andcommitted
Combine work-request errors into single reconcileError event. (#385)
* changed wrClient to nlb and lb client to fetch core work-requests. * combine error events into single message * concatention changes
1 parent 031cf13 commit d634751

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

controllers/ocimachine_controller.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ func (r *OCIMachineReconciler) recordErrorsOnFailedWorkRequest(ctx context.Conte
305305
r.Recorder.Event(machine, corev1.EventTypeWarning, "ReconcileError", errors.Wrapf(err, "Failed to reconcile OCIMachine").Error())
306306
return reconcile.Result{}, errors.Wrapf(err, "failed to list workrequests for OCI Machine %s/%s", machineScope.OCIMachine.Namespace, machineScope.OCIMachine.Name)
307307
}
308+
final_error := ""
308309
for _, wrqst := range wresp.Items {
309310
if wrqst.Status == "FAILED" {
310311
logger.Info("Fetching work-request errors for the all failed work-requests for the instance")
@@ -316,12 +317,13 @@ func (r *OCIMachineReconciler) recordErrorsOnFailedWorkRequest(ctx context.Conte
316317
r.Recorder.Event(machine, corev1.EventTypeWarning, "ReconcileError", errors.Wrapf(err, "Failed to normal reconcile OCIMachine").Error())
317318
return reconcile.Result{}, errors.Wrapf(err, "failed to normal reconcile OCI Machine %s/%s", machineScope.OCIMachine.Namespace, machineScope.OCIMachine.Name)
318319
}
320+
final_error = fmt.Sprintf("%s Workrequest %s failed.", final_error, *wrqst.Id)
319321
for _, wr_err := range wr_errs.Items {
320-
r.Recorder.Eventf(machine, corev1.EventTypeWarning, "ReconcileError", *wr_err.Message)
322+
final_error = fmt.Sprintf("%s %s", final_error, *wr_err.Message)
321323
}
322324
}
323325
}
324-
r.Recorder.Eventf(machine, corev1.EventTypeWarning, "ReconcileError", "Instance has invalid lifecycle state %s", instance.LifecycleState)
326+
r.Recorder.Eventf(machine, corev1.EventTypeWarning, "ReconcileError", "%s. Instance has invalid lifecycle state %s", final_error, instance.LifecycleState)
325327
return reconcile.Result{}, errors.New(fmt.Sprintf("instance has invalid lifecycle state %s", instance.LifecycleState))
326328
}
327329

0 commit comments

Comments
 (0)