Skip to content

Publish and refresh hybrid job-array peers for workloads and spored status (#933) - #976

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/933
Oct 17, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/933

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #933

Stacked on #966 (fix/939), which is on #940, #934 and #926. Review after those; the diff here is only this branch.

Contract chosen

Option (a) from the issue. The burst help's claim that instances "coordinate with local instances" is now backed by a file a workload can read.

  • Where: /etc/spawn/job-array-peers.json. This is the file and format spawn launch --mpi already uses: the cohort Assembler pushes it, and the MPI user-data builds its hostfile from it with jq. The format is a JSON array of {index, instance_id, ip, dns, provider}. The path and encoder now live in pkg/provider (JobArrayPeersFile, MarshalPeers, WritePeersFile, ReadPeersFile), and pkg/mpicohort uses them, so the two writers cannot drift. The existing byte-compat test still passes.
  • Who writes it: spored, for hybrid members only: spawn:burst=true on EC2, or a local-provider node in a job array.
  • Freshness: written at boot, then rewritten every minute (agent.PeerRefreshInterval, two registry heartbeats). This runs in its own goroutine, off the lifecycle loop (CRITICAL: spored monitor loop never runs after startup — TTL/idle/on-complete/pre-stop all silently dead #65). The write is atomic (temp file + rename) with mode 0644. A failed discovery keeps the previous file. The file's mtime is when the list was last confirmed.
  • spored status: job-array members get a peers section in the table and in -o json (peers). It shows the list, the file, the time since the last rewrite, the refresh interval, and stale when a spored-maintained list has missed three refreshes. A missing file is reported as "not written yet" or "no peers file", never as zero peers.

Tests (no AWS)

  • pkg/agent:
    • TestHybridMemberWritesItsPeersFile
    • TestPeersFileFollowsMembership: a later joiner appears, a leaver drops out
    • TestPeersFileKeepsTheLastListWhenDiscoveryFails
    • TestOnlyHybridMembersMaintainThePeersFile: burst and local write; MPI/ordinary and non-array members never write, checked through the running loop too
    • TestBootWritesTheHybridPeersFile: the real NewAgent, with every AWS credential source and IMDS removed so its registry registration cannot reach AWS
  • pkg/provider: round trip, atomic replace, empty list is [].
  • cmd/spored: the peers section in the table and JSON, stale flagging (and no staleness for an Assembler-written file), missing file, and buildStatusReport wiring (burst member has it, non-array instance does not).

Each was watched failing against a compiling revert:

  • the write skipped: 5 agent tests fail
  • the loop parked: the membership test fails
  • every job-array member writing: the hybrid-only test fails
  • status wiring disabled: the wiring test fails
  • staleness disabled: the stale test fails
  • the file emptied on discovery failure: the keep test fails
  • boot write skipped: the boot test fails

make check: all packages pass except the known Docker-only TestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker. make check-nested: all 9 nested modules clean. -race is clean on agent, spored, provider and mpicohort. Public surface unchanged (pkg/provider is not in it). docs-gen/burst.md is regenerated for the help change.

Caveats

  • Peers are refreshed by polling. A member that leaves stays listed until its registry entry's expires_at passes. That is the registry's existing TTL (1h, refreshed by the 30s heartbeat), and this PR does not change it. EC2 siblings drop out as soon as they leave pending/running.
  • A local node whose spored cannot write /etc/spawn (not root) logs the failure once, and spored status reports the error or staleness. There is no alternate path.
  • Not observed on a live instance: no instances were launched.
  • Separately found while working here: pkg/agent unit test registers a real spore.host DNS record with ambient credentials #968. TestNewAgent_StillActivates in pkg/agent registers a real spore.host DNS record with ambient credentials on every local make check.

…tatus (#933)

spored discovered a job-array member's peers once, at boot, and only logged
the count. Nothing stored the list, wrote it anywhere, showed it in spored
status, or looked again, so a burst member's workload had no way to learn the
local nodes #918 made discovery find, and the boot-time count was a lower
bound because most siblings had not registered yet.

For a hybrid member (spawn:burst on EC2, or a local-provider node) spored now
writes the merged list to /etc/spawn/job-array-peers.json, the file and
format spawn launch --mpi already uses (pkg/mpicohort), and rewrites it every
minute from its own goroutine, off the lifecycle loop (#65). The path and the
encoder now live in pkg/provider (JobArrayPeersFile, MarshalPeers,
WritePeersFile, ReadPeersFile) and mpicohort uses them, so the two writers
cannot drift. Writes are atomic (temp file + rename, 0644). A failed discovery
keeps the previous file.

spored never writes the file for any other member. For --mpi the file's
arrival is the user-data's release signal, ordered after the cluster SSH key
push (#684), so a spored write could release a node early.

spored status (table and -o json) gains a peers section for job-array
members: the list, the file, when it was last rewritten, and whether a
spored-maintained list is stale (three missed refreshes). spawn burst's help
says where the list is.

Tests: write, refresh (join and leave), keep-on-failure, hybrid-only (MPI and
ordinary members never write, also through the loop), boot write through the
real NewAgent with every credential source removed, and status read, stale
and missing-file handling plus the buildStatusReport wiring. Each was watched
failing against a compiling revert.

Fixes #933

(#933)
@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.65789% with 37 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/provider/peers_file.go 42.10% 12 Missing and 10 partials ⚠️
cmd/spored/main.go 81.48% 7 Missing and 3 partials ⚠️
pkg/agent/agent.go 66.66% 2 Missing and 2 partials ⚠️
pkg/agent/peers.go 97.87% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit e64b2a8 into main Oct 17, 2026
8 checks passed
@scttfrdmn
scttfrdmn deleted the fix/933 branch October 17, 2026 07:50
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.

spored discovers job-array peers once at boot and only logs the count; nothing consumes the result

1 participant