mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
nomad: disable one worker when leader
This commit is contained in:
@@ -98,6 +98,12 @@ WAIT:
|
||||
// previously inflight transactions have been commited and that our
|
||||
// state is up-to-date.
|
||||
func (s *Server) establishLeadership(stopCh chan struct{}) error {
|
||||
// If we have multiple workers, disable one to free processing
|
||||
// for the plan queue and evaluation broker
|
||||
if len(s.workers) > 1 {
|
||||
s.workers[0].SetPause(true)
|
||||
}
|
||||
|
||||
// Enable the plan queue, since we are now the leader
|
||||
s.planQueue.SetEnabled(true)
|
||||
|
||||
@@ -243,6 +249,11 @@ func (s *Server) revokeLeadership() error {
|
||||
s.logger.Printf("[ERR] nomad: clearing heartbeat timers failed: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
// Unpause our worker if we paused previously
|
||||
if len(s.workers) > 1 {
|
||||
s.workers[0].SetPause(false)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user