From f1877e3d99c197e4ecdc183ffdbbc0184e1a4fbd Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Tue, 20 Feb 2018 12:52:00 -0800 Subject: [PATCH] Need to revoke leadership to clean up in case there was a failure during leadership establishment --- nomad/leader.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nomad/leader.go b/nomad/leader.go index a8313e6a1bfe..748e292279a2 100644 --- a/nomad/leader.go +++ b/nomad/leader.go @@ -107,8 +107,16 @@ RECONCILE: if !establishedLeader { if err := s.establishLeadership(stopCh); err != nil { s.logger.Printf("[ERR] nomad: failed to establish leadership: %v", err) + + // Immediately revoke leadership since we didn't successfully + // establish leadership. + if err := s.revokeLeadership(); err != nil { + s.logger.Printf("[ERR] nomad: failed to revoke leadership: %v", err) + } + goto WAIT } + establishedLeader = true defer func() { if err := s.revokeLeadership(); err != nil {