fix(cluster): remove related metrics label after cluster is deleted
Signed-off-by: chang.qiangqiang <chang.qiangqiang@immomo.com>
This commit is contained in:
parent
3d25407e3f
commit
58887bc078
|
@ -135,6 +135,7 @@ func (c *ClusterStatusController) Reconcile(ctx context.Context, req controllerr
|
||||||
c.GenericInformerManager.Stop(req.NamespacedName.Name)
|
c.GenericInformerManager.Stop(req.NamespacedName.Name)
|
||||||
c.TypedInformerManager.Stop(req.NamespacedName.Name)
|
c.TypedInformerManager.Stop(req.NamespacedName.Name)
|
||||||
c.clusterConditionCache.delete(req.NamespacedName.Name)
|
c.clusterConditionCache.delete(req.NamespacedName.Name)
|
||||||
|
metrics.CleanupMetricsForCluster(req.NamespacedName.Name)
|
||||||
|
|
||||||
// stop lease controller after the cluster is gone.
|
// 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.
|
// 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))
|
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.
|
// ClusterCollectors returns the collectors about clusters.
|
||||||
func ClusterCollectors() []prometheus.Collector {
|
func ClusterCollectors() []prometheus.Collector {
|
||||||
return []prometheus.Collector{
|
return []prometheus.Collector{
|
||||||
|
|
Loading…
Reference in New Issue