Merge pull request #44970 from Random-Liu/fix-stop-container-timeout

Automatic merge from submit-queue (batch tested with PRs 44970, 43618)

CRI: Fix StopContainer timeout

Fixes https://github.com/kubernetes/kubernetes/issues/44956.

I verified this PR with the example provided in https://github.com/kubernetes/kubernetes/issues/44956, and now pod deletion will respect grace period timeout:
```
NAME                         READY     STATUS        RESTARTS   AGE
gracefully-terminating-pod   1/1       Terminating   0          6m
```

@dchen1107 @yujuhong @feiskyer /cc @kubernetes/sig-node-bugs
This commit is contained in:
Kubernetes Submit Queue 2017-04-26 22:58:11 -07:00 committed by GitHub
commit c3df35df7b

View File

@ -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{