diff --git a/libdocker/kube_docker_client.go b/libdocker/kube_docker_client.go index f48dee3dd..b328959a4 100644 --- a/libdocker/kube_docker_client.go +++ b/libdocker/kube_docker_client.go @@ -31,6 +31,7 @@ import ( "github.com/sirupsen/logrus" dockertypes "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" dockercontainer "github.com/docker/docker/api/types/container" dockerimagetypes "github.com/docker/docker/api/types/image" dockerapi "github.com/docker/docker/client" @@ -39,8 +40,8 @@ import ( ) // kubeDockerClient is a wrapped layer of docker client for kubelet internal use. This layer is added to: -// 1) Redirect stream for exec and attach operations. -// 2) Wrap the context in this layer to make the DockerClientInterface cleaner. +// 1. Redirect stream for exec and attach operations. +// 2. Wrap the context in this layer to make the DockerClientInterface cleaner. type kubeDockerClient struct { // timeout is the timeout of short running docker operations. timeout time.Duration @@ -179,7 +180,13 @@ func (d *kubeDockerClient) StartContainer(id string) error { func (d *kubeDockerClient) StopContainer(id string, timeout time.Duration) error { ctx, cancel := d.getCustomTimeoutContext(timeout) defer cancel() - err := d.client.ContainerStop(ctx, id, &timeout) + + timeoutSeconds := int(timeout / time.Second) + options := container.StopOptions{ + Timeout: &timeoutSeconds, + } + + err := d.client.ContainerStop(ctx, id, options) if ctxErr := contextError(ctx); ctxErr != nil { return ctxErr }