Skip to content

Mount MPS control binary and pipe dir into the agent container - #5086

Merged
harishxr merged 1 commit into
aws:devfrom
harishxr:mps-ec2-init-mps-mounts
Aug 7, 2026
Merged

harishxr merged 1 commit into
aws:devfrom
harishxr:mps-ec2-init-mps-mounts

Conversation

@harishxr

@harishxr harishxr commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The ECS agent runs inside a container, so it cannot see host paths that aren't explicitly mounted in. An upcoming change adds an MPS control-daemon health gate that runs inside the agent and needs to reach the daemon on the host. This change makes the two host paths that gate depends on visible inside the agent container.

Implementation details

In ecs-init, getHostConfig already adds GPU-only bind mounts inside the block gated on ECS_ENABLE_GPU_SUPPORT=true and nvidiaGPUDevicesPresent(). Adding 2 more mounts there:

  • /usr/bin/nvidia-cuda-mps-control - the MPS control front-end which the agent execs.
  • /tmp/nvidia-mps - the MPS control daemon's socket directory

Both mounts are guarded with isPathValid so they are only added when the source exists on the host, avoiding docker creating an empty host directory when the daemon is not present. The MPS binary ships in the GPU AMI. The pipe directory is created by the MPS control daemon at boot, before the agent starts.

Only GPU instances with GPU support enabled are affected, non-GPU instances are unchanged.

Testing

Built a custom agent and loaded it on a GPU instance running the latest AL2023 ECS GPU AMI. Ran a docker inspect ecs-agent and observed the following in the mounts section:

{
                "Type": "bind",
                "Source": "/usr/bin/nvidia-cuda-mps-control",
                "Destination": "/usr/bin/nvidia-cuda-mps-control",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
},
{
                "Type": "bind",
                "Source": "/tmp/nvidia-mps",
                "Destination": "/tmp/nvidia-mps",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
}

New tests cover the changes: yes

Description for the changelog

Enhancement - Mount MPS control binary and pipe dir into the agent container

Additional Information

Does this PR include breaking model changes? If so, Have you added transformation functions? No

Does this PR include the addition of new environment variables in the README? No

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@harishxr
harishxr force-pushed the mps-ec2-init-mps-mounts branch from f44e499 to 12f0505 Compare August 5, 2026 18:34
@harishxr
harishxr marked this pull request as ready for review August 5, 2026 18:45
@harishxr
harishxr requested a review from a team as a code owner August 5, 2026 18:45
@harishxr
harishxr enabled auto-merge (rebase) August 5, 2026 18:50
@aws aws deleted a comment from tessaSlice Aug 5, 2026
Comment thread ecs-init/docker/docker_test.go Resolved
Comment thread ecs-init/docker/docker_test.go Resolved
@harishxr
harishxr force-pushed the mps-ec2-init-mps-mounts branch from 12f0505 to 95ae0ee Compare August 5, 2026 20:13
@tessaSlice tessaSlice added bot/test go Pull requests that update Go code labels Aug 5, 2026
@harishxr harishxr removed the go Pull requests that update Go code label Aug 5, 2026
@harishxr
harishxr disabled auto-merge August 5, 2026 20:23
@harishxr
harishxr enabled auto-merge (rebase) August 6, 2026 19:00
Comment thread ecs-init/docker/docker.go Resolved
@TheanLim

TheanLim commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

The pipe directory is created by the MPS control daemon at boot, before the agent starts.

curious: how to ensure the creation before agent starts?

Comment thread ecs-init/docker/docker.go Resolved
Comment thread ecs-init/docker/docker.go Resolved
Comment thread ecs-init/docker/docker.go Resolved
Comment thread ecs-init/docker/docker_test.go Resolved
@harishxr
harishxr requested a review from TheanLim August 7, 2026 06:28
@harishxr
harishxr merged commit 4bfd765 into aws:dev Aug 7, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants