Skip to content

Commit

Permalink
Merge pull request #31 from lilwan/bug/fix
Browse files Browse the repository at this point in the history
#28 Reset retryCount and error description for Ready case
  • Loading branch information
lilwan authored Sep 29, 2021
2 parents 28d280b + bb7bf30 commit fc52f1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion controllers/alertsconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (r *AlertsConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request

alertStatus := alertHashMap[alertName]
alertStatus.LastChangeChecksum = reqChecksum
// Update the individual alert status state to be ready
// Update the individual alert status state to be ready and cleanup the error message
alertStatus.State = alertmanagerv1alpha1.Ready
if err := r.CommonClient.PatchWfAlertAndAlertsConfigStatus(ctx, alertmanagerv1alpha1.Ready, &wfAlert, &alertsConfig, alertStatus); err != nil {
log.Error(err, "unable to patch wfalert and alertsconfig status objects")
Expand Down Expand Up @@ -221,6 +221,7 @@ func (r *AlertsConfigReconciler) HandleIndividalAlertConfigRemoval(ctx context.C
tempStatusConfig := updatedAlertsConfig.Status.AlertsStatus
tempState := updatedAlertsConfig.Status.State
var toBeDeleted []string
areAlertsReady := true

for key, status := range updatedAlertsConfig.Status.AlertsStatus {
// This is for sure delete use case
Expand All @@ -235,6 +236,7 @@ func (r *AlertsConfigReconciler) HandleIndividalAlertConfigRemoval(ctx context.C
} else {
if status.State == alertmanagerv1alpha1.Error {
tempState = alertmanagerv1alpha1.Error
areAlertsReady = false
}
}
}
Expand All @@ -245,6 +247,10 @@ func (r *AlertsConfigReconciler) HandleIndividalAlertConfigRemoval(ctx context.C
// update the count
updatedAlertsConfig.Status.AlertsCount = len(updatedAlertsConfig.Spec.Alerts)
updatedAlertsConfig.Status.AlertsStatus = tempStatusConfig
// reset the retry count if all the alerts are Ready
if areAlertsReady {
updatedAlertsConfig.Status.RetryCount = 0
}
// update the status
return r.CommonClient.UpdateStatus(ctx, &updatedAlertsConfig, tempState, errRequeueTime)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.16.0
golang.org/x/mod v0.5.1 // indirect
golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7 // indirect
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 // indirect
golang.org/x/tools v0.1.6 // indirect
k8s.io/api v0.19.2
k8s.io/apimachinery v0.19.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,8 @@ golang.org/x/sys v0.0.0-20210909193231-528a39cd75f3 h1:3Ad41xy2WCESpufXwgs7NpDSu
golang.org/x/sys v0.0.0-20210909193231-528a39cd75f3/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7 h1:c20P3CcPbopVp2f7099WLOqSNKURf30Z0uq66HpijZY=
golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 h1:foEbQz/B0Oz6YIqu/69kfXPYeFQAuuMYFkjaqXzl5Wo=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down

0 comments on commit fc52f1e

Please sign in to comment.