@@ -206,9 +206,13 @@ func (agent *ecsAgent) capabilities() ([]*ecs.Attribute, error) {
206
206
}
207
207
208
208
supportedVersions := make (map [dockerclient.DockerVersion ]bool )
209
- // Determine API versions to report as supported. Supported versions are also used for capability-enablement, except
210
- // logging drivers.
211
- for _ , version := range agent .dockerClient .SupportedVersions () {
209
+ // Determine API versions to report as supported via com.amazonaws.ecs.capability.docker-remote-api.X.XX capabilities
210
+ // We advertise all known versions here rather than "supported" versions. The reason for this is that ECS backend
211
+ // adds required capabilities to some features at the minimum supported version. If this is less than our Minimum
212
+ // supported version (currently 1.24), then the capability will not match.
213
+ // In other words, here we advertise supporting docker api versions that this agent may not actually support, for the
214
+ // sake of task definition required attributes.
215
+ for _ , version := range dockerclient .GetKnownAPIVersions () {
212
216
capabilities = appendNameOnlyAttribute (capabilities , capabilityPrefix + "docker-remote-api." + string (version ))
213
217
supportedVersions [version ] = true
214
218
}
@@ -311,12 +315,12 @@ func (agent *ecsAgent) capabilities() ([]*ecs.Attribute, error) {
311
315
312
316
func (agent * ecsAgent ) appendDockerDependentCapabilities (capabilities []* ecs.Attribute ,
313
317
supportedVersions map [dockerclient.DockerVersion ]bool ) []* ecs.Attribute {
314
- if _ , ok := supportedVersions [dockerclient .Version_1_19 ]; ok {
318
+ if _ , ok := supportedVersions [dockerclient .MinDockerAPIVersion ]; ok {
315
319
capabilities = appendNameOnlyAttribute (capabilities , capabilityPrefix + "ecr-auth" )
316
320
capabilities = appendNameOnlyAttribute (capabilities , attributePrefix + "execution-role-ecr-pull" )
317
321
}
318
322
319
- if _ , ok := supportedVersions [dockerclient .Version_1_24 ]; ok && ! agent .cfg .DisableDockerHealthCheck .Enabled () {
323
+ if _ , ok := supportedVersions [dockerclient .MinDockerAPIVersion ]; ok && ! agent .cfg .DisableDockerHealthCheck .Enabled () {
320
324
// Docker health check was added in API 1.24
321
325
capabilities = appendNameOnlyAttribute (capabilities , attributePrefix + "container-health-check" )
322
326
}
@@ -361,7 +365,7 @@ func (agent *ecsAgent) appendTaskIamRoleCapabilities(capabilities []*ecs.Attribu
361
365
// The "task-iam-role" capability is supported for docker v1.7.x onwards
362
366
// Refer https://github.com/docker/docker/blob/master/docs/reference/api/docker_remote_api.md
363
367
// to lookup the table of docker supportedVersions to API supportedVersions
364
- if _ , ok := supportedVersions [dockerclient .Version_1_19 ]; ok {
368
+ if _ , ok := supportedVersions [dockerclient .MinDockerAPIVersion ]; ok {
365
369
capabilities = appendNameOnlyAttribute (capabilities , capabilityPrefix + capabilityTaskIAMRole )
366
370
} else {
367
371
seelog .Warn ("Task IAM Role not enabled due to unsuppported Docker version" )
@@ -370,7 +374,7 @@ func (agent *ecsAgent) appendTaskIamRoleCapabilities(capabilities []*ecs.Attribu
370
374
371
375
if agent .cfg .TaskIAMRoleEnabledForNetworkHost {
372
376
// The "task-iam-role-network-host" capability is supported for docker v1.7.x onwards
373
- if _ , ok := supportedVersions [dockerclient .Version_1_19 ]; ok {
377
+ if _ , ok := supportedVersions [dockerclient .MinDockerAPIVersion ]; ok {
374
378
capabilities = appendNameOnlyAttribute (capabilities , capabilityPrefix + capabilityTaskIAMRoleNetHost )
375
379
} else {
376
380
seelog .Warn ("Task IAM Role for Host Network not enabled due to unsuppported Docker version" )
@@ -381,7 +385,7 @@ func (agent *ecsAgent) appendTaskIamRoleCapabilities(capabilities []*ecs.Attribu
381
385
382
386
func (agent * ecsAgent ) appendTaskCPUMemLimitCapabilities (capabilities []* ecs.Attribute , supportedVersions map [dockerclient.DockerVersion ]bool ) ([]* ecs.Attribute , error ) {
383
387
if agent .cfg .TaskCPUMemLimit .Enabled () {
384
- if _ , ok := supportedVersions [dockerclient .Version_1_22 ]; ok {
388
+ if _ , ok := supportedVersions [dockerclient .MinDockerAPIVersion ]; ok {
385
389
capabilities = appendNameOnlyAttribute (capabilities , attributePrefix + capabilityTaskCPUMemLimit )
386
390
} else if agent .cfg .TaskCPUMemLimit .Value == config .ExplicitlyEnabled {
387
391
// explicitly enabled -- return an error because we cannot fulfil an explicit request
0 commit comments