Skip to content

feat(userdata): headless container-run library primitive - #490

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/353-headless-container-primitive
Aug 7, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/353-headless-container-primitive

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Summary

  • New pkg/userdata.GenerateContainerUserData + ContainerConfig{Image, Region, InstanceType, Command}: installs Docker on demand, authenticates to a private-ECR image (skipped for public images), pulls, and runs — headlessly, no DCV/X11.
  • Wired through launcher.Options.ContainerScript -> BootstrapConfig.ContainerScript, spliced after StorageScript (so a containerized workload sees any mounted volumes already live) and before CustomUserData — same ordering rationale StorageScript already established for #166.
  • GPU (--gpus all) is inferred from InstanceType via the existing aws.DetectGPUInstance — the same inference Provision already applies to AMI selection, so a caller doesn't separately track "is this a GPU type?"
  • Private-ECR auth uses the image's OWN embedded region (not the caller's Region), since a cross-region ECR pull must authenticate against its own region.

Why not reuse pkg/taskproto's existing container-run logic

pkg/taskproto/wrapper.go already has a very similar docker-install/ECR-login/docker-run implementation, but it's built around the full TaskSpec (S3 staging, manifests, results bucket) — much heavier than what the issue asks for ("provision a host and docker run <ref>"). Rather than force a caller like calque to construct a TaskSpec just to run a container, pkg/userdata gets its own lightweight generator, following the exact precedent of the existing GenerateStorageUserData/GenerateMPIUserData (pure config → script, wired through launcher.Options). ecrImageAccount/ecrRegistryHost-equivalent logic is duplicated rather than imported, mirroring taskproto's own existing duplication-with-a-comment from cmd/app_byo.go (pkg/userdata must not depend on cmd or taskproto).

Fixes #353.

Test plan

  • 8 new tests in pkg/userdata (required-field validation, public-image skips login, private-ECR logs in against the image's own region, GPU inference on/off/no-instance-type, CMD override quoting, no DCV/X11 wiring, docker-install-on-demand)
  • 2 new tests in pkg/launcher (ContainerScript splices after StorageScript and before CustomUserData; no container section when empty)
  • go build ./..., go vet ./..., gofmt -l clean, golangci-lint run 0 issues on both touched packages
  • make check-docs — no drift (library-only change, no CLI surface)
  • Full go test ./pkg/userdata/... ./pkg/launcher/... green; broader make check has one pre-existing, unrelated failure (TestCatalogValid — filed as TestCatalogValid fails: chimerax/paraview catalog images are private ECR, not public #489, confirmed present on main via git stash)

New pkg/userdata.GenerateContainerUserData + ContainerConfig: install
Docker on demand, authenticate to a private-ECR image (skipped for
public), pull, and run — headlessly, no DCV/X11. Wired through
launcher.Options.ContainerScript -> BootstrapConfig.ContainerScript,
spliced after StorageScript (so a containerized workload sees any
mounted volumes already live) and before CustomUserData.

Today, running a container image on a spawned instance meant
hand-building the ecr-login/docker-pull/docker-run command string
yourself; the only existing logic (cmd/app.go's containerRunWrapper)
is DCV-streaming-specific (wires DISPLAY/XAUTHORITY for a GUI session),
which a headless SDK consumer neither wants nor can supply.

GPU (--gpus all) is inferred from InstanceType via the existing
aws.DetectGPUInstance, the same inference Provision already applies to
AMI selection.

Fixes #353.
@scttfrdmn
scttfrdmn force-pushed the feat/353-headless-container-primitive branch from dedd949 to 4306396 Compare August 7, 2026 18:17
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.07692% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/userdata/container.go 97.67% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 6b67253 into main Aug 7, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the feat/353-headless-container-primitive branch August 7, 2026 18:27
scttfrdmn added a commit that referenced this pull request Aug 7, 2026
…kage (#491)

cmd/app_byo.go and pkg/taskproto/wrapper.go each carried an independent
copy of ecrImageAccount/ecrRegistryHost (the taskproto copy explicitly
duplicated rather than imported, since taskproto must not depend on
cmd). pkg/userdata/container.go (#353/PR #490) was about to become a
third divergence point with its own slightly-different variant
(ecrImageAccountHost, which also resolves the auth region).

New pkg/ecrref (stdlib-only leaf): Account, RegistryHost, and AuthHost
(the combined host+region lookup userdata needs, with the image's own
region winning over a caller-supplied fallback). Both cmd and
taskproto's existing functions become one-line aliases over it -- no
call-site or test-name changes, so this is purely internal dedup.
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.

Headless container-run library primitive (DCV-free docker run of an image ref)

1 participant