Merge pull request #5866 from CharlesQQ/fix-metrics
fix(cluster): remove related metrics label when cluster is deleted
This commit is contained in:
commit
e75306d143
|
@ -135,6 +135,7 @@ func (c *ClusterStatusController) Reconcile(ctx context.Context, req controllerr
|
|||
c.GenericInformerManager.Stop(req.NamespacedName.Name)
|
||||
c.TypedInformerManager.Stop(req.NamespacedName.Name)
|
||||
c.clusterConditionCache.delete(req.NamespacedName.Name)
|
||||
metrics.CleanupMetricsForCluster(req.NamespacedName.Name)
|
||||
|
||||
// stop lease controller after the cluster is gone.
|
||||
// only used for clusters in Pull mode because no need to set up lease syncing for Push clusters.
|
||||
|
|
|
@ -135,6 +135,20 @@ func RecordClusterSyncStatusDuration(cluster *v1alpha1.Cluster, startTime time.T
|
|||
clusterSyncStatusDuration.WithLabelValues(cluster.Name).Observe(utilmetrics.DurationInSeconds(startTime))
|
||||
}
|
||||
|
||||
// CleanupMetricsForCluster removes the cluster status metrics after the cluster is deleted.
|
||||
func CleanupMetricsForCluster(clusterName string) {
|
||||
clusterReadyGauge.DeleteLabelValues(clusterName)
|
||||
clusterTotalNodeNumberGauge.DeleteLabelValues(clusterName)
|
||||
clusterReadyNodeNumberGauge.DeleteLabelValues(clusterName)
|
||||
clusterMemoryAllocatableGauge.DeleteLabelValues(clusterName)
|
||||
clusterCPUAllocatableGauge.DeleteLabelValues(clusterName)
|
||||
clusterPodAllocatableGauge.DeleteLabelValues(clusterName)
|
||||
clusterMemoryAllocatedGauge.DeleteLabelValues(clusterName)
|
||||
clusterCPUAllocatedGauge.DeleteLabelValues(clusterName)
|
||||
clusterPodAllocatedGauge.DeleteLabelValues(clusterName)
|
||||
clusterSyncStatusDuration.DeleteLabelValues(clusterName)
|
||||
}
|
||||
|
||||
// ClusterCollectors returns the collectors about clusters.
|
||||
func ClusterCollectors() []prometheus.Collector {
|
||||
return []prometheus.Collector{
|
||||
|
|
Loading…
Reference in New Issue