Skip to content

Commit e01227b

Browse files
committed
Fixed destination metrics warning when re-linking
Similar to #11246, the destination controller was complaning above trying to register dupe metrics for the api cache gauges, when a given target cluster got re-linked. This change unregisters the gauges for the target cluster when said cluster is removed. Supersedes #11252
1 parent 57f44c4 commit e01227b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

controller/api/destination/watcher/cluster_store.go

+2
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ func (cs *ClusterStore) removeCluster(clusterName string) {
173173
return
174174
}
175175
r.watcher.removeHandlers()
176+
r.watcher.k8sAPI.UnregisterGauges()
177+
r.watcher.metadataAPI.UnregisterGauges()
176178
close(r.stopCh)
177179
delete(cs.store, clusterName)
178180
cs.log.Infof("Removed cluster %s from ClusterStore", clusterName)

controller/k8s/metadata_api.go

+5
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ func (api *MetadataAPI) Sync(stopCh <-chan struct{}) {
100100
waitForCacheSync(api.syncChecks)
101101
}
102102

103+
// UnregisterGauges unregisters all the prometheus cache gauges associated to this API
104+
func (api *MetadataAPI) UnregisterGauges() {
105+
api.promGauges.unregister()
106+
}
107+
103108
func (api *MetadataAPI) getLister(res APIResource) (cache.GenericLister, error) {
104109
inf, ok := api.inf[res]
105110
if !ok {

0 commit comments

Comments
 (0)