diff options
author | Cory Snider <csnider@mirantis.com> | 2022-08-25 16:34:13 -0400 |
---|---|---|
committer | Cory Snider <csnider@mirantis.com> | 2022-08-25 20:03:42 -0400 |
commit | 8b748bd326d102e4188f55b78ebd06fea0770ffc (patch) | |
tree | 35b050393e2909dbffbbc291d9afe6d2c6cc3d8f | |
parent | d0731af939a061d40925b212a2ae341513276925 (diff) |
daemon: stop health checks before deleting task
Prevent new health check probes from racing the task deletion. This may
have been a root cause of containers taking so long to stop on Windows.
Signed-off-by: Cory Snider <csnider@mirantis.com>
-rw-r--r-- | daemon/monitor.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/daemon/monitor.go b/daemon/monitor.go index 1e96c1d9d8..33a3d6d866 100644 --- a/daemon/monitor.go +++ b/daemon/monitor.go @@ -28,6 +28,11 @@ func (daemon *Daemon) setStateCounter(c *container.Container) { func (daemon *Daemon) handleContainerExit(c *container.Container, e *libcontainerdtypes.EventInfo) error { var exitStatus container.ExitStatus c.Lock() + + // Health checks will be automatically restarted if/when the + // container is started again. + daemon.stopHealthchecks(c) + tsk, ok := c.Task() if ok { ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) @@ -72,9 +77,6 @@ func (daemon *Daemon) handleContainerExit(c *container.Container, e *libcontaine restart = false } - // cancel healthcheck here, they will be automatically - // restarted if/when the container is started again - daemon.stopHealthchecks(c) attributes := map[string]string{ "exitCode": strconv.Itoa(exitStatus.ExitCode), } |