Skip to content

Commit

Permalink
controller: delete reconcile metric for orphaned PromRule in advance
Browse files Browse the repository at this point in the history
  • Loading branch information
talal committed Sep 16, 2020
1 parent 6e06044 commit 7b8df51
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.6.1] - 2020-09-16

### Changed

- Delete the reconcile time metric for orphaned `PrometheusRule` in advance,
regardless of the cleanup error status.

### Fixed

- Use a single loop for controller worker.
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ func (c *Controller) cleanUpOrphanedAbsentAlertsCluster() error {

aPR := &absentPrometheusRule{PrometheusRule: pr}
for n := range cleanup {
c.metrics.SuccessfulPrometheusRuleReconcileTime.DeleteLabelValues(namespace, n)
if err := c.cleanUpOrphanedAbsentAlerts(n, aPR); err != nil {
return err
}
c.metrics.SuccessfulPrometheusRuleReconcileTime.DeleteLabelValues(namespace, n)
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions internal/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,8 @@ func (c *Controller) syncHandler(key string) error {
// The resource may no longer exist, in which case we clean up any
// orphaned absent alerts.
c.logger.Debug("msg", "PrometheusRule no longer exists", "key", key)
c.metrics.SuccessfulPrometheusRuleReconcileTime.DeleteLabelValues(namespace, name)
err = c.cleanUpOrphanedAbsentAlertsNamespace(name, namespace)
if err == nil {
c.metrics.SuccessfulPrometheusRuleReconcileTime.DeleteLabelValues(namespace, name)
}
default:
// Requeue object for later processing.
return err
Expand Down

0 comments on commit 7b8df51

Please sign in to comment.