From cfd0efff11344c7dfa6693b370cd23aab91b8281 Mon Sep 17 00:00:00 2001 From: Random-Liu Date: Wed, 26 Apr 2017 13:13:12 -0700 Subject: [PATCH] Fix StopContainer timeout --- pkg/kubelet/remote/remote_runtime.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/kubelet/remote/remote_runtime.go b/pkg/kubelet/remote/remote_runtime.go index 8a4e29f7ad0..0b0ef219f7c 100644 --- a/pkg/kubelet/remote/remote_runtime.go +++ b/pkg/kubelet/remote/remote_runtime.go @@ -209,7 +209,11 @@ func (r *RemoteRuntimeService) StartContainer(containerID string) error { // StopContainer stops a running container with a grace period (i.e., timeout). func (r *RemoteRuntimeService) StopContainer(containerID string, timeout int64) error { - ctx, cancel := getContextWithTimeout(r.timeout) + ctx, cancel := getContextWithTimeout(time.Duration(timeout) * time.Second) + if timeout == 0 { + // Use default timeout if stop timeout is 0. + ctx, cancel = getContextWithTimeout(r.timeout) + } defer cancel() _, err := r.runtimeClient.StopContainer(ctx, &runtimeapi.StopContainerRequest{