diff --git a/consul/leader.go b/consul/leader.go index f154d5857..e10e3fc54 100644 --- a/consul/leader.go +++ b/consul/leader.go @@ -93,8 +93,7 @@ RECONCILE: // Check if we need to handle initial leadership actions if !establishedLeader { if err := s.establishLeadership(); err != nil { - s.logger.Printf("[ERR] consul: failed to establish leadership: %v", - err) + s.logger.Printf("[ERR] consul: failed to establish leadership: %v", err) goto WAIT } establishedLeader = true @@ -124,19 +123,20 @@ WAIT: goto RECONCILE case member := <-reconcileCh: s.reconcileMember(member) - case <-s.reassertLeaderCh: - if establishedLeader { - if err := s.revokeLeadership(); err != nil { - s.logger.Printf("[ERR] consul: failed to revoke leadership: %v", err) - goto WAIT - } - if err := s.establishLeadership(); err != nil { - s.logger.Printf("[ERR] consul: failed to re-establish leadership: %v", err) - goto WAIT - } - } case index := <-s.tombstoneGC.ExpireCh(): go s.reapTombstones(index) + case <-s.reassertLeaderCh: + if !establishedLeader { + continue + } + if err := s.revokeLeadership(); err != nil { + s.logger.Printf("[ERR] consul: failed to revoke leadership: %v", err) + continue + } + if err := s.establishLeadership(); err != nil { + s.logger.Printf("[ERR] consul: failed to re-establish leadership: %v", err) + continue + } } } }