ca-manager: move provider shutdown into CAManager

Reducing the coupling between Server and CAManager
This commit is contained in:
Daniel Nephin 2021-06-21 17:20:54 -04:00 committed by Dhia Ayachi
parent db250e2114
commit fc629d9eaa
4 changed files with 9 additions and 11 deletions

View File

@ -387,9 +387,6 @@ func (s *Server) revokeLeadership() {
s.stopConnectLeader() s.stopConnectLeader()
s.caManager.setCAProvider(nil, nil)
s.caManager.setState(caStateUninitialized, false)
s.stopACLTokenReaping() s.stopACLTokenReaping()
s.stopACLUpgrade() s.stopACLUpgrade()

View File

@ -49,14 +49,6 @@ func (s *Server) stopConnectLeader() {
s.leaderRoutineManager.Stop(caRootPruningRoutineName) s.leaderRoutineManager.Stop(caRootPruningRoutineName)
s.leaderRoutineManager.Stop(caRootMetricRoutineName) s.leaderRoutineManager.Stop(caRootMetricRoutineName)
s.leaderRoutineManager.Stop(caSigningMetricRoutineName) s.leaderRoutineManager.Stop(caSigningMetricRoutineName)
// If the provider implements NeedsStop, we call Stop to perform any shutdown actions.
provider, _ := s.caManager.getCAProvider()
if provider != nil {
if needsStop, ok := provider.(ca.NeedsStop); ok {
needsStop.Stop()
}
}
} }
// createProvider returns a connect CA provider from the given config. // createProvider returns a connect CA provider from the given config.

View File

@ -271,6 +271,14 @@ func (c *CAManager) Stop() {
c.leaderRoutineManager.Stop(secondaryCARootWatchRoutineName) c.leaderRoutineManager.Stop(secondaryCARootWatchRoutineName)
c.leaderRoutineManager.Stop(intermediateCertRenewWatchRoutineName) c.leaderRoutineManager.Stop(intermediateCertRenewWatchRoutineName)
c.leaderRoutineManager.Stop(backgroundCAInitializationRoutineName) c.leaderRoutineManager.Stop(backgroundCAInitializationRoutineName)
if provider, _ := c.getCAProvider(); provider != nil {
if needsStop, ok := provider.(ca.NeedsStop); ok {
needsStop.Stop()
}
}
c.setCAProvider(nil, nil)
c.setState(caStateUninitialized, false)
} }
func (c *CAManager) startPostInitializeRoutines(ctx context.Context) { func (c *CAManager) startPostInitializeRoutines(ctx context.Context) {

View File

@ -138,6 +138,7 @@ func (s *Server) getCARoots(ws memdb.WatchSet, state *state.Store) (*structs.Ind
return indexedRoots, nil return indexedRoots, nil
} }
// TODO: Move this off Server. This is only called by RPC endpoints.
func (s *Server) SignCertificate(csr *x509.CertificateRequest, spiffeID connect.CertURI) (*structs.IssuedCert, error) { func (s *Server) SignCertificate(csr *x509.CertificateRequest, spiffeID connect.CertURI) (*structs.IssuedCert, error) {
provider, caRoot := s.caManager.getCAProvider() provider, caRoot := s.caManager.getCAProvider()
if provider == nil { if provider == nil {