Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/DASHBOARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ launcher folder in the store) fold in the order they were written, so a host clo
stepped back (NTP) folds as before. A host clock that is off by more than the gap
between two hosts' records still orders those records by that clock, and records of
two hosts with the same `time_unix` fold in the order they are read (a known limit).
The spare-node events of a resident `ssh:` island (`island_node_lost`,
`island_waiting_spare`, `island_node_replaced`, `island_replacement_limit`) fold the
same way and share both limits: a host whose clock is behind by more than the gap
between two hosts' records can show a replaced island still waiting for a spare node,
and two hosts' events with the same `time_unix` fold in the order they are read. The
island's record in the run store (`fleet/trainers/<k>/state.json`) wins over the
events, so a page that reads the store shows the record's state either way.
For tools that read the file itself:

```
Expand All @@ -262,6 +269,17 @@ python -m yeto.dashboard.fleet_store merge --store s3://<bucket>/runs/<run> \

writes one `fleet.jsonl`, in time order, each record once.

A resident `ssh:` trainer island with spare nodes shows its wait for a spare node,
its lost node and why, and its replacements on its card, its tip and an extra
`Nodes` column of Islands now (a page without such an island has no new column).
It is out of the syncer roster while a spare takes a lost node's place (the roster
in the warning colour). Past `fleet.waiting_absent_after_s` (plan, default 1 h) it
reads `waiting for a spare node · counts as absent`. A wait past
`--spare-max-wait-s` (the record's, default 24 h), or one no record or event
reported for 1 h 12 min (the hourly wait report, two health periods and 10 min), is
not believed: the island reads lost, as one without spare nodes. Node checks stop on
purpose while the island recovers, so a check reads stale only while it runs.

## Alert rules and thresholds

| Rule | Default threshold | Level |
Expand Down
71 changes: 71 additions & 0 deletions tests/test_dashboard_island_health_relaunch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"""A resident ssh: island relaunched on the same nodes (own-cluster 4.5 review): its node checks kept over
the relaunch (``reset: true``, the old job's times) must not leave a healthy running island reading
"health unread (stale)" for good. The first check of the new job writes the record again
(``FleetController._health_key`` counts ``reset``), so the record's checks are the new job's."""

from __future__ import annotations

import json

from test_dashboard_island_spares import cards, reducer, smoke
from test_node_health_wiring import HealthCluster, _island, _tick, _wait
from test_rl_ssh_resident import NAMES, _controller
from test_rl_ssh_resident import _cards # noqa: F401 - autouse

from yeto.dashboard import fleet_islands
from yeto.launch import island_lifecycle as lifecycle
from yeto.launch.fleet import FleetController
from yeto.rl.engine.object_store import DirectoryObjectStore


def test_a_relaunch_on_the_same_nodes_reads_healthy_once_it_runs(tmp_path):
cluster = HealthCluster(NAMES)
ops, clock, _ = _island(tmp_path, cluster)
wall = [2_000_000_000.0]
for w in ops.islands["isl"].health.values():
w.clock = lambda: wall[0]
objects = DirectoryObjectStore(str(tmp_path / "store"))
store = lifecycle.IslandStateStore(objects, controller={"host": "t"}, clock=lambda: wall[0])
recorder = lifecycle.FleetRecorder(store, {"isl": lifecycle.IslandRef(island=1, source="ssh")})
ctl = _controller(ops, recorder=recorder)
rec = ctl.learners["isl"]
ctl._record(rec, reason="launched")
for _ in range(2): # two ok checks
wall[0] += 61
assert _tick(ops, clock) == "RUNNING"
ctl._health_events(rec)
# rank 2's trainer exits 1 (not a health loss): the island fails, its checks stop
cluster.exit("b300-2", 0, 1)
assert _wait(lambda: ops.islands["isl"].job.procs[2].poll() is not None)
wall[0] += 61
assert _tick(ops, clock) == "FAILED"
ctl._record(rec, lifecycle.RECOVERING, reason="rank 2 exited 1")
wall[0] += 240 # backoff, preflight and the container start on the same nodes
for w in ops.islands["isl"].health.values():
w.clock = lambda: wall[0]
assert ops.relaunch(None, "isl") == 1
ctl._record(rec, lifecycle.RUNNING, reason="relaunched") # the record keeps the old job's checks (reset)
kept = json.loads(objects.read(lifecycle.state_key(1)))["health"]["nodes"]
assert all(n.get("reset") for n in kept.values())
for _ in range(60): # it runs: ok checks every minute, an hour long
wall[0] += 61
clock.t += 61
assert str(ops.job_status("isl", 1)) == "RUNNING"
ctl._health_events(rec)
doc = json.loads(objects.read(lifecycle.state_key(1)))
assert doc["state"] == "running"
assert not any(n.get("reset") for n in doc["health"]["nodes"].values()) # the new job's checks
assert all(n["verdict"] == "ok" for n in doc["health"]["nodes"].values())
r = reducer()
assert r.load_fleet_state(fleet_islands.read_fleet_state(objects))
c = cards(r)["1"]
assert c["island_now"]["state"] == "running" and "node_health" not in c
out = smoke(tmp_path / "page", r)
assert not any("stale" in t for t in out["texts"]) and "stale" not in out["nodes"]


def test_the_health_key_counts_a_kept_check():
ok = {"verdict": "ok", "reasons": [], "at": 1.0}
key = FleetController._health_key
assert key({"nodes": {"a": ok}}) != key({"nodes": {"a": {**ok, "reset": True}}})
assert key({"nodes": {"a": ok}}) == key({"nodes": {"a": {**ok, "at": 99.0}}}) # times alone: no rewrite
Loading
Loading