mirror of https://github.com/hashicorp/consul
agent/consul: retry reading provider a few times
parent
e54e69d11f
commit
9b3495dddb
|
@ -488,9 +488,23 @@ func (s *Server) createCAProvider(conf *structs.CAConfiguration) (connect.CAProv
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) getCAProvider() connect.CAProvider {
|
func (s *Server) getCAProvider() connect.CAProvider {
|
||||||
|
retries := 0
|
||||||
|
|
||||||
|
RETRY_PROVIDER:
|
||||||
s.caProviderLock.RLock()
|
s.caProviderLock.RLock()
|
||||||
defer s.caProviderLock.RUnlock()
|
result := s.caProvider
|
||||||
return s.caProvider
|
s.caProviderLock.RUnlock()
|
||||||
|
|
||||||
|
// In cases where an agent is started with managed proxies, we may ask
|
||||||
|
// for the provider before establishLeadership completes. If we're the
|
||||||
|
// leader, then wait and get the provider again
|
||||||
|
if result == nil && s.IsLeader() && retries < 10 {
|
||||||
|
retries++
|
||||||
|
time.Sleep(50 * time.Millisecond)
|
||||||
|
goto RETRY_PROVIDER
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) setCAProvider(newProvider connect.CAProvider) {
|
func (s *Server) setCAProvider(newProvider connect.CAProvider) {
|
||||||
|
|
Loading…
Reference in New Issue