Skip to content

Commit

Permalink
feat(prometheus): delete prometheus_status_fail along with prometheus
Browse files Browse the repository at this point in the history
Signed-off-by: Feng Kun <[email protected]>
  • Loading branch information
kevinfeng authored and tke-robot committed Jul 15, 2020
1 parent 92a7721 commit 790f8d9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/monitor/controller/prometheus/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ func (c *Controller) processPrometheusDelete(ctx context.Context, cachedPromethe
log.Info("prometheus will be dropped", log.String("prome", key))

prometheus := cachedPrometheus.state
if prometheus != nil {
DeleteMetricPrometheusStatusFail(prometheus.Spec.TenantID, prometheus.Spec.ClusterName, prometheus.Name)
}
err := c.uninstallPrometheus(ctx, prometheus, true)
if err != nil {
log.Errorf("Prometheus uninstall fail: %v", err)
Expand Down
5 changes: 5 additions & 0 deletions pkg/monitor/controller/prometheus/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ func UpdateMetricPrometheusStatusFail(tenantID string, clusterName string, prome
prometheusStatusFail.With(labels).Set(0)
}
}

func DeleteMetricPrometheusStatusFail(tenantID string, clusterName string, prometheusName string) {
labels := map[string]string{"tenant_id": tenantID, "cluster_name": clusterName, "prometheus_name": prometheusName}
prometheusStatusFail.Delete(labels)
}
3 changes: 3 additions & 0 deletions pkg/platform/controller/addon/prometheus/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ func (c *Controller) processPrometheusDelete(ctx context.Context, cachedPromethe
log.Info("prometheus will be dropped", log.String("prome", key))

prometheus := cachedPrometheus.state
if prometheus != nil {
DeleteMetricPrometheusStatusFail(prometheus.Spec.TenantID, prometheus.Spec.ClusterName, prometheus.Name)
}
err := c.uninstallPrometheus(ctx, prometheus, true)
if err != nil {
log.Errorf("Prometheus uninstall fail: %v", err)
Expand Down
5 changes: 5 additions & 0 deletions pkg/platform/controller/addon/prometheus/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ func UpdateMetricPrometheusStatusFail(tenantID string, clusterName string, prome
prometheusStatusFail.With(labels).Set(0)
}
}

func DeleteMetricPrometheusStatusFail(tenantID string, clusterName string, prometheusName string) {
labels := map[string]string{"tenant_id": tenantID, "cluster_name": clusterName, "prometheus_name": prometheusName}
prometheusStatusFail.Delete(labels)
}

0 comments on commit 790f8d9

Please sign in to comment.