Skip to content

Commit

Permalink
Early error when failing to get alert status from coralogix (#41)
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Silva Sens <[email protected]>
  • Loading branch information
ArthurSens authored Aug 3, 2023
1 parent 9f5fe52 commit e9b8fb6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions controllers/alphacontrollers/alert_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ func (r *AlertReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
notFount = true
} else if err == nil {
actualState, flattenErr = flattenAlert(ctx, getAlertResp.GetAlert(), alertCRD.Spec)
if flattenErr != nil {
log.Error(flattenErr, "Received an error while flattened Alert")
return ctrl.Result{RequeueAfter: defaultErrRequeuePeriod}, flattenErr
}
}

if notFount {
Expand Down Expand Up @@ -193,6 +197,10 @@ func (r *AlertReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
}

actualState, flattenErr = flattenAlert(ctx, createAlertResp.GetAlert(), alertCRD.Spec)
if flattenErr != nil {
log.Error(flattenErr, "Received an error while flattened Alert")
return ctrl.Result{RequeueAfter: defaultErrRequeuePeriod}, flattenErr
}
alertCRD.Status = *actualState
if err := r.Status().Update(ctx, alertCRD); err != nil {
log.Error(err, "Error on updating alert status", "Name", alertCRD.Name, "Namespace", alertCRD.Namespace)
Expand Down Expand Up @@ -225,11 +233,6 @@ func (r *AlertReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
log.V(1).Info("Alert was updated", "alert", jstr)
}

if flattenErr != nil {
log.Error(err, "Received an error while flattened Alert")
return ctrl.Result{RequeueAfter: defaultErrRequeuePeriod}, err
}

return ctrl.Result{RequeueAfter: defaultRequeuePeriod}, nil
}

Expand Down

0 comments on commit e9b8fb6

Please sign in to comment.