From 7dae65cd56e27c15cf705269c2ce3c5858aa885d Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Mon, 21 Jun 2021 19:35:38 -0400 Subject: [PATCH] ca: remove unused method and small refactor to getCAProvider so that GoLand is less confused about what it is doing. Previously it was reporting that the for condition was always true, which was not the case. --- agent/consul/leader_connect_ca.go | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/agent/consul/leader_connect_ca.go b/agent/consul/leader_connect_ca.go index 67d24d155f..74d89be769 100644 --- a/agent/consul/leader_connect_ca.go +++ b/agent/consul/leader_connect_ca.go @@ -100,13 +100,6 @@ func NewCAManager(delegate caServerDelegate, leaderRoutineManager *routine.Manag } } -func (c *CAManager) reset() { - c.state = caStateUninitialized - c.primaryRoots = structs.IndexedCARoots{} - c.actingSecondaryCA = false - c.setCAProvider(nil, nil) -} - // setState attempts to update the CA state to the given state. // Valid state transitions are: // @@ -229,12 +222,10 @@ func parseCARoot(pemValue, provider, clusterID string) (*structs.CARoot, error) // as well as the active root. func (c *CAManager) getCAProvider() (ca.Provider, *structs.CARoot) { retries := 0 - var result ca.Provider - var resultRoot *structs.CARoot - for result == nil { + for { c.providerLock.RLock() - result = c.provider - resultRoot = c.providerRoot + result := c.provider + resultRoot := c.providerRoot c.providerLock.RUnlock() // In cases where an agent is started with managed proxies, we may ask @@ -246,10 +237,8 @@ func (c *CAManager) getCAProvider() (ca.Provider, *structs.CARoot) { continue } - break + return result, resultRoot } - - return result, resultRoot } // setCAProvider is being called while holding the stateLock