mirror of https://github.com/status-im/consul.git
Stop all watches before shuting down anything dring shutdown. (#7526)
This will prevent watches from being triggered. ```changelog * fix(agent): stop all watches before shuting down ```
This commit is contained in:
parent
66612e5dc6
commit
0d86e802be
|
@ -1035,13 +1035,18 @@ func (a *Agent) serveHTTP(srv *HTTPServer) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stopAllWatches stops all the currently running watches
|
||||||
|
func (a *Agent) stopAllWatches() {
|
||||||
|
for _, wp := range a.watchPlans {
|
||||||
|
wp.Stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// reloadWatches stops any existing watch plans and attempts to load the given
|
// reloadWatches stops any existing watch plans and attempts to load the given
|
||||||
// set of watches.
|
// set of watches.
|
||||||
func (a *Agent) reloadWatches(cfg *config.RuntimeConfig) error {
|
func (a *Agent) reloadWatches(cfg *config.RuntimeConfig) error {
|
||||||
// Stop the current watches.
|
// Stop the current watches.
|
||||||
for _, wp := range a.watchPlans {
|
a.stopAllWatches()
|
||||||
wp.Stop()
|
|
||||||
}
|
|
||||||
a.watchPlans = nil
|
a.watchPlans = nil
|
||||||
|
|
||||||
// Return if there are no watches now.
|
// Return if there are no watches now.
|
||||||
|
@ -1743,6 +1748,8 @@ func (a *Agent) ShutdownAgent() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
a.logger.Info("Requesting shutdown")
|
a.logger.Info("Requesting shutdown")
|
||||||
|
// Stop the watches to avoid any notification/state change during shutdown
|
||||||
|
a.stopAllWatches()
|
||||||
|
|
||||||
// Stop the service manager (must happen before we take the stateLock to avoid deadlock)
|
// Stop the service manager (must happen before we take the stateLock to avoid deadlock)
|
||||||
if a.serviceManager != nil {
|
if a.serviceManager != nil {
|
||||||
|
|
Loading…
Reference in New Issue