Wait longer for exit events on Windows

The latest version of containerd-shim-runhcs-v1 (v0.10.0-rc.4) pulled in
with the bump to ContainerD v1.7.0-rc.3 had several changes to make it
more robust, which had the side effect of increasing the worst-case
amount of time it takes for a container to exit in the worst case.
Notably, the total timeout for shutting down a task increased from 30
seconds to 60! Increase the timeouts hardcoded in the daemon and
integration tests so that they don't give up too soon.

Signed-off-by: Cory Snider <csnider@mirantis.com>
(cherry picked from commit d634ae9b60)
Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
Cory Snider 2023-01-31 15:19:08 -05:00
parent bfc8e1ae36
commit b1d9012969
2 changed files with 8 additions and 3 deletions

View file

@ -147,7 +147,12 @@ func (daemon *Daemon) Kill(container *containerpkg.Container) error {
}
}
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
waitTimeout := 10 * time.Second
if runtime.GOOS == "windows" {
waitTimeout = 75 * time.Second // runhcs can be sloooooow.
}
ctx, cancel := context.WithTimeout(context.Background(), waitTimeout)
defer cancel()
status := <-container.Wait(ctx, containerpkg.WaitConditionNotRunning)
@ -155,7 +160,7 @@ func (daemon *Daemon) Kill(container *containerpkg.Container) error {
return nil
}
logrus.WithError(status.Err()).WithField("container", container.ID).Error("Container failed to exit within 10 seconds of kill - trying direct SIGKILL")
logrus.WithError(status.Err()).WithField("container", container.ID).Errorf("Container failed to exit within %v of kill - trying direct SIGKILL", waitTimeout)
if err := killProcessDirectly(container); err != nil {
if errors.As(err, &errNoSuchProcess{}) {

View file

@ -145,7 +145,7 @@ func TestWaitConditions(t *testing.T) {
opts = append(opts, container.WithAutoRemove)
}
containerID := container.Run(ctx, t, cli, opts...)
poll.WaitOn(t, container.IsInState(ctx, cli, containerID, "running"), poll.WithTimeout(30*time.Second), poll.WithDelay(100*time.Millisecond))
poll.WaitOn(t, container.IsInState(ctx, cli, containerID, "running"), poll.WithTimeout(75*time.Second), poll.WithDelay(100*time.Millisecond))
waitResC, errC := cli.ContainerWait(ctx, containerID, tc.waitCond)
select {