Skip to content

Commit 90513fe

Browse files
add ECS_EBSTA_SUPPORTED envvar to advertise ebsta capabilities
1 parent 6e33e33 commit 90513fe

File tree

6 files changed

+22
-9
lines changed

6 files changed

+22
-9
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ Additionally, the following environment variable(s) can be used to configure the
267267
| `ECS_OFFHOST_INTROSPECTION_INTERFACE_NAME` | `eth0` | Primary network interface name to be used for blocking offhost agent introspection port access. By default, this value is `eth0` | `eth0` |
268268
| `ECS_AGENT_LABELS` | `{"test.label.1":"value1","test.label.2":"value2"}` | The labels to add to the ECS Agent container. | |
269269
| `ECS_AGENT_APPARMOR_PROFILE` | `unconfined` | Specifies the name of the AppArmor profile to run the ecs-agent container under. This only applies to AppArmor-enabled systems, such as Ubuntu, Debian, and SUSE. If unset, defaults to the profile written out by ecs-init (ecs-agent-default). | `ecs-agent-default` |
270+
| `ECS_EBSTA_SUPPORTED` | `true` | Whether to use the container instance with EBS Task Attach support. ecs-init sets this variable for the ECS Agent if the instance support can support mounting EBS volumes or not. | `false` | `false` |
270271

271272

272273

agent/app/agent_capability.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,10 @@ func (agent *ecsAgent) capabilities() ([]*ecs.Attribute, error) {
295295
// add service-connect capabilities if applicable
296296
capabilities = agent.appendServiceConnectCapabilities(capabilities)
297297

298-
// add ebs-task-attach attribute if applicable
299-
capabilities = agent.appendEBSTaskAttachCapabilities(capabilities)
298+
if agent.cfg.EBSTASupportEnabled {
299+
// add ebs-task-attach attribute if applicable
300+
capabilities = agent.appendEBSTaskAttachCapabilities(capabilities)
301+
}
300302

301303
if agent.cfg.External.Enabled() {
302304
// Add external specific capability; remove external unsupported capabilities.

agent/config/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ func environmentConfig() (Config, error) {
582582
PollingMetricsWaitDuration: parseEnvVariableDuration("ECS_POLLING_METRICS_WAIT_DURATION"),
583583
DisableDockerHealthCheck: parseBooleanDefaultFalseConfig("ECS_DISABLE_DOCKER_HEALTH_CHECK"),
584584
GPUSupportEnabled: utils.ParseBool(os.Getenv("ECS_ENABLE_GPU_SUPPORT"), false),
585+
EBSTASupportEnabled: utils.ParseBool(os.Getenv("ECS_EBSTA_SUPPORTED"), false),
585586
InferentiaSupportEnabled: utils.ParseBool(os.Getenv("ECS_ENABLE_INF_SUPPORT"), false),
586587
NvidiaRuntime: os.Getenv("ECS_NVIDIA_RUNTIME"),
587588
TaskMetadataAZDisabled: utils.ParseBool(os.Getenv("ECS_DISABLE_TASK_METADATA_AZ"), false),

agent/config/types.go

+3
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ type Config struct {
301301

302302
// GPUSupportEnabled specifies if the Agent is capable of launching GPU tasks
303303
GPUSupportEnabled bool
304+
305+
// EBSTASupportEnabled specifies if the Agent can support tasks needing EBS Task Attach
306+
EBSTASupportEnabled bool
304307
// InferentiaSupportEnabled specifies whether the built-in support for inferentia task is enabled.
305308
InferentiaSupportEnabled bool
306309

ecs-init/docker/docker.go

+7
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,13 @@ func (c *client) getContainerConfig(envVarsFromFiles map[string]string) *godocke
327327
envVariables["ECS_ENABLE_TASK_ENI"] = "false"
328328
}
329329

330+
if config.RunningInExternal() || !isPathValid(config.MountDirectoryEBS(), true) {
331+
// EBS Task Attach (EBSTA) is not supported for external instances
332+
// If EBS mount directory fails to get created, tasks requiring EBSTA can not be supported
333+
// Disable EBSTA Support for these cases
334+
envVariables["ECS_EBSTA_SUPPORTED"] = "false"
335+
}
336+
330337
var env []string
331338
for envKey, envValue := range envVariables {
332339
env = append(env, envKey+"="+envValue)

ecs-init/engine/engine.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,12 @@ func (e *Engine) PreStart() error {
142142
if err != nil {
143143
return engineError("could not create route to the credentials proxy", err)
144144
}
145-
// Add the EBS Task Attach host mount point
146-
// Skip for External, EBS Task Attach is not supported for External launch type
147-
if !config.RunningInExternal() {
148-
err = os.MkdirAll(config.MountDirectoryEBS(), mountFilePermission)
149-
if err != nil {
150-
return engineError("could not create EBS mount directory", err)
151-
}
145+
146+
err = os.MkdirAll(config.MountDirectoryEBS(), mountFilePermission)
147+
if err != nil {
148+
// Log error and continue
149+
// If directory creation fails, set ECS_EBSTA_SUPPORTED=false in docker/docker.go
150+
log.Error("could not create EBS mount directory", err)
152151
}
153152

154153
docker, err := getDockerClient()

0 commit comments

Comments
 (0)