Skip to content

Testing: substrate tag round-trip contract, AL2023 container checks, shellcheck on rendered user-data #689

Closed

Description

@scttfrdmn

Follow-up to #688, which implemented the cheap half of this. Three remaining pieces that would move bugs out of the "hardware only" bucket, in value order.

Context: what the escape routes actually were

v0.118.0 shipped eleven fixes. Four were findable only on real hardware while the unit suite stayed green, and three pre-existing tests asserted the broken behaviour as correct. Sorted by how they escaped:

Escape route Bugs Addressed by
Test built its own fixture, confirming the author's belief #683, #684, #669 A (and partly #688)
Test asserted the text of generated shell, not behaviour #668, #660 C
Property belongs to the OS image, not the code #684 (probe PATH) B
Property belongs to AWS (accepts? authorizes? routes?) #659, #683 smoke only

#688 added the production-path interpolation gate and the hardware-sensitivity marking. These three are what's left.


A. Substrate tag round-trip contract (highest value)

The bug it generalises. #683's drain filtered on in.Tags["spawn:job-array-id"]. listInstancesInRegion lifts every recognised spawn:* tag into a named field and writes only unrecognised keys into Tags, so that lookup was always "" and the drain terminated nothing, ever. A unit test with a hand-built InstanceInfo passes forever, because the fixture encodes the author's belief about the data rather than what the producer emits.

#688's class gate greps for Tags["spawn:…"] reads, which catches this mistake. It does not catch the general case: any field spawn writes and later reads, where the two sides disagree.

The test. Launch into substrate using spawn's real tag-writing path, read back through ListInstances, and assert that every field spawn later reads is populated:

for each spawn:* tag the launcher writes:
    assert it is reachable via the InstanceInfo field that consumers use
    assert Tags does NOT also claim to carry it (or that it does, consistently)

This tests that producer and consumer agree, using the real producer. It is the structural fix for the dominant escape route, and substrate already models RunInstances + DescribeInstances + tags, so no new emulator capability is needed.

Worth extending to the reverse direction too: a field in InstanceInfo that no tag populates is dead weight and will eventually be read by someone.

B. AL2023 container checks

The bug it catches. #684's enrollment probe ran command -v mpirun. On AL2023 openmpi installs to /usr/lib64/openmpi/bin, which is not on the default PATH — the user-data adds it via /etc/profile.d/mpi.sh, and SSM runs a non-login shell that never sources it. Verified live:

/usr/lib64/openmpi/bin/mpirun -> orterun          (installed)
$PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
command -v mpirun                                  → nothing
. /etc/profile.d/mpi.sh && command -v mpirun       → /usr/lib64/openmpi/bin/mpirun

No amount of correct installation could satisfy that probe. This is a property of the image, so no Go test can reach it — but a container can.

The test. In public.ecr.aws/amazonlinux/amazonlinux:2023, dnf install openmpi, then run the generated enrollment probe and assert it passes. Same shape for the storage-gate verify loop and the task wrapper's quoting.

Honest limits, so this isn't oversold: a container has no IMDS, no cloud-init, no systemd (unprivileged), and no EFA device. So it tests fragments — "does this shell snippet behave as intended on this OS" — not the bootstrap as a whole. It supplements make smoke; it does not replace it.

C. shellcheck on rendered user-data

Render each template and pipe it through shellcheck. Cheap, and it plausibly catches the quoting class (#660, where strconv.Quote collapsed a command to one argv word) and would flag the unbounded while [ ! -f … ] wait that #684 fixed.

Needs a baseline pass first: the existing templates will light up, and a gate that starts red gets disabled. Suggest capturing the current findings, fixing or explicitly ignoring each, then enforcing.


Not proposed

Running the full bootstrap under cloud-init in a VM (Firecracker/QEMU) would close most of the remaining gap, but the cost — maintaining a VM harness, an AMI-equivalent rootfs, and cloud-init plumbing — is larger than make smoke, which already does this correctly on the real thing for about five cents. The marking in #688 plus a ten-minute smoke is a better trade than a second simulation to keep honest.

Activity

  1. added this to the v0.138.0 milestone on Oct 19, 2026
  2. scttfrdmn commented on Oct 20, 2026

    @scttfrdmn
    ContributorAuthor

    Part B (AL2023 container checks) is not being done in the #689 PR. It needs a container runtime in CI: pull public.ecr.aws/amazonlinux/amazonlinux:2023, dnf install openmpi, and run the probe inside. That isn't cheap on the hosted runners, and the issue's own "honest limits" note says a container only tests fragments anyway. The PR covers parts A and C: a static writer/reader contract over every spawn:* key, a Substrate round trip through ListInstances, and a shellcheck gate over every generated script, discovered from source. If B is wanted later, it fits best as an opt-in make target next to make smoke, not as a unit-test gate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions