Skip to content

Commit

Permalink
Change timeout input to use StopOptions structure
Browse files Browse the repository at this point in the history
  • Loading branch information
nwneisen committed Jun 7, 2023
1 parent 078346c commit 3aadfc2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions libdocker/kube_docker_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 3aadfc2

Please sign in to comment.