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 3, 2018
1 parent 9d3345d commit 928bc7d
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 @@ -192,6 +192,13 @@ func (cm *controllerManager) serveMetrics(stop <-chan struct{}) {
}

func (cm *controllerManager) Start(stop <-chan struct{}) error {
// 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(stop)
}

if cm.resourceLock != nil {
err := cm.startLeaderElection(stop)
if err != nil {
Expand Down Expand Up @@ -227,11 +234,6 @@ func (cm *controllerManager) start(stop <-chan struct{}) {
}
}()

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

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

0 comments on commit 928bc7d

Please sign in to comment.