StopContainer should block unless client context is canceled

A call to StopContainer should only return if the client context is canceled or
its deadline was exceeded. The Timeout parameter on StopContainerRequest is now
used as the time AFTER sending the stop signal before the SIGKILL is delivered.
The call will remain until the container has exited or the client context has
finished.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
This commit is contained in:
Justin Terry (VM)
2019-05-21 13:53:46 -07:00
parent d7c3ecd0fb
commit 71cecedc44
2 changed files with 28 additions and 22 deletions

View File

@@ -74,7 +74,12 @@ func TestWaitContainerStop(t *testing.T) {
cancel()
ctx = cancelledCtx
}
err = c.waitContainerStop(ctx, container, test.timeout)
if test.timeout > 0 {
timeoutCtx, cancel := context.WithTimeout(ctx, test.timeout)
defer cancel()
ctx = timeoutCtx
}
err = c.waitContainerStop(ctx, container)
assert.Equal(t, test.expectErr, err != nil, desc)
}
}