mirror of https://github.com/status-im/consul.git
Exit before starting the vip check routine if possible
This commit is contained in:
parent
04ef1c3fa0
commit
ecbd3eb2a6
|
@ -125,10 +125,14 @@ func (s *Server) pruneCARoots() error {
|
|||
|
||||
func (s *Server) runVirtualIPVersionCheck(ctx context.Context) error {
|
||||
// Return early if the flag is already set.
|
||||
_, err := s.setVirtualIPVersionFlag()
|
||||
done, err := s.setVirtualIPVersionFlag()
|
||||
if err != nil {
|
||||
s.loggers.Named(logging.Connect).Warn("error enabling virtual IPs", "error", err)
|
||||
}
|
||||
if done {
|
||||
s.leaderRoutineManager.Stop(virtualIPCheckRoutineName)
|
||||
return nil
|
||||
}
|
||||
|
||||
ticker := time.NewTicker(virtualIPVersionCheckInterval)
|
||||
defer ticker.Stop()
|
||||
|
@ -138,12 +142,12 @@ func (s *Server) runVirtualIPVersionCheck(ctx context.Context) error {
|
|||
case <-ctx.Done():
|
||||
return nil
|
||||
case <-ticker.C:
|
||||
ok, err := s.setVirtualIPVersionFlag()
|
||||
done, err := s.setVirtualIPVersionFlag()
|
||||
if err != nil {
|
||||
s.loggers.Named(logging.Connect).Warn("error enabling virtual IPs", "error", err)
|
||||
continue
|
||||
}
|
||||
if ok {
|
||||
if done {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2126,7 +2126,9 @@ func TestLeader_EnableVirtualIPs(t *testing.T) {
|
|||
t.Skip("too slow for testing.Short")
|
||||
}
|
||||
|
||||
orig := virtualIPVersionCheckInterval
|
||||
virtualIPVersionCheckInterval = 50 * time.Millisecond
|
||||
t.Cleanup(func() { virtualIPVersionCheckInterval = orig })
|
||||
|
||||
conf := func(c *Config) {
|
||||
c.Bootstrap = false
|
||||
|
|
Loading…
Reference in New Issue