-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
With the built in prom. metrics provider, the k8s machinery doesnt deregister metrics when controllers are removed. So over time as things like clusters are created or removed the metrics are not cleaned up. The metrics types for the cache and queue are also very large. They can take ~1GB of RAM in a 100 cluster setup. Also, Rancher is not exposing these stats so they are unobservable.
- Loading branch information
Bill Maxwell
authored and
Denise
committed
Jul 27, 2018
1 parent
0953e9e
commit de9510b
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package controller | ||
|
||
import ( | ||
"k8s.io/client-go/tools/cache" | ||
"k8s.io/client-go/util/workqueue" | ||
) | ||
|
||
type noopMetric struct{} | ||
|
||
func (noopMetric) Inc() {} | ||
func (noopMetric) Dec() {} | ||
func (noopMetric) Observe(float64) {} | ||
func (noopMetric) Set(float64) {} | ||
|
||
type noopWorkqueueMetricsProvider struct{} | ||
|
||
func (noopWorkqueueMetricsProvider) NewDepthMetric(name string) workqueue.GaugeMetric { | ||
return noopMetric{} | ||
} | ||
|
||
func (noopWorkqueueMetricsProvider) NewAddsMetric(name string) workqueue.CounterMetric { | ||
return noopMetric{} | ||
} | ||
|
||
func (noopWorkqueueMetricsProvider) NewLatencyMetric(name string) workqueue.SummaryMetric { | ||
return noopMetric{} | ||
} | ||
|
||
func (noopWorkqueueMetricsProvider) NewWorkDurationMetric(name string) workqueue.SummaryMetric { | ||
return noopMetric{} | ||
} | ||
|
||
func (noopWorkqueueMetricsProvider) NewRetriesMetric(name string) workqueue.CounterMetric { | ||
return noopMetric{} | ||
} | ||
|
||
type noopCacheMetricsProvider struct{} | ||
|
||
func (noopCacheMetricsProvider) NewListsMetric(name string) cache.CounterMetric { return noopMetric{} } | ||
func (noopCacheMetricsProvider) NewListDurationMetric(name string) cache.SummaryMetric { | ||
return noopMetric{} | ||
} | ||
func (noopCacheMetricsProvider) NewItemsInListMetric(name string) cache.SummaryMetric { | ||
return noopMetric{} | ||
} | ||
func (noopCacheMetricsProvider) NewWatchesMetric(name string) cache.CounterMetric { return noopMetric{} } | ||
func (noopCacheMetricsProvider) NewShortWatchesMetric(name string) cache.CounterMetric { | ||
return noopMetric{} | ||
} | ||
func (noopCacheMetricsProvider) NewWatchDurationMetric(name string) cache.SummaryMetric { | ||
return noopMetric{} | ||
} | ||
func (noopCacheMetricsProvider) NewItemsInWatchMetric(name string) cache.SummaryMetric { | ||
return noopMetric{} | ||
} | ||
func (noopCacheMetricsProvider) NewLastResourceVersionMetric(name string) cache.GaugeMetric { | ||
return noopMetric{} | ||
} | ||
|
||
func DisableAllControllerMetrics() { | ||
DisableControllerReflectorMetrics() | ||
DisableControllerWorkqueuMetrics() | ||
} | ||
|
||
func DisableControllerWorkqueuMetrics() { | ||
workqueue.SetProvider(noopWorkqueueMetricsProvider{}) | ||
} | ||
|
||
func DisableControllerReflectorMetrics() { | ||
cache.SetReflectorMetricsProvider(noopCacheMetricsProvider{}) | ||
} |