From 57a98945f590eecd6a24d281032571f0a9475ea6 Mon Sep 17 00:00:00 2001 From: Kyle Havlovitz Date: Tue, 15 Sep 2020 12:28:58 -0700 Subject: [PATCH] Clean up CA shutdown logic and error --- agent/connect/ca/provider_vault.go | 2 +- agent/consul/leader_connect.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/agent/connect/ca/provider_vault.go b/agent/connect/ca/provider_vault.go index eb0d48e449..54afdf8ac6 100644 --- a/agent/connect/ca/provider_vault.go +++ b/agent/connect/ca/provider_vault.go @@ -126,7 +126,7 @@ func (v *VaultProvider) renewToken(ctx context.Context, renewer *vaultapi.Renewe case err := <-renewer.DoneCh(): if err != nil { - v.logger.Error(fmt.Sprintf("Error renewing token for Vault provider: %v", err)) + v.logger.Error("Error renewing token for Vault provider", "error", err) } // Renewer routine has finished, so start it again. diff --git a/agent/consul/leader_connect.go b/agent/consul/leader_connect.go index 0ae2353eb5..81bfce7555 100644 --- a/agent/consul/leader_connect.go +++ b/agent/consul/leader_connect.go @@ -566,20 +566,20 @@ func (s *Server) startConnectLeader() { // stopConnectLeader stops connect specific leader functions. func (s *Server) stopConnectLeader() { - s.caProviderReconfigurationLock.Lock() - defer s.caProviderReconfigurationLock.Unlock() + s.leaderRoutineManager.Stop(secondaryCARootWatchRoutineName) + s.leaderRoutineManager.Stop(intentionReplicationRoutineName) + s.leaderRoutineManager.Stop(caRootPruningRoutineName) + s.stopConnectLeaderEnterprise() // If the provider implements NeedsStop, we call Stop to perform any shutdown actions. + s.caProviderReconfigurationLock.Lock() + defer s.caProviderReconfigurationLock.Unlock() provider, _ := s.getCAProvider() if provider != nil { if needsStop, ok := provider.(ca.NeedsStop); ok { needsStop.Stop() } } - - s.leaderRoutineManager.Stop(secondaryCARootWatchRoutineName) - s.leaderRoutineManager.Stop(intentionReplicationRoutineName) - s.leaderRoutineManager.Stop(caRootPruningRoutineName) } func (s *Server) runCARootPruning(ctx context.Context) error {