Skip to content

Commit

Permalink
Fixed destination metrics warning when re-linking (#11253)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alpeb authored Aug 16, 2023
1 parent cb5448b commit 4720714
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions controller/api/destination/watcher/cluster_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ func (cs *ClusterStore) removeCluster(clusterName string) {
return
}
r.watcher.removeHandlers()
r.watcher.k8sAPI.UnregisterGauges()
r.watcher.metadataAPI.UnregisterGauges()
close(r.stopCh)
delete(cs.store, clusterName)
cs.log.Infof("Removed cluster %s from ClusterStore", clusterName)
Expand Down
5 changes: 5 additions & 0 deletions controller/k8s/metadata_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ func (api *MetadataAPI) Sync(stopCh <-chan struct{}) {
waitForCacheSync(api.syncChecks)
}

// UnregisterGauges unregisters all the prometheus cache gauges associated to this API
func (api *MetadataAPI) UnregisterGauges() {
api.promGauges.unregister()
}

func (api *MetadataAPI) getLister(res APIResource) (cache.GenericLister, error) {
inf, ok := api.inf[res]
if !ok {
Expand Down

0 comments on commit 4720714

Please sign in to comment.