Skip to content

Commit

Permalink
Bump min/default docker API version to 1.24
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrc committed Jan 20, 2024
1 parent 473aa9a commit 8b2bb71
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 59 deletions.
6 changes: 2 additions & 4 deletions agent/app/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1107,16 +1107,14 @@ func (agent *ecsAgent) verifyRequiredDockerVersion() (int, bool) {
return exitcodes.ExitError, false
}

// if api version 1.21 is supported, it means docker version is at least 1.9.0
for _, version := range supportedVersions {
if version == dockerclient.Version_1_21 {
if version == dockerclient.MinDockerAPIVersion {
return -1, true
}
}

// api 1.21 is not supported, docker version is older than 1.9.0
seelog.Criticalf("Required minimum docker API verion %s is not supported",
dockerclient.Version_1_21)
dockerclient.MinDockerAPIVersion)
return exitcodes.ExitTerminal, false
}

Expand Down
10 changes: 5 additions & 5 deletions agent/app/agent_capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,12 @@ func (agent *ecsAgent) capabilities() ([]*ecs.Attribute, error) {

func (agent *ecsAgent) appendDockerDependentCapabilities(capabilities []*ecs.Attribute,
supportedVersions map[dockerclient.DockerVersion]bool) []*ecs.Attribute {
if _, ok := supportedVersions[dockerclient.Version_1_19]; ok {
if _, ok := supportedVersions[dockerclient.MinDockerAPIVersion]; ok {
capabilities = appendNameOnlyAttribute(capabilities, capabilityPrefix+"ecr-auth")
capabilities = appendNameOnlyAttribute(capabilities, attributePrefix+"execution-role-ecr-pull")
}

if _, ok := supportedVersions[dockerclient.Version_1_24]; ok && !agent.cfg.DisableDockerHealthCheck.Enabled() {
if _, ok := supportedVersions[dockerclient.MinDockerAPIVersion]; ok && !agent.cfg.DisableDockerHealthCheck.Enabled() {
// Docker health check was added in API 1.24
capabilities = appendNameOnlyAttribute(capabilities, attributePrefix+"container-health-check")
}
Expand Down Expand Up @@ -361,7 +361,7 @@ func (agent *ecsAgent) appendTaskIamRoleCapabilities(capabilities []*ecs.Attribu
// The "task-iam-role" capability is supported for docker v1.7.x onwards
// Refer https://github.com/docker/docker/blob/master/docs/reference/api/docker_remote_api.md
// to lookup the table of docker supportedVersions to API supportedVersions
if _, ok := supportedVersions[dockerclient.Version_1_19]; ok {
if _, ok := supportedVersions[dockerclient.MinDockerAPIVersion]; ok {
capabilities = appendNameOnlyAttribute(capabilities, capabilityPrefix+capabilityTaskIAMRole)
} else {
seelog.Warn("Task IAM Role not enabled due to unsuppported Docker version")
Expand All @@ -370,7 +370,7 @@ func (agent *ecsAgent) appendTaskIamRoleCapabilities(capabilities []*ecs.Attribu

if agent.cfg.TaskIAMRoleEnabledForNetworkHost {
// The "task-iam-role-network-host" capability is supported for docker v1.7.x onwards
if _, ok := supportedVersions[dockerclient.Version_1_19]; ok {
if _, ok := supportedVersions[dockerclient.MinDockerAPIVersion]; ok {
capabilities = appendNameOnlyAttribute(capabilities, capabilityPrefix+capabilityTaskIAMRoleNetHost)
} else {
seelog.Warn("Task IAM Role for Host Network not enabled due to unsuppported Docker version")
Expand All @@ -381,7 +381,7 @@ func (agent *ecsAgent) appendTaskIamRoleCapabilities(capabilities []*ecs.Attribu

func (agent *ecsAgent) appendTaskCPUMemLimitCapabilities(capabilities []*ecs.Attribute, supportedVersions map[dockerclient.DockerVersion]bool) ([]*ecs.Attribute, error) {
if agent.cfg.TaskCPUMemLimit.Enabled() {
if _, ok := supportedVersions[dockerclient.Version_1_22]; ok {
if _, ok := supportedVersions[dockerclient.MinDockerAPIVersion]; ok {
capabilities = appendNameOnlyAttribute(capabilities, attributePrefix+capabilityTaskCPUMemLimit)
} else if agent.cfg.TaskCPUMemLimit.Value == config.ExplicitlyEnabled {
// explicitly enabled -- return an error because we cannot fulfil an explicit request
Expand Down
48 changes: 21 additions & 27 deletions agent/app/agent_capability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ func TestCapabilities(t *testing.T) {
// AnyTimes() because they are not called in windows.
gomock.InOrder(
client.EXPECT().SupportedVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_17,
dockerclient.Version_1_18,
dockerclient.Version_1_19,
dockerclient.MinDockerAPIVersion,
}),
client.EXPECT().KnownVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_17,
dockerclient.Version_1_18,
dockerclient.Version_1_19,
dockerclient.MinDockerAPIVersion,
}),
// CNI plugins are platform dependent.
// Therefore, for any version query for any plugin return an appropriate version
Expand All @@ -125,8 +125,7 @@ func TestCapabilities(t *testing.T) {
// TODO add capabilityEBSTaskAttach
expectedNameOnlyCapabilities := []string{
capabilityPrefix + "privileged-container",
capabilityPrefix + "docker-remote-api.1.17",
capabilityPrefix + "docker-remote-api.1.18",
capabilityPrefix + "docker-remote-api.1.24",
capabilityPrefix + "logging-driver.json-file",
capabilityPrefix + "logging-driver.syslog",
capabilityPrefix + "logging-driver.journald",
Expand Down Expand Up @@ -258,7 +257,7 @@ func getCapabilitiesWithConfig(cfg *config.Config, t *testing.T) []*ecs.Attribut
client.EXPECT().KnownVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_17,
dockerclient.Version_1_18,
dockerclient.Version_1_19,
dockerclient.MinDockerAPIVersion,
}),
mockMobyPlugins.EXPECT().Scan().AnyTimes().Return([]string{}, nil),
client.EXPECT().ListPluginsWithFilters(gomock.Any(), gomock.Any(), gomock.Any(),
Expand Down Expand Up @@ -293,7 +292,7 @@ func TestCapabilitiesECR(t *testing.T) {

client := mock_dockerapi.NewMockDockerClient(ctrl)
client.EXPECT().SupportedVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_19,
dockerclient.MinDockerAPIVersion,
})
client.EXPECT().KnownVersions().Return(nil)
mockMobyPlugins.EXPECT().Scan().AnyTimes().Return([]string{}, nil)
Expand Down Expand Up @@ -350,7 +349,7 @@ func TestCapabilitiesTaskIAMRoleForSupportedDockerVersion(t *testing.T) {

client := mock_dockerapi.NewMockDockerClient(ctrl)
client.EXPECT().SupportedVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_19,
dockerclient.MinDockerAPIVersion,
})
client.EXPECT().KnownVersions().Return(nil)
mockMobyPlugins.EXPECT().Scan().AnyTimes().Return([]string{}, nil)
Expand Down Expand Up @@ -460,7 +459,7 @@ func TestCapabilitiesTaskIAMRoleNetworkHostForSupportedDockerVersion(t *testing.
mockMobyPlugins := mock_mobypkgwrapper.NewMockPlugins(ctrl)

client.EXPECT().SupportedVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_19,
dockerclient.MinDockerAPIVersion,
})
client.EXPECT().KnownVersions().Return(nil)
mockMobyPlugins.EXPECT().Scan().AnyTimes().Return([]string{}, nil)
Expand Down Expand Up @@ -594,7 +593,7 @@ func TestAWSVPCBlockInstanceMetadataWhenTaskENIIsDisabled(t *testing.T) {
client.EXPECT().KnownVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_17,
dockerclient.Version_1_18,
dockerclient.Version_1_19,
dockerclient.MinDockerAPIVersion,
}),
mockMobyPlugins.EXPECT().Scan().AnyTimes().Return([]string{}, nil),
client.EXPECT().ListPluginsWithFilters(gomock.Any(), gomock.Any(), gomock.Any(),
Expand Down Expand Up @@ -712,7 +711,10 @@ func TestCapabilitiesTaskResourceLimit(t *testing.T) {
conf := &config.Config{TaskCPUMemLimit: config.BooleanDefaultTrue{Value: config.ExplicitlyEnabled}}

client := mock_dockerapi.NewMockDockerClient(ctrl)
versionList := []dockerclient.DockerVersion{dockerclient.Version_1_22}
versionList := []dockerclient.DockerVersion{
dockerclient.Version_1_22,
dockerclient.MinDockerAPIVersion,
}
mockMobyPlugins := mock_mobypkgwrapper.NewMockPlugins(ctrl)
mockPauseLoader := mock_loader.NewMockLoader(ctrl)
mockPauseLoader.EXPECT().IsLoaded(gomock.Any()).Return(false, nil).AnyTimes()
Expand Down Expand Up @@ -861,17 +863,11 @@ func TestCapabilitiesIncreasedTaskCPULimit(t *testing.T) {
expectedIncreasedTaskCPULimitEnabled bool
}{
{
testName: "enabled by default",
testName: "enabled by default with min docker API version",
taskCPUMemLimitValue: config.NotSet,
dockerVersion: dockerclient.Version_1_22,
dockerVersion: dockerclient.MinDockerAPIVersion,
expectedIncreasedTaskCPULimitEnabled: true,
},
{
testName: "disabled, unsupportedDockerVersion",
taskCPUMemLimitValue: config.NotSet,
dockerVersion: dockerclient.Version_1_19,
expectedIncreasedTaskCPULimitEnabled: false,
},
{
testName: "disabled, taskCPUMemLimit explicitly disabled",
taskCPUMemLimitValue: config.ExplicitlyDisabled,
Expand Down Expand Up @@ -1044,7 +1040,7 @@ func TestCapabilitesListPluginsErrorCase(t *testing.T) {
mockMobyPlugins := mock_mobypkgwrapper.NewMockPlugins(ctrl)

client := mock_dockerapi.NewMockDockerClient(ctrl)
versionList := []dockerclient.DockerVersion{dockerclient.Version_1_19}
versionList := []dockerclient.DockerVersion{dockerclient.MinDockerAPIVersion}
mockPauseLoader := mock_loader.NewMockLoader(ctrl)
mockPauseLoader.EXPECT().IsLoaded(gomock.Any()).Return(false, nil).AnyTimes()
mockServiceConnectManager := mock_serviceconnect.NewMockManager(ctrl)
Expand Down Expand Up @@ -1092,7 +1088,7 @@ func TestCapabilitesScanPluginsErrorCase(t *testing.T) {
mockMobyPlugins := mock_mobypkgwrapper.NewMockPlugins(ctrl)

client := mock_dockerapi.NewMockDockerClient(ctrl)
versionList := []dockerclient.DockerVersion{dockerclient.Version_1_19}
versionList := []dockerclient.DockerVersion{dockerclient.MinDockerAPIVersion}
mockPauseLoader := mock_loader.NewMockLoader(ctrl)
mockPauseLoader.EXPECT().IsLoaded(gomock.Any()).Return(false, nil).AnyTimes()
mockServiceConnectManager := mock_serviceconnect.NewMockManager(ctrl)
Expand Down Expand Up @@ -1210,7 +1206,7 @@ func TestCapabilitiesExecuteCommand(t *testing.T) {

mockMobyPlugins := mock_mobypkgwrapper.NewMockPlugins(ctrl)
client := mock_dockerapi.NewMockDockerClient(ctrl)
versionList := []dockerclient.DockerVersion{dockerclient.Version_1_19}
versionList := []dockerclient.DockerVersion{dockerclient.MinDockerAPIVersion}
mockPauseLoader := mock_loader.NewMockLoader(ctrl)
mockPauseLoader.EXPECT().IsLoaded(gomock.Any()).Return(false, nil).AnyTimes()
mockServiceConnectManager := mock_serviceconnect.NewMockManager(ctrl)
Expand Down Expand Up @@ -1308,13 +1304,12 @@ func TestCapabilitiesNoServiceConnect(t *testing.T) {
// AnyTimes() because they are not called in windows.
gomock.InOrder(
client.EXPECT().SupportedVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_17,
dockerclient.Version_1_18,
dockerclient.MinDockerAPIVersion,
}),
client.EXPECT().KnownVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_17,
dockerclient.Version_1_18,
dockerclient.Version_1_19,
dockerclient.MinDockerAPIVersion,
}),
// CNI plugins are platform dependent.
// Therefore, for any version query for any plugin return an appropriate version
Expand All @@ -1326,8 +1321,7 @@ func TestCapabilitiesNoServiceConnect(t *testing.T) {

expectedNameOnlyCapabilities := []string{
capabilityPrefix + "privileged-container",
capabilityPrefix + "docker-remote-api.1.17",
capabilityPrefix + "docker-remote-api.1.18",
capabilityPrefix + "docker-remote-api.1.24",
capabilityPrefix + "logging-driver.json-file",
capabilityPrefix + "logging-driver.syslog",
capabilityPrefix + "logging-driver.journald",
Expand Down
2 changes: 2 additions & 0 deletions agent/app/agent_capability_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ func TestVolumeDriverCapabilitiesUnix(t *testing.T) {
client.EXPECT().SupportedVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_17,
dockerclient.Version_1_18,
dockerclient.MinDockerAPIVersion,
}),
client.EXPECT().KnownVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_17,
dockerclient.Version_1_18,
dockerclient.Version_1_19,
dockerclient.MinDockerAPIVersion,
}),
cniClient.EXPECT().Version(ecscni.VPCENIPluginName).Return("v1", nil),
mockMobyPlugins.EXPECT().Scan().Return([]string{"fancyvolumedriver"}, nil),
Expand Down
5 changes: 4 additions & 1 deletion agent/app/agent_capability_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ func TestVolumeDriverCapabilitiesWindows(t *testing.T) {
client.EXPECT().SupportedVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_17,
dockerclient.Version_1_18,
dockerclient.MinDockerAPIVersion,
}),
client.EXPECT().KnownVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_17,
dockerclient.Version_1_18,
dockerclient.Version_1_19,
dockerclient.MinDockerAPIVersion,
}),
cniClient.EXPECT().Version(ecscni.ECSVPCENIPluginExecutable).Return("v1", nil),
)
Expand Down Expand Up @@ -159,11 +161,13 @@ func TestSupportedCapabilitiesWindows(t *testing.T) {
client.EXPECT().SupportedVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_17,
dockerclient.Version_1_18,
dockerclient.MinDockerAPIVersion,
}),
client.EXPECT().KnownVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_17,
dockerclient.Version_1_18,
dockerclient.Version_1_19,
dockerclient.MinDockerAPIVersion,
}),
cniClient.EXPECT().Version(ecscni.ECSVPCENIPluginExecutable).Return("v1", nil),
)
Expand Down Expand Up @@ -221,7 +225,6 @@ func TestSupportedCapabilitiesWindows(t *testing.T) {
capabilities, err := agent.capabilities()
assert.NoError(t, err)

assert.Equal(t, len(expectedCapabilities), len(capabilities))
for _, expected := range expectedCapabilities {
assert.Contains(t, capabilities, &ecs.Attribute{
Name: expected.Name,
Expand Down
5 changes: 2 additions & 3 deletions agent/app/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ var notFoundErr = awserr.NewRequestFailure(awserr.Error(awserr.New("NotFound", "
var badReqErr = awserr.NewRequestFailure(awserr.Error(awserr.New("BadRequest", "", errors.New(""))), 400, "")
var serverErr = awserr.NewRequestFailure(awserr.Error(awserr.New("InternalServerError", "", errors.New(""))), 500, "")
var apiVersions = []dockerclient.DockerVersion{
dockerclient.Version_1_21,
dockerclient.Version_1_22,
dockerclient.Version_1_23}
dockerclient.MinDockerAPIVersion,
}
var capabilities []*ecs.Attribute
var testHostCPU = int64(1024)
var testHostMEMORY = int64(1024)
Expand Down
16 changes: 8 additions & 8 deletions agent/dockerclient/logging_drivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ const (
)

var LoggingDriverMinimumVersion = map[LoggingDriver]DockerVersion{
JSONFileDriver: Version_1_18,
SyslogDriver: Version_1_18,
JournaldDriver: Version_1_19,
GelfDriver: Version_1_20,
FluentdDriver: Version_1_20,
AWSLogsDriver: Version_1_21,
SplunklogsDriver: Version_1_22,
JSONFileDriver: MinDockerAPIVersion,
SyslogDriver: MinDockerAPIVersion,
JournaldDriver: MinDockerAPIVersion,
GelfDriver: MinDockerAPIVersion,
FluentdDriver: MinDockerAPIVersion,
AWSLogsDriver: MinDockerAPIVersion,
SplunklogsDriver: MinDockerAPIVersion,
NoneDriver: MinDockerAPIVersion,
LogentriesDriver: Version_1_25,
SumoLogicDriver: Version_1_29,
NoneDriver: Version_1_19,
}
2 changes: 1 addition & 1 deletion agent/dockerclient/sdkclientfactory/sdkclientfactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func findDockerVersions(ctx context.Context, endpoint string) map[dockerclient.D
// the clients in getKnownAPIVersions
var minAPIVersion, apiVersion string
// get a Docker client with the default supported version
client, err := newVersionedClient(endpoint, string(minDockerAPIVersion))
client, err := newVersionedClient(endpoint, string(dockerclient.MinDockerAPIVersion))
if err == nil {
derivedCtx, cancel := context.WithTimeout(ctx, dockerclient.VersionTimeout)
defer cancel()
Expand Down
11 changes: 5 additions & 6 deletions agent/dockerclient/sdkclientfactory/versionsupport_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ import (
"github.com/aws/amazon-ecs-agent/agent/dockerclient/sdkclient"
)

const (
// minDockerAPIVersion is the min Docker API version supported by agent
minDockerAPIVersion = dockerclient.Version_1_17
)

// GetClient on linux will simply return the cached client from the map
func (f *factory) GetClient(version dockerclient.DockerVersion) (sdkclient.Client, error) {
return f.getClient(version)
Expand All @@ -50,10 +45,14 @@ func getAgentSupportedDockerVersions() []dockerclient.DockerVersion {
dockerclient.Version_1_30,
dockerclient.Version_1_31,
dockerclient.Version_1_32,
dockerclient.Version_1_33,
dockerclient.Version_1_34,
dockerclient.Version_1_35,
dockerclient.Version_1_36,
}
}

// getDefaultVersion will return the default Docker API version for linux
func GetDefaultVersion() dockerclient.DockerVersion {
return dockerclient.Version_1_21
return dockerclient.MinDockerAPIVersion
}
8 changes: 4 additions & 4 deletions agent/dockerclient/sdkclientfactory/versionsupport_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import (
"github.com/aws/amazon-ecs-agent/agent/dockerclient/sdkclient"
)

// minDockerAPIVersion is the min Docker API version supported by agent
const minDockerAPIVersion = dockerclient.Version_1_24
// MinDockerAPIVersion is the min Docker API version supported by agent
const MinDockerAPIVersion = dockerclient.Version_1_24

// GetClient will replace some versions of Docker on Windows. We need this because
// agent assumes that it can always call older versions of the docker API.
func (f *factory) GetClient(version dockerclient.DockerVersion) (sdkclient.Client, error) {
for _, v := range getWindowsReplaceableVersions() {
if v == version {
version = minDockerAPIVersion
version = MinDockerAPIVersion
break
}
}
Expand Down Expand Up @@ -71,5 +71,5 @@ func getAgentSupportedDockerVersions() []dockerclient.DockerVersion {

// getDefaultVersion returns agent's default version of the Docker API
func GetDefaultVersion() dockerclient.DockerVersion {
return minDockerAPIVersion
return MinDockerAPIVersion
}
10 changes: 10 additions & 0 deletions agent/dockerclient/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ const (
Version_1_30 DockerVersion = "1.30"
Version_1_31 DockerVersion = "1.31"
Version_1_32 DockerVersion = "1.32"
Version_1_33 DockerVersion = "1.33"
Version_1_34 DockerVersion = "1.34"
Version_1_35 DockerVersion = "1.35"
Version_1_36 DockerVersion = "1.36"
// MinDockerAPIVersion is the min Docker API version supported by agent
MinDockerAPIVersion = Version_1_24
)

func (d DockerVersion) String() string {
Expand All @@ -58,5 +64,9 @@ func GetKnownAPIVersions() []DockerVersion {
Version_1_30,
Version_1_31,
Version_1_32,
Version_1_33,
Version_1_34,
Version_1_35,
Version_1_36,
}
}

0 comments on commit 8b2bb71

Please sign in to comment.