Skip to content

fix(bootstrap): enable a shipped acpid, else install with one package manager, skip under 768 MiB (#1521) - #1547

Merged
scttfrdmn merged 2 commits into
mainfrom
fix/1521-acpid-single-pm
Nov 6, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
fix/1521-acpid-single-pm

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1521

Important

This changes the signed, published bootstrap body.
spawn bootstrap-body sha256 (computed the way release.yaml does: go run . bootstrap-body | sha256sum; the same with or without -X cmd.Version=…):

  • before (origin/main 604611b9): baa047b3132cecce0c44ff9880ddf0edf0e6c8e390cec68bb4c2bb801b6b4861
  • after: 3563692d194f446e3aca50030b0e6a24a9fb15a87594daf30b46271f0e93f739 (head a784e70d)

The release republishes and re-signs the body. The sweep orchestrator needs a code-only redeploy from that release, because its compiled-in body has to match the published one (scripts/deploylambdas / deploy-sweep-orchestrator.sh refuse a mismatch). No test or release guard pins a literal body sha.

Bug

if { command -v dnf … && dnf install -y acpid; } || { command -v yum … && yum install -y acpid; }; then

On AL2023, yum is dnf. When dnf was OOM-killed on a t4g.nano, the same transaction ran again as yum, and that second OOM took spored and systemd-resolved.

The live test of the first revision (d13d7bd) found a second problem: the AL2023 AMI ships acpid. On every type, the nano included, dnf install -y acpid was a no-op that still loaded the full repo metadata, and that load is what OOM-killed the nano. The skip path then printed a false "acpid not installed".

Fix (pkg/launcher/bootstrap.go)

SPAWN_MEM_KB=$(awk '/^MemTotal:/{print $2}' /proc/meminfo 2>/dev/null || true)
if ! command -v acpid >/dev/null 2>&1; then
    if [ "${SPAWN_MEM_KB:-786432}" -lt 786432 ] 2>/dev/null; then
        echo "acpid skipped: MemTotal ${SPAWN_MEM_KB} kB < 768 MiB"
    elif command -v dnf >/dev/null 2>&1; then
        dnf install -y acpid 2>/dev/null || true
    elif command -v yum >/dev/null 2>&1; then
        yum install -y acpid 2>/dev/null || true
    fi
fi
if command -v acpid >/dev/null 2>&1; then
    systemctl enable --now acpid 2>/dev/null || echo "acpid installed but not started; stop/terminate will not shut down gracefully"
else
    echo "acpid not installed; stop/terminate will not shut down gracefully"
fi
  • acpid already present: it is enabled and nothing is installed. Nothing new is printed unless the enable fails, and then the existing "installed but not started" line appears.
  • Why command -v acpid and not systemctl list-unit-files acpid.service: it is fewer bytes and needs no output parsing (list-unit-files exits 0 or 1 depending on the systemd version and the pattern, so its output would have to be grepped). It is also reliable here: acpid is /usr/sbin/acpid, and /usr/sbin is already on the bootstrap's PATH, because the bootstrap calls useradd/usermod unqualified. A binary on PATH without its unit file would show up as the "installed but not started" line, which is the truthful outcome.
  • acpid absent: the memory floor applies first, then exactly one package manager (dnf, else yum, else none). A failed or killed install is never retried under the other name.
  • Truthful messages: the same command -v acpid decides the message afterwards. "Not installed" is printed only when acpid is absent after the step, including when an install "succeeded" but left no acpid behind.
  • Still non-fatal (User data: fetch the bootstrap from S3 behind a small verifying stub, removing the 16 KiB ceiling (follow-up to #1246) #1274). Each install is || true.

Memory floor: 768 MiB of MemTotal

aws.SporedMemoryFloorMiB is 1 GiB of instance memory, and MemTotal excludes what the kernel reserves. Measured live on AL2023 arm64: nano 422188 kB, micro 931880 kB, small 1885000 kB. A 1 GiB MemTotal check would therefore skip the micro, which installs fine (#1515). 768 MiB (786432 kB) sits between the nano and the micro. TestAcpidMemoryFloorIsBelowTheLaunchWarningFloor keeps the literal above 512 MiB and at least 1/8 below SporedMemoryFloorMiB.

Gzip budget: +16 bytes (9088 to 9104)

The whole change costs about 104 gzipped bytes (bare bootstrap 7963 to 8067), and the 1024-byte margin had 101 to spare, so after compacting the shell it was 3 bytes over. I raised the budget by the minimum round amount (16) and recorded the reason in minify_test.go. The cost lands in the published body, not in a release launch's stub (stub: 1841 gzipped, unchanged).

Tests (pkg/launcher/bootstrap_acpid_test.go, full inline boot in the boot sandbox)

The sandbox maps /proc/meminfo into the sandbox, and the file is absent unless a test writes it. The package-manager stand-ins put acpid on PATH when they exit 0, as a real install does.

  • acpid already present (at small and at nano MemTotal): no package manager runs, acpid is enabled, and none of the three acpid messages is printed.
  • acpid present but the enable fails: the "installed but not started" line is printed, and "not installed" is not.
  • An install that exits 0 but leaves no acpid: "not installed" is printed, and acpid is not enabled.
  • dnf present: only dnf runs.
  • dnf exits 137: yum is not run, the boot goes on (spored started, user data ran, not retired), and "not installed" is printed.
  • yum-only base: yum runs.
  • Neither present: nothing runs, and "not installed" is printed.
  • MemTotal unreadable: the install is attempted.
  • MemTotal 446000 and 786431 kB: no package manager runs, and the skip line plus "not installed" are printed. At 786432 and 948000 kB, the install runs once.

Revert gate:

  • Against the previous revision's bootstrap.go (d13d7bd): the three new cases fail, each with its own assertion:
    • a package manager ran with acpid already installed
    • the shipped acpid was not enabled
    • printed "acpid not installed…" though acpid is installed and enabled
    • a failed enable of an installed acpid was misreported
    • acpid is absent, so it must be reported not installed
  • Against main's bootstrap.go: the cases above fail, and so do dnf OOM-killed (yum reran the install dnf was killed in (#1521)), the two under-floor cases and the floor-literal test.

Checks (at a784e70d)

  • make check: green.
  • Hermetic go test ./... with AWS env stripped: green.
  • make test-e2e-tier0 (Substrate): green, 79 passing, 0 skipped.
  • semgrep scan --config=auto --error .: 0 findings.
  • TestBootstrap_Shellcheck: green.
  • TestBootstrapToolsExistOnEveryBase: green.

Live checks (owner)

  • All three types: no dnf/yum line in cloud-init-output.log, and no "acpid skipped" or "acpid not installed" line. systemctl is-active acpid should be active, spored and systemd-resolved active, and there should be 0 oom-killer events.
  • The nano specifically: no repo-metadata load at all during the bootstrap.

@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn scttfrdmn changed the title fix(bootstrap): install acpid with one package manager, skip it under 768 MiB (#1521) fix(bootstrap): enable a shipped acpid, else install with one package manager, skip under 768 MiB (#1521) Nov 6, 2026
@scttfrdmn

Copy link
Copy Markdown
Contributor Author

Live test: PASS (aws account, us-east-1, stock AL2023 arm64, CLI built from each head)

Round 1, at d13d7bd8: the measured MemTotal values are t4g.nano 422188 kB, t4g.micro 931880 kB and t4g.small 1885000 kB. The 768 MiB (786432 kB) floor separates the nano from the micro as intended.

But: acpid was active on all three, including the nano, where the install was skipped. AL2023 ships acpid. So the old dnf install -y acpid was a no-op that still loaded the repo metadata, the same load that OOM-killed the nano in #1515. And the nano's "not installed" message was false. That led to the revision.

Round 2, at a784e70d (enable a shipped acpid and install nothing):

nano micro small
acpid/dnf/yum lines in cloud-init-output.log 0 0 0
acpid / spored / systemd-resolved active / active / active active / active / active active / active / active
oom-killer events 0 0 0

The bootstrap's acpid step no longer touches a package manager on AL2023 at any size. The body sha256 is 3563692d…f739.

Teardown: all six test instances, across both rounds, are terminated and verified.

…nder 768 MiB (#1521)

On AL2023 yum is dnf, so 'dnf install || yum install' reran the install
dnf had just been OOM-killed in; on a t4g.nano that second run's OOM took
spored and systemd-resolved. Run dnf if present, else yum, else nothing,
never retrying under the other name; skip the install entirely when
MemTotal is under 768 MiB. The step stays non-fatal (#1274).

Changes the published bootstrap body: sha256
5782bdb0b4972dfb88050b0b2c412fcadc7ac8b0c72d5c98133a4e154cb141ce.
…nstalled' only when absent (#1521)

The AL2023 AMI ships acpid, so the dnf install was a no-op whose
repo-metadata load is what OOM-killed the t4g.nano, and the nano's skip
path then printed a false 'acpid not installed'. Look for acpid first
(command -v); install only when absent; decide the message by the same
check afterwards. Bare bootstrap gzip budget +16 (3 bytes over margin).

Published bootstrap body sha256 is now
3563692d194f446e3aca50030b0e6a24a9fb15a87594daf30b46271f0e93f739.
@scttfrdmn
scttfrdmn force-pushed the fix/1521-acpid-single-pm branch from a784e70 to df01584 Compare November 6, 2026 18:23
@scttfrdmn
scttfrdmn merged commit d990a89 into main Nov 6, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1521-acpid-single-pm branch November 6, 2026 18:45
@scttfrdmn scttfrdmn mentioned this pull request Nov 6, 2026
4 tasks
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.

bootstrap: acpid install retries with yum after dnf is OOM-killed (AL2023 yum = dnf), which later kills spored and systemd-resolved

1 participant