agent/consul: change provider wait from goto to a loop

This commit is contained in:
Mitchell Hashimoto 2018-05-08 21:32:47 -07:00
parent c8b65217c3
commit bc605a1576
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
1 changed files with 14 additions and 11 deletions

View File

@ -489,10 +489,10 @@ func (s *Server) createCAProvider(conf *structs.CAConfiguration) (connect.CAProv
func (s *Server) getCAProvider() connect.CAProvider {
retries := 0
RETRY_PROVIDER:
var result connect.CAProvider
for result == nil {
s.caProviderLock.RLock()
result := s.caProvider
result = s.caProvider
s.caProviderLock.RUnlock()
// In cases where an agent is started with managed proxies, we may ask
@ -501,7 +501,10 @@ RETRY_PROVIDER:
if result == nil && s.IsLeader() && retries < 10 {
retries++
time.Sleep(50 * time.Millisecond)
goto RETRY_PROVIDER
continue
}
break
}
return result