Skip to content

Commit

Permalink
Serve metrics even if not leader
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelSpeed committed Nov 16, 2018
1 parent 0f0740d commit e1ceb2f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/manager/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ func (cm *controllerManager) Start(stop <-chan struct{}) error {
// join the passed-in stop channel as an upstream feeding into cm.internalStopper
defer close(cm.internalStopper)

// Metrics should be served whether the controller is leader or not.
// (If we don't serve metrics for non-leaders, prometheus will still scrape
// the pod but will get a connection refused)
if cm.metricsListener != nil {
go cm.serveMetrics(cm.internalStop)
}

if cm.resourceLock != nil {
err := cm.startLeaderElection()
if err != nil {
Expand Down Expand Up @@ -237,11 +244,6 @@ func (cm *controllerManager) start() {
}
}()

// Start the metrics server
if cm.metricsListener != nil {
go cm.serveMetrics(cm.internalStop)
}

// Wait for the caches to sync.
// TODO(community): Check the return value and write a test
cm.cache.WaitForCacheSync(cm.internalStop)
Expand Down

0 comments on commit e1ceb2f

Please sign in to comment.