Skip to content

fix: tree-walk test flake (#1334); discard per-instance state inherited from an image (#1241) - #1339

Merged
scttfrdmn merged 2 commits into
mainfrom
fix/1334-1241-flake-ami
Oct 26, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
fix/1334-1241-flake-ami

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1334
Fixes #1241

#1334: tree-walk flake

TestReleaseBuildLeavesTheTreeClean created and removed dist/ and the before-hook outputs (lambda/ttl-reaper/build/bootstrap, the reaper zip) inside the checkout. Meanwhile tests in other packages walked the tree, so a walk could list an entry and then fail to lstat it.

Reproduced. I ran the taskiam test 50 times while the root test looped concurrently. Before: 11/50 and 5/50 failures, on lstat ../../dist, lstat ../../lambda/ttl-reaper/ttl-reaper_lambda_linux_arm64.zip and open ../../lambda/ttl-reaper/build, so skipping dist alone would not have fixed it. After: 0/50. Each half alone also gives 0/50.

  • The release gate now runs git --git-dir=<checkout> --work-tree=<tempdir> status. The temp tree holds the tracked .gitignore files and the probes, and GIT_OPTIONAL_LOCKS=0 is set. It still fails when /dist/ is dropped from .gitignore, which I checked.
  • TestReleaseTreeProbesStayOutOfTheCheckout: new gate that the probes stay out of the checkout.
  • internal/treewalk.Vanished: used by all 33 test tree-walks. The nested scripts module does the same check inline. TestTreeWalksTolerateVanishedEntries parses every Walk/WalkDir callback in the repo's tests and fails on one that returns its error without the check.

#1241: inherited per-instance state

pkg/instancestate records which instance owns the state in /var/lib/spawn/instance-owner. When that names another instance, it removes the files under instancestate.Paths modified before the current boot and records the new owner. Files written during this boot are kept: the launch's own plugins.json and command, and a peers file pushed over SSM. So it doesn't matter which runs first, and no lock is needed. The source keeps its state, because the owner is itself.

  • The bootstrap body runs spored discard-inherited-state || true after installing spored and before systemctl start spored, --command, profile scripts, MPI and user data. Bare bootstrap gzip size: 8001 → 8023 (budget 8192).
  • The daemon does the same in NewEC2Provider before loadConfigFromEC2Tags (Linux, root only). This covers instances launched from such an image by something other than spawn.
  • ImageStateCleanupScript (spawn ami create) records the source as owner before the snapshot, so images of instances launched by older releases are covered. It does not delete these files: the source keeps running and still needs them.
  • Paths (18): plugins.json, plugin state dir, push.token, queue.json, queue-state.json, compute-checkpoint.json, job-array.sh, job-array-peers.json, pipeline-peers.json, spawn-params.sh, session-timeout.sh, efs.sh, fsx.sh, command, mpi-command, task-flush.sh, staged-files.sh, bootstrap-body.sh. TestEveryWrittenStatePathIsCovered discovers every path under the state roots named in a non-test Go string literal. Each must be covered or have a reason for being left out (signing key, local.yaml, mpi.sh, efa.sh).

Not covered: an image of an older instance made outside spawn ami create, then booted without spawn's bootstrap and with that older spored (there is no owner record to compare). Windows. Root's MPI cluster SSH key, filed as #1338.

Gates, each watched failing against a revert that compiles

  • Owner check disabled → simulated image boot and ami-create→child tests fail.
  • Boot-time check disabled → the test fails on removed this-boot files.
  • Cleanup's owner write removed → the child-discard test fails.
  • Body line removed → the ordering gate fails.
  • A Path dropped → the discovery gate fails.
  • Provider call removed → the AST order gate fails.
  • Subcommand unregistered → the cobra test fails.
  • taskiam walker reverted → the treewalk gate fails.
  • createProbe writes into . → the probes-stay-out gate fails.

make check passes except check-build-tags, which fails on unmodified main at f887212 too (it's the /private/tmp path issue). make lint reports 0 issues. semgrep --config=auto --error . is clean. make check-docs is clean.

@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.92982% with 32 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/instancestate/instancestate.go 68.18% 21 Missing ⚠️
cmd/spored/inherited_state.go 70.00% 9 Missing ⚠️
pkg/provider/ec2.go 77.77% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

…rates vanished entries (#1334)

TestReleaseBuildLeavesTheTreeClean created and removed dist/ and the
before-hook outputs inside the checkout while tests in other packages walked
it, so a walk could list an entry and fail to lstat it (reproduced 11/50,
0/50 after). The gate now runs git status against the checkout's index with a
temporary work tree holding its .gitignores and the probes, and
TestReleaseTreeProbesStayOutOfTheCheckout holds it there. internal/treewalk
adds Vanished, used by every test walk callback; TestTreeWalksTolerate-
VanishedEntries discovers every Walk/WalkDir in the repo's tests and fails
on a callback that returns its error without consulting it.
… instance (#1241)

pkg/instancestate records the instance owning the per-instance state in
/var/lib/spawn/instance-owner; when it names another instance, files under
instancestate.Paths last modified before the current boot are removed and the
owner rewritten. Files written during this boot are kept, so the order of the
discard against the bootstrap's writes and the MPI peers push does not matter.
The bootstrap body runs 'spored discard-inherited-state' after installing
spored and before starting it; the daemon runs it in NewEC2Provider before
loading plugins.json. ImageStateCleanupScript records the source as owner
before the snapshot. Paths are held to every state path named in the source
by a discovery gate.
@scttfrdmn
scttfrdmn force-pushed the fix/1334-1241-flake-ami branch from 2ba8aea to 5214b8d Compare October 26, 2026 23:31
@scttfrdmn
scttfrdmn merged commit e16c57c into main Oct 26, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1334-1241-flake-ami branch October 26, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant