Skip to content

ssh islands: replace a lost node of a resident trainer island with a spare (own-cluster 4.1-4.4) - #885

Merged
michaellchung merged 4 commits into
mainfrom
own/island-spares
Nov 26, 2026
Merged

michaellchung merged 4 commits into
mainfrom
own/island-spares

Conversation

@michaellchung

@michaellchung michaellchung commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A resident ssh: trainer island replaces a lost node with a spare node of its inventory (own-cluster-fleet-stability tasks 4.1-4.4).

Rebased onto main with #882/#883/#884/#889/#892/#896/#897/#898 in: it uses the real node_health.checker_for (a NullChecker family gets no spare), HealthWatch/hcas_of, the _node_health_lost hook of the resident health tick, and the real NodeLeases (acquire, held, keep_all(nodes=), force_release(holder=, force=), ssh_probe, pick_nodes(excluded=)). A spare is picked only after a node health check has run and passed; when an inventory declares trainer-spare nodes but its device family has no checker, the spares do not apply at all: spares_from_args returns None and a WARN (also in the dry run) says the island is relaunched on its own nodes, as on main.

Placement uses the real fabric_groups.pick_placement(candidates, need, *, excluded=, required=, inventory=) (#892). Its PlacementError becomes the island's wait reason (...; placement: <its text>); any other error, a TypeError included, is raised. yeto cluster release-node is a subcommand of yeto cluster (yeto/cluster_release_node.py, hooked into yeto/cluster_cli.py).

  • Spares are declared by role: an inventory node with roles: [trainer-spare] is a spare. island_nodes(..., "trainer") does not match it, so the island's node count check, its dry run and every customer path are unchanged. An inventory without spares (the 6 x 8 B300 K3.1 layout takes every node) loses a node exactly as on main.
  • 4.1 lost node: a node is lost when (a) its log stream (the SSH heartbeat) ended and it then fails unreachable_polls SSH checks in a row, or (b) its health turned bad twice in a row (SshIslandOps._node_health_lost(rec, rank, reasons, reading); a reading that names another node than the rank's current one is ignored). A node whose stop is not confirmed when the island fails keeps its stream. The usual power-loss order is that rank 0 exits first and the dead node's stream ends minutes later. Such a node is checked with ssh true at each relaunch poll. It is lost after unreachable_polls checks in a row without an answer once its stream has ended, or after 2 x unreachable_polls while its stream is still open. The higher bar keeps a node whose sshd refuses new sessions while the old connection lives from being quarantined. An SSH hiccup with the stream still flowing, followed by an answer, is no loss.
  • What happens on a loss: island_node_lost is written, and the island is stopped on its other nodes; the lost node is not waited for. The node is quarantined: fleet/nodes/<name>/quarantine.json in the run store records the stop it still owes. With a lease_store, the record is also written to nodes/<name>/quarantine.json there, next to the lease and event objects, so every run's pick skips the node. A lost node that still answers is stopped in the background, outside the ops lock; once that stop is confirmed it owes nothing. Ledger: the incarnation's row closes, and a node that still owes its stop gets its own row (its rank and price only) so yeto cleanup still stops it.
  • 4.2 pick: pick_placement(survivors + spares, len(survivors) + 1, excluded={name: reason}, required=survivors, inventory=pool). The nodes that stay are required: they never move, and a placement that drops one is no placement; the reserved group unavailable never joins a multi-node island. excluded names every node that is out with its reason: quarantined (the lost node too), held by another island, leased by another run, unhealthy (the health check's text), checked before. Nodes that are quarantined, held by another island of the run, or leased by another run are filtered out first. The health checks run before the pick, outside the ops lock. A check must have run and passed; an SSH answer alone is not enough, and a family without a checker gets no spare. The pick then claims the node (an exclusive create of fleet/nodes/<name>/claim.json) and takes its lease, reading the records again. A node whose claim or lease fails is excluded and the pick runs again. A store without an atomic create (for example the OSS relay) is refused for claims.
  • 4.3 replace and resume: the island is rendered again with the spare in the lost node's place (same learner id, same layout; a lost rank 0 hands the rendezvous to the spare). The next incarnation resumes from the learner's own newest checkpoint: island-cuts/island<learner id>/LATEST (the learner id from sample_roles.island_learner, e.g. --rl-fleet-learner-id of a per-island launch, not the island index), or its release in trainer<k>/policy-releases/ when its samplers follow it. island_node_replaced names the old node, the new one and the resume step. A journal next to the jobs journal keeps each incarnation's nodes, so a restarted launcher reattaches on the spare.
  • 4.4 waiting and limit: without a spare the island is in waiting_spare, checked again after 60 s, doubling up to 900 s, with an hourly island_waiting_spare that carries elapsed_s. The fleet controller does not give it up on --recover-timeout, and says its retry line every 15 min instead of every poll. A waiting island still counts toward fleet.min_islands for fleet.waiting_absent_after_s (run config, default 3600 s) after its wait began, then as absent; the island record carries spares.waiting_since. This decides whether the fleet goes on. --spare-max-wait-s decides when the island itself is given up. Past --spare-max-wait-s (default 24 h, a fixed roster too; the wait's start is kept in the journal) the relaunch is refused and the island is given up. At 3 replacements within 24 h the next loss also refuses the relaunch, and island_replacement_limit lists every replaced node. A launcher restarted while its island waits now starts: the quarantined node is lost again, and the waiting goes on.
  • Leases on the production path: the island's spec.leases (from trainer_leases) is the spares' NodeLeases, and its store holds the shared quarantine. A start takes the leases of the island's current nodes (a restarted launcher on a spare; another run's lease refuses the start) and keeps the leases of this run's quarantined nodes out of the renewals (keep_all(nodes=...)). A lost node's lease is kept at once, and its quarantine records the lease holder. lease_trainer_nodes passes shared_quarantined_names(leases.objects) in pick_nodes(excluded=...), so no run picks a node quarantined in the lease store (a leaf module node_quarantine keeps the launch imports acyclic). The pick names each such node with the run and island that quarantined it, the reason and how to release it: once before the pick, on every waiting line and in the final error, not just "no free node". The health watches are rebuilt for the new node set after a replacement.
  • Release: island_spares.release_node_main is the body of yeto cluster release-node <name> --inventory --store [--dry-run] [--force] [--kill-grace-s]. It requires a health check that ran and passed; --force skips the check and prints a WARN. It runs the owed stops and closes their ledger rows. Then the lease of the recorded holder: force_release(node, holder=...) ends a kept or run-out lease; a live one ends only after ssh_probe found nothing of that run on the node, then force_release(..., force=True); a lease another run holds is not touched. Any failure keeps the quarantine (exit 1, no traceback); only then is the record removed. Nothing lifts a quarantine on its own.
  • Docs: docs/OWN_CLUSTERS.md gets a "Spare nodes" section (declaring spares, when a node is lost, the pick, waiting and the two times, the limit, release-node, known limits), and the Node leases section points to it.

Review fixes (REV-885c)

  • A node's confirmed stop is kept per (node, incarnation), and dropped when the node is picked again, so a later loss of its new incarnation owes its stop (its own ledger row) again; a confirmed stop owes no row even when its quarantine record could not be updated.
  • Leases across a launcher restart: after a replacement the run dir's lease record names the island's current nodes; the recorded lookup knows trainer-spare nodes; a reattach holds the current nodes' leases (_hold_leases) and gives back a lease of a node the record still named but the island no longer runs on (unless quarantined or another island's).
  • release-node on a machine without the run's ledger says where the owed row is; the launcher closes its own owed rows of a node it picks again with no quarantine record (reason: released elsewhere), so the node is billed once.
  • A shared quarantine record that cannot be read (store error or not JSON) counts as a quarantine in the spare pick and the trainer pick (quarantine record unreadable: ...); a listing failure reads each node's record instead; a running island's node is not taken as lost on a store read error.
  • down() does not wait for a lost node.
  • The stale-reading guard no longer relies on a node field (the real node_health.Reading has none): the resident tick stamps a lost reading with the rank's node and its replacement count, and the hook ignores a stamp that no longer matches (kept when ignored, so asking again is ignored too).
  • A spare's health check reads the island's job ports (node.env with the job env over it), as the island's own watch does.
  • The spare wait reason names another run's quarantine (run, island, reason) and the release command, as the trainer pick does.
  • release-node --dry-run lists the records it would remove (run store and lease store) and what it would do with the lease; an unreadable quarantine record needs --force (the owed stops cannot be known).
  • Each backoff check of a waiting island retries the stops its quarantined nodes still owe, in the background, so a node back from a network partition stops its old container.

Review fixes (REV-885d)

  • A settle never rewrites a quarantine record. The stores have no conditional replace, so a confirmed owed stop is kept as a marker of its own (fleet/nodes/<name>/settled/<run>-<island>-i<k>.json, exclusive create) and the owed list leaves those out. release-node first writes a timestamped released.json tombstone in both stores, then removes the markers and the records; a settle that finds a tombstone newer than the record writes nothing. A settle racing a release therefore never brings the quarantine back, in the run store or the lease store.
  • Owed stops read the quarantine record again before each kill and skip a stop it no longer lists (released meanwhile, or another island's); the ledger row closes in a finally even when the marker cannot be written.
  • A confirmed owed stop removes the incarnation's pid file and leaves a stopped marker in its state dir; kill_script exits 0 on that marker, so a later stop (release-node, yeto cleanup) neither signals a reused pid nor fails on the missing pid file. The process group is not checked against the run beyond the pid file in the run's own state dir (docstring).
  • The run's lease record is written before the start on a spare and put back if that start fails; lease_trainer_nodes takes the island's nodes from its spares journal (newest incarnation) before the lease record, so a launcher that went mid-replacement restarts on the spare. Every start path (launch, start without a quarantined node, reattach) gives back leases of old nodes the island no longer runs on, except another island's pick or claim; assigned keeps another island's nodes.
  • A node picked again without a quarantine record (release-node elsewhere, --force over a broken record, a run store kept in memory) runs the stops of its open owed rows first; only rows whose stop succeeded close (released elsewhere).
  • down() and close() join the owed-stop retries with a short timeout and drop finished ones.
  • Docs: the release section states these guarantees.

Notes

  • By design: with a lease_store, a trainer node another run quarantined is left out of the trainer pick; when the inventory has no other free trainer node the new run waits --rl-node-lease-wait-s and fails with the note above; it does not start on a spare in its place.

Tests

  • tests/test_ssh_island_spares.py (36): loss rules, replacement in the same layout (rank 1 and rank 0), restart following the journal, the pick rules (fabric group, unavailable, quarantine, claims and a claim lost to another island, leases, health, by name), the pick through the real pick_placement (the nodes that stay passed as required, need = island size, the lost node in excluded as quarantined, a spare whose health check fails added to excluded with the check's text and asked again, the nodes that stay unchanged after the replacement), the nodes that stay kept when another group has more free nodes, a PlacementError as the wait reason, a TypeError (one string as excluded, or raised inside pick_placement) raised, an excluded required node and a placement that drops a required node refused, backoff, replacement limit, the fleet controller waiting past its recover timeout, an island given up while another runs on, no spares as on main, dry run, release-node, the release-node subcommand's flags and exit codes, and the documented yeto cluster release-node ... --dry-run through cluster_cli.
  • tests/test_ssh_island_spares_recovery.py (83): as before (power-loss order, the 2x rule for open streams, sshd refusing new sessions, max wait and hourly report, fleet.waiting_absent_after_s 3599/3601 s and single-island/fleet cases, owed stops and ledger rows, per-learner resume keys, the no-checker note, the shared quarantine, a restart while waiting, a stale health reading, no SSH under the ops lock, non-atomic stores), plus: release-node probes a live lease before force=True and refuses a node that still runs the run; a kept lease of another run is not ended; the lease ended is the record's lease_holder when the command runs under its own holder; the quarantine names the lease holder and a restarted launcher keeps the quarantined lease out of the renewals; the trainer pick leaves out a node quarantined in the lease store (real NodeLeases on a fake S3 store, node_lease keys not mistaken for a quarantine) and names the quarantining run and island, the reason and release-node before the pick, on the waiting line and in the error; the island's own spec.leases hold the spares and the shared quarantine; a start on a node another run holds is refused; the health watches rebuilt on the new node set; and for the review fixes: a node picked again then power-lost, or health-lost with a failed stop, owes its stop again; a confirmed stop with a failed record update owes no row; with real NodeLeases, a restarted launcher renews its spare's lease, does not hold a released old node (stale record), and reattaches when another run took the old node; release-node away from the run's ledger says where the row is and the launcher closes it once; unreadable shared quarantines (store error, broken JSON, failed listing) keep nodes out of both picks, and a store error does not lose a running node; down() with a lost node; stale health readings with the real Reading (a replaced rank, the same node back after two replacements, asked twice); the spare check's job ports; the dry run's lease and record plan; a broken record needing --force; an owed stop retried after a partition heals. For REV-885d: a settle racing release-node (between its read and its write, with another run leasing the node meanwhile) writes nothing back in either store and leaves no marker; an owed-stop retry racing release-node leaves the node released; a settle after a newer tombstone writes nothing; a settle clears only that node's stop of that incarnation, and a release leaves only the tombstone; an owed stop reads the record again and skips a node released meanwhile, and never runs another island's stop; the row closes even when the settle fails; a confirmed stop already settled is not owed again after a restart; a stopped node owes no row at a later release; the owed stop run by bash removes the pid file and leaves the marker, a second try and the plain kill script exit 0, a failed stop keeps the pid file (the stopped group is not a child of the test, so a zombie does not keep it alive on Linux); a launcher gone mid-replacement restarts on the spare and neither holds the released old node nor is refused by another run's lease on it; a failed start on a spare puts the lease record back; a start gives back a stale lease, but not another island's pick or claim, and assigned keeps that island's node; a reattach takes the spare's lease when its pick did not; retries run only while waiting and only the island's own owed stops; --force over a broken record, a failed stop and a run store kept in memory each stop the old incarnation before the row closes (a failed stop keeps it open); down() and close() join the retries.
  • tests/test_ssh_island_spares_e2e.py (real Rust syncer, local store, fleet controller over the fake SSH cluster, fake trainers): island 1 loses its rank 0 node while holding a PULL, the spare takes its place, and the island re-JOINs under its learner id, resuming from its own trainer1/policy-releases/LATEST.json. Asserted: merge sequence 1..N with every step once; no fragment pushed twice; resume step equal to the newest checkpoint step; catch-up and final weights equal to the f32 Nesterov recomputation within 1e-6; island 0 on one connection with a push in every merged round. Its syncer binds port 0 and the test reads the bound port from its own log. 1 passed (7 of 7 runs).
  • tests/test_trainer_provision.py: the stub of start_resident_ssh takes the new keywords and asserts them.
  • Mutation: 129 of 129 mutants killed (13 earlier, 44 for the first review, 24 for the rebases, 21 for REV-885c: per-incarnation stopped and its reset on a pick, the lease record and the reattach's leases, the recorded spare lookup, the released-elsewhere close and the row note, unreadable quarantines in both picks and the running-node guard, down() skipping lost nodes, the stamp and the rank generation, the job ports, the other run's quarantine in the wait reason, the dry run's lease plan, the broken record's --force, the owed-stop retry; 27 for REV-885d: the settle rewriting the record, no tombstone check, no tombstone, markers kept on release, markers ignored, no re-read before the kill, the re-read ignoring the island, the row closed only when the settle succeeds, no join in down() or close(), no pid file removal, kill_script ignoring the marker, a close without the stop, a failed stop closing, the journal not used, the record written after the launch, no rollback, no stale release at a start, the claim-holder and other-island guards, retries not only while waiting, retries not filtered by island, the old node kept in assigned, another island's node dropped from assigned, _owes always true, a settle clearing every row; plus the earlier mutants re-anchored).
  • The whole python suite locally on this head's tree, as CI runs it (4 shards, --timeout=600): 18355 passed, 377 skipped, 11 xfailed, 0 failed. On an earlier base, one shard run hit test_node_lease.py::test_podman_needs_the_users_view_and_with_sudo_the_rootful_one, which saw a local process of another job (passes alone on main and on this branch; tracked separately).

Customer gate

  • 52 customer goldens: 52 passed.
  • examples/k31 dry runs (run up and nc pool), normalized: 6 of 6 normalized outputs (4 run up dry-run and preflight logs, 1 nc pool dry-run, the golden file diff) identical to main line by line.

🤖 Generated with Claude Code

michaellchung and others added 3 commits November 27, 2026 02:12
…iner island

A resident ssh trainer island whose inventory lists trainer-spare nodes
replaces a lost node (stream ended plus failed ssh checks, or node health
bad twice in a row) with a healthy spare of the same fabric group, in the
same layout, and resumes from its learner's newest checkpoint. The lost
node is quarantined in the run store and, with a lease_store, for every
run; its lease is kept until yeto cluster release-node. Without a spare
the island waits with a backoff; fleet.waiting_absent_after_s and
--spare-max-wait-s bound the wait; at most 3 replacements per 24 h.

- pick_placement with required=<nodes that stay> and excluded reasons
- the island's own NodeLeases; release-node probes a live lease before
  force=True; the trainer pick leaves quarantined nodes out and says why
- yeto cluster release-node; docs/OWN_CLUSTERS.md Spare nodes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…luster release-node

- the spare pick calls fabric_groups.pick_placement (#892) directly with
  required=<nodes that stay> and excluded={name: reason}: quarantined,
  held by another island, leased by another run, unhealthy, checked
  before; the local placement stub is gone
- a PlacementError becomes the island's wait reason; any other error,
  TypeError included, is raised
- yeto cluster release-node is a subcommand of yeto cluster; the hint no
  longer says it is unavailable

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uarantines)

- a confirmed stop is kept per (node, incarnation) and dropped when the
  node is picked again; a later loss owes its stop again
- after a replacement the run's lease record names the current nodes; the
  recorded lookup knows trainer-spare nodes; a reattach holds the current
  nodes' leases and gives back a stale old node's lease
- release-node away from the run's ledger says where the owed row is; the
  launcher closes owed rows of a node it picks again (released elsewhere)
- an unreadable shared quarantine counts as one in both picks; a listing
  failure reads each record; a store error loses no running node
- down() skips lost nodes; health readings are stamped with the rank's node
  and replacement count; the spare check reads the job's ports
- no checker: spares do not apply (WARN); the wait reason names another
  run's quarantine; release-node --dry-run lists the lease and records; a
  broken record needs --force; backoff checks retry owed stops

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…osed after their stop

- A confirmed owed stop never rewrites the quarantine record: it is kept as a
  marker of its own (fleet/nodes/<n>/settled/, exclusive create), and
  release-node first writes a timestamped released.json tombstone in both
  stores, so a settle racing a release writes nothing back. Owed stops re-read
  the record before each kill; the ledger row closes in a finally even when the
  marker cannot be written.
- A confirmed owed stop removes the incarnation's pid file and leaves a stopped
  marker; kill_script exits 0 on that marker, so a later stop never signals a
  reused pid and never fails on the missing pid file.
- The run's lease record is written before the start on a spare and put back if
  that start fails; the trainer lease pick follows the island's spares journal;
  every start (launch, start without a quarantined node, reattach) gives back
  stale leases, except another island's pick or claim.
- A node picked again without a quarantine record runs the stops of its open
  owed rows first and closes only the rows whose stop succeeded.
- down() and close() join the owed-stop retries briefly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@michaellchung
michaellchung merged commit 73b7da5 into main Nov 26, 2026
7 checks passed
@michaellchung
michaellchung deleted the own/island-spares branch November 26, 2026 19:33
michaellchung added a commit that referenced this pull request Nov 26, 2026
…are and is replaced

Over #885's spare nodes: the poll that finds the loss clears the report
(recovering), the island is not counted while it waits for a spare, and on
the spare it is a new launch with its catch-up grace; past its recover timeout
it is reported N cycles later. The dashboard keeps the card's mark and state
with the spare events in between.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
michaellchung added a commit that referenced this pull request Nov 26, 2026
…are and is replaced

Over #885's spare nodes: the poll that finds the loss clears the report
(recovering), the island is not counted while it waits for a spare, and on
the spare it is a new launch with its catch-up grace; past its recover timeout
it is reported N cycles later. The dashboard keeps the card's mark and state
with the spare events in between.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant