agent/consul: change provider wait from goto to a loop
This commit is contained in:
parent
749f81373f
commit
54a1662da8
|
@ -489,19 +489,22 @@ func (s *Server) createCAProvider(conf *structs.CAConfiguration) (connect.CAProv
|
||||||
|
|
||||||
func (s *Server) getCAProvider() connect.CAProvider {
|
func (s *Server) getCAProvider() connect.CAProvider {
|
||||||
retries := 0
|
retries := 0
|
||||||
|
var result connect.CAProvider
|
||||||
|
for result == nil {
|
||||||
|
s.caProviderLock.RLock()
|
||||||
|
result = s.caProvider
|
||||||
|
s.caProviderLock.RUnlock()
|
||||||
|
|
||||||
RETRY_PROVIDER:
|
// In cases where an agent is started with managed proxies, we may ask
|
||||||
s.caProviderLock.RLock()
|
// for the provider before establishLeadership completes. If we're the
|
||||||
result := s.caProvider
|
// leader, then wait and get the provider again
|
||||||
s.caProviderLock.RUnlock()
|
if result == nil && s.IsLeader() && retries < 10 {
|
||||||
|
retries++
|
||||||
|
time.Sleep(50 * time.Millisecond)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// In cases where an agent is started with managed proxies, we may ask
|
break
|
||||||
// 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
|
return result
|
||||||
|
|
Loading…
Reference in New Issue