Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump github.com/docker/docker from 20.10.24+incompatible to 24.0.6+incompatible in /agent and /ecs-agent #3907

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions agent/api/task/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ import (
"github.com/aws/amazon-ecs-agent/agent/taskresource/envFiles"
"github.com/aws/amazon-ecs-agent/agent/taskresource/ssmsecret"
"github.com/aws/aws-sdk-go/aws"
"github.com/docker/docker/api/types"
dockercontainer "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/volume"
"github.com/docker/go-units"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -1145,7 +1145,7 @@ func TestPostUnmarshalTaskWithDockerVolumes(t *testing.T) {
autoprovision := true
ctrl := gomock.NewController(t)
dockerClient := mock_dockerapi.NewMockDockerClient(ctrl)
dockerClient.EXPECT().InspectVolume(gomock.Any(), gomock.Any(), gomock.Any()).Return(dockerapi.SDKVolumeResponse{DockerVolume: &types.Volume{}})
dockerClient.EXPECT().InspectVolume(gomock.Any(), gomock.Any(), gomock.Any()).Return(dockerapi.SDKVolumeResponse{DockerVolume: &volume.Volume{}})
taskFromACS := ecsacs.Task{
Arn: strptr("myArn"),
DesiredStatus: strptr("RUNNING"),
Expand Down
8 changes: 4 additions & 4 deletions agent/api/task/taskvolume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
apicontainerstatus "github.com/aws/amazon-ecs-agent/ecs-agent/api/container/status"
apiresource "github.com/aws/amazon-ecs-agent/ecs-agent/api/resource"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/volume"
"github.com/golang/mock/gomock"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -585,7 +585,7 @@ func TestInitializeSharedNonProvisionedVolume(t *testing.T) {

// Expect the volume already exists on the instance
dockerClient.EXPECT().InspectVolume(gomock.Any(), gomock.Any(), gomock.Any()).Return(dockerapi.SDKVolumeResponse{
DockerVolume: &types.Volume{
DockerVolume: &volume.Volume{
Labels: map[string]string{"test": "test"},
},
})
Expand Down Expand Up @@ -632,7 +632,7 @@ func TestInitializeSharedNonProvisionedVolumeValidateNameOnly(t *testing.T) {

// Expect the volume already exists on the instance
dockerClient.EXPECT().InspectVolume(gomock.Any(), gomock.Any(), gomock.Any()).Return(dockerapi.SDKVolumeResponse{
DockerVolume: &types.Volume{
DockerVolume: &volume.Volume{
Options: map[string]string{},
Labels: nil,
},
Expand Down Expand Up @@ -714,7 +714,7 @@ func TestInitializeSharedAutoprovisionVolumeNotMatchError(t *testing.T) {
}

dockerClient.EXPECT().InspectVolume(gomock.Any(), gomock.Any(), gomock.Any()).Return(dockerapi.SDKVolumeResponse{
DockerVolume: &types.Volume{
DockerVolume: &volume.Volume{
Labels: map[string]string{"test": "test"},
},
})
Expand Down
9 changes: 7 additions & 2 deletions agent/dockerclient/dockerapi/docker_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,12 @@ func (dg *dockerGoClient) stopContainer(ctx context.Context, dockerID string, ti
if err != nil {
return DockerContainerMetadata{Error: CannotGetDockerClientError{version: dg.version, err: err}}
}
err = client.ContainerStop(ctx, dockerID, &timeout)

timeoutSeconds := int(timeout.Seconds())
containerOptions := dockercontainer.StopOptions{
Timeout: &timeoutSeconds,
}
err = client.ContainerStop(ctx, dockerID, containerOptions)
metadata := dg.containerMetadata(ctx, dockerID)
if err != nil {
seelog.Errorf("DockerGoClient: error stopping container ID=%s: %v", dockerID, err)
Expand Down Expand Up @@ -1238,7 +1243,7 @@ func (dg *dockerGoClient) createVolume(ctx context.Context,
return SDKVolumeResponse{DockerVolume: nil, Error: &CannotGetDockerClientError{version: dg.version, err: err}}
}

volumeOptions := volume.VolumeCreateBody{
volumeOptions := volume.CreateOptions{
Driver: driver,
DriverOpts: driverOptions,
Labels: labels,
Expand Down
30 changes: 19 additions & 11 deletions agent/dockerclient/dockerapi/docker_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func TestCreateContainerTimeout(t *testing.T) {
mockDockerSDK.EXPECT().ContainerCreate(gomock.Any(), &dockercontainer.Config{}, hostConfig,
&network.NetworkingConfig{}, gomock.Any(), "containerName").Do(func(u, v, w, x, y, z interface{}) {
wait.Wait()
}).MaxTimes(1).Return(dockercontainer.ContainerCreateCreatedBody{}, errors.New("test error"))
}).MaxTimes(1).Return(dockercontainer.CreateResponse{}, errors.New("test error"))
ctx, cancel := context.WithCancel(context.TODO())
defer cancel()
metadata := client.CreateContainer(ctx, &dockercontainer.Config{}, hostConfig, "containerName", xContainerShortTimeout)
Expand All @@ -419,7 +419,7 @@ func TestCreateContainer(t *testing.T) {
"Mismatch in create container HostConfig, %v != %v", actualHostConfig, hostConfig)
assert.Equal(t, actualName, name,
"Mismatch in create container options, %s != %s", actualName, name)
}).Return(dockercontainer.ContainerCreateCreatedBody{ID: "id"}, nil),
}).Return(dockercontainer.CreateResponse{ID: "id"}, nil),
mockDockerSDK.EXPECT().ContainerInspect(gomock.Any(), "id").
Return(types.ContainerJSON{
ContainerJSONBase: &types.ContainerJSONBase{
Expand Down Expand Up @@ -637,7 +637,11 @@ func TestStopContainerTimeout(t *testing.T) {

wait := &sync.WaitGroup{}
wait.Add(1)
mockDockerSDK.EXPECT().ContainerStop(gomock.Any(), "id", &client.config.DockerStopTimeout).Do(func(x, y, z interface{}) {
timeoutSeconds := int(client.config.DockerStopTimeout.Seconds())
containerOptions := dockercontainer.StopOptions{
Timeout: &timeoutSeconds,
}
mockDockerSDK.EXPECT().ContainerStop(gomock.Any(), "id", containerOptions).Do(func(x, y, z interface{}) {
wait.Wait()
// Don't return, verify timeout happens
}).MaxTimes(1).Return(errors.New("test error"))
Expand All @@ -654,8 +658,12 @@ func TestStopContainer(t *testing.T) {
mockDockerSDK, client, _, _, _, done := dockerClientSetup(t)
defer done()

timeoutSeconds := int(client.config.DockerStopTimeout.Seconds())
containerOptions := dockercontainer.StopOptions{
Timeout: &timeoutSeconds,
}
gomock.InOrder(
mockDockerSDK.EXPECT().ContainerStop(gomock.Any(), "id", &client.config.DockerStopTimeout).Return(nil),
mockDockerSDK.EXPECT().ContainerStop(gomock.Any(), "id", containerOptions).Return(nil),
mockDockerSDK.EXPECT().ContainerInspect(gomock.Any(), "id").
Return(
types.ContainerJSON{
Expand Down Expand Up @@ -1875,7 +1883,7 @@ func TestCreateVolumeTimeout(t *testing.T) {
wait.Add(1)
mockDockerSDK.EXPECT().VolumeCreate(gomock.Any(), gomock.Any()).Do(func(ctx context.Context, x interface{}) {
wait.Wait()
}).MaxTimes(1).Return(types.Volume{}, nil)
}).MaxTimes(1).Return(volume.Volume{}, nil)
ctx, cancel := context.WithCancel(context.TODO())
defer cancel()
volumeResponse := client.CreateVolume(ctx, "name", "driver", nil, nil, xContainerShortTimeout)
Expand All @@ -1888,7 +1896,7 @@ func TestCreateVolumeError(t *testing.T) {
mockDockerSDK, client, _, _, _, done := dockerClientSetup(t)
defer done()

mockDockerSDK.EXPECT().VolumeCreate(gomock.Any(), gomock.Any()).Return(types.Volume{}, errors.New("some docker error"))
mockDockerSDK.EXPECT().VolumeCreate(gomock.Any(), gomock.Any()).Return(volume.Volume{}, errors.New("some docker error"))
ctx, cancel := context.WithCancel(context.TODO())
defer cancel()
volumeResponse := client.CreateVolume(ctx, "name", "driver", nil, nil, dockerclient.CreateVolumeTimeout)
Expand All @@ -1907,11 +1915,11 @@ func TestCreateVolume(t *testing.T) {
"opt2": "val2",
}
gomock.InOrder(
mockDockerSDK.EXPECT().VolumeCreate(gomock.Any(), gomock.Any()).Do(func(ctx context.Context, opts volume.VolumeCreateBody) {
mockDockerSDK.EXPECT().VolumeCreate(gomock.Any(), gomock.Any()).Do(func(ctx context.Context, opts volume.CreateOptions) {
assert.Equal(t, opts.Name, volumeName)
assert.Equal(t, opts.Driver, driver)
assert.EqualValues(t, opts.DriverOpts, driverOptions)
}).Return(types.Volume{Name: volumeName, Driver: driver, Mountpoint: mountPoint, Labels: nil}, nil),
}).Return(volume.Volume{Name: volumeName, Driver: driver, Mountpoint: mountPoint, Labels: nil}, nil),
)
ctx, cancel := context.WithCancel(context.TODO())
defer cancel()
Expand All @@ -1932,7 +1940,7 @@ func TestInspectVolumeTimeout(t *testing.T) {
wait.Add(1)
mockDockerSDK.EXPECT().VolumeInspect(gomock.Any(), gomock.Any()).Do(func(ctx context.Context, x interface{}) {
wait.Wait()
}).MaxTimes(1).Return(types.Volume{}, nil)
}).MaxTimes(1).Return(volume.Volume{}, nil)
ctx, cancel := context.WithCancel(context.TODO())
defer cancel()
volumeResponse := client.InspectVolume(ctx, "name", xContainerShortTimeout)
Expand All @@ -1945,7 +1953,7 @@ func TestInspectVolumeError(t *testing.T) {
mockDockerSDK, client, _, _, _, done := dockerClientSetup(t)
defer done()

mockDockerSDK.EXPECT().VolumeInspect(gomock.Any(), gomock.Any()).Return(types.Volume{}, errors.New("some docker error"))
mockDockerSDK.EXPECT().VolumeInspect(gomock.Any(), gomock.Any()).Return(volume.Volume{}, errors.New("some docker error"))
ctx, cancel := context.WithCancel(context.TODO())
defer cancel()
volumeResponse := client.InspectVolume(ctx, "name", dockerclient.InspectVolumeTimeout)
Expand All @@ -1958,7 +1966,7 @@ func TestInspectVolume(t *testing.T) {

volumeName := "volumeName"

volumeOutput := types.Volume{
volumeOutput := volume.Volume{
Name: volumeName,
Driver: "driver",
Mountpoint: "local/mount/point",
Expand Down
5 changes: 3 additions & 2 deletions agent/dockerclient/dockerapi/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
apierrors "github.com/aws/amazon-ecs-agent/ecs-agent/api/errors"
"github.com/aws/aws-sdk-go/aws"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/volume"
)

// ContainerNotFound is a type for a missing container
Expand Down Expand Up @@ -105,13 +106,13 @@ type PingResponse struct {
// VolumeResponse wrapper for CreateVolume and InspectVolume
// TODO Remove type when migration is complete
type VolumeResponse struct {
DockerVolume *types.Volume
DockerVolume *volume.Volume
Error error
}

// VolumeResponse wrapper for CreateVolume for SDK Clients
type SDKVolumeResponse struct {
DockerVolume *types.Volume
DockerVolume *volume.Volume
Error error
}

Expand Down
9 changes: 4 additions & 5 deletions agent/dockerclient/sdkclient/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package sdkclient
import (
"context"
"io"
"time"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
Expand All @@ -34,14 +33,14 @@ import (
type Client interface {
ClientVersion() string
ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig,
networkingConfig *network.NetworkingConfig, platform *v1.Platform, containerName string) (container.ContainerCreateCreatedBody, error)
networkingConfig *network.NetworkingConfig, platform *v1.Platform, containerName string) (container.CreateResponse, error)
ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)
ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)
ContainerTop(ctx context.Context, containerID string, arguments []string) (container.ContainerTopOKBody, error)
ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error
ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error
ContainerStats(ctx context.Context, containerID string, stream bool) (types.ContainerStats, error)
ContainerStop(ctx context.Context, containerID string, timeout *time.Duration) error
ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error
ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error
ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
Expand All @@ -56,8 +55,8 @@ type Client interface {
error)
Ping(ctx context.Context) (types.Ping, error)
PluginList(ctx context.Context, filter filters.Args) (types.PluginsListResponse, error)
VolumeCreate(ctx context.Context, options volume.VolumeCreateBody) (types.Volume, error)
VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error)
VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error)
VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error)
VolumeRemove(ctx context.Context, volumeID string, force bool) error
ServerVersion(ctx context.Context) (types.Version, error)
Info(ctx context.Context) (types.Info, error)
Expand Down
15 changes: 7 additions & 8 deletions agent/dockerclient/sdkclient/mocks/sdkclient_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions agent/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/containernetworking/cni v1.1.2
github.com/containernetworking/plugins v1.1.1
github.com/deniswernert/udev v0.0.0-20170418162847-a12666f7b5a1
github.com/docker/docker v20.10.24+incompatible
github.com/docker/docker v24.0.6+incompatible
github.com/docker/go-connections v0.4.0
github.com/docker/go-units v0.4.0
github.com/fsnotify/fsnotify v1.6.0
Expand All @@ -37,11 +37,9 @@ require (

require (
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/Microsoft/hcsshim v0.9.9 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cilium/ebpf v0.9.1 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/didip/tollbooth v4.0.2+incompatible // indirect
Expand All @@ -56,17 +54,17 @@ require (
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/moby/sys/mount v0.3.3 // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/common v0.26.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/rootless-containers/rootlesskit v1.1.1 // indirect
github.com/sirupsen/logrus v1.9.2 // indirect
github.com/vishvananda/netns v0.0.4 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
Expand Down
Loading