Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 0068. A worker pauses warming and new devices under host memory pressure

- **Status:** Accepted — not yet implemented
- **Status:** Accepted
- **Date:** 2026-11-06
- **Issue:** [#1355](https://github.com/callstackincubator/simlock/issues/1355)
(from request [#1246](https://github.com/callstackincubator/simlock/issues/1246))
Expand Down
2 changes: 1 addition & 1 deletion docs/internal/adr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ the status is stale.
| [0065](0065-a-driver-owns-its-config-keys-and-a-module-takes-the-sections-it-reads.md) | A driver owns its config keys, and a module takes the config sections it reads | Accepted |
| [0066](0066-a-slim-lease-may-keep-named-categories-running.md) | A slim lease may keep named categories running | Accepted; narrows 0007 §8, §9, 0008 §4, §9, 0009 §2, §4 and 0060 §1, §2, §6 |
| [0067](0067-a-lease-has-a-file-folder-on-its-worker-that-http-callers-fill-and-read.md) | A lease has a file folder on its worker that HTTP callers fill and read | Accepted; narrows 0005 Non-goals (file transfer) and §19b′, 0026 §1 (a core relay target) and 0028 §4 (a file PUT's deadline) |
| [0068](0068-a-worker-pauses-warming-and-new-devices-under-host-memory-pressure.md) | A worker pauses warming and new devices under host memory pressure | Accepted — not yet implemented; narrows 0029, adds a rank stage to 0009 |
| [0068](0068-a-worker-pauses-warming-and-new-devices-under-host-memory-pressure.md) | A worker pauses warming and new devices under host memory pressure | Accepted; narrows 0029, adds a rank stage to 0009 |
22 changes: 22 additions & 0 deletions ui/src/model/fleet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,28 @@ describe("a worker's health square", () => {
});
});

describe("a worker's memory-pressure step", () => {
it("shows on the square as its own word, ahead of the pressure it comes with", () => {
const stepped = (step: string, pressure?: "warn" | "critical") =>
worker({
capacity: {
...capacity(4, 4),
memoryPressure: { step },
} as unknown as NonNullable<WorkerView["capacity"]>,
...(pressure === undefined ? {} : { load: load(30, 40, pressure) }),
});
const cases: readonly [WorkerView, string, string][] = [
[stepped("new-devices-paused"), "error", "new devices paused"],
[stepped("warming-paused"), "warn", "warming paused"],
[stepped("warming-paused", "warn"), "warn", "warming paused"],
[stepped("new-devices-paused", "critical"), "error", "new devices paused"],
[stepped("none"), "ok", "connected"],
[{ ...stepped("new-devices-paused"), connection: "disconnected" }, "error", "disconnected"],
];
for (const [w, tone, word] of cases) expect(workerHealth(w), word).toEqual({ tone, word });
});
});

describe("a worker with an issue", () => {
it("is one that is lost, failed, drained, starting, over its RAM budget, under memory pressure, or at 85% of CPU, disk or memory", () => {
const budget = { ...capacity(4, 4), ramBudget: { overLimit: true } };
Expand Down
16 changes: 15 additions & 1 deletion ui/src/model/fleet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const RANK: Readonly<Record<Tone, number>> = { error: 3, idle: 0, ok: 1, warn: 2
// why: a list row has room for one square, so of everything wrong with a worker the worst is
// shown and its word goes in the square's name; a worker with nothing wrong reads "connected".
export function workerHealth(worker: WorkerView): Toned {
return [...stateFindings(worker), ...loadFindings(worker)].reduce<Toned>(
return [...stateFindings(worker), ...stepFindings(worker), ...loadFindings(worker)].reduce<Toned>(
(worst, finding) => (RANK[finding.tone] > RANK[worst.tone] ? finding : worst),
{ tone: "ok", word: "connected" },
);
Expand All @@ -42,6 +42,20 @@ function stateFindings(worker: WorkerView): Toned[] {
return findings;
}

// why: the step comes before the pressure and figure findings so that, at equal tone, the square
// names what the worker refuses rather than the reading behind it. A worker not connected needs no
// guard: its error finding comes first and wins.
function stepFindings(worker: WorkerView): Toned[] {
switch (worker.capacity?.memoryPressure?.step) {
case "new-devices-paused":
return [{ tone: "error", word: "new devices paused" }];
case "warming-paused":
return [{ tone: "warn", word: "warming paused" }];
default:
return [];
}
}

// why: a reading from a worker that is not connected is stale, so it says nothing about the worker
// now; where memory reports a pressure, that word judges memory instead of its fill.
function loadFindings(worker: WorkerView): Toned[] {
Expand Down
10 changes: 10 additions & 0 deletions ui/src/model/stale-keys.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { describe, expect, it } from "vitest";

import { staleKeys } from "./stale-keys";

describe("a memory.pressure-changed event", () => {
it("marks the console's workers stale, and an unrelated event does not", () => {
expect(staleKeys("memory.pressure-changed", {})).toContainEqual(["workers"]);
expect(staleKeys("something.unrelated", {})).toEqual([]);
});
});
1 change: 1 addition & 0 deletions ui/src/model/stale-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function staleKeys(name: string, payload: unknown): readonly StaleKey[] {
case "queue.changed":
return REQUESTS;
case "capacity.changed":
case "memory.pressure-changed":
return WORKERS;
case "baseline.saved":
case "baseline.removed":
Expand Down
24 changes: 24 additions & 0 deletions ui/src/model/worker-page.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,30 @@ describe("a worker's load figures", () => {
expect(inspector.overview.read).toBe("12 s ago");
});

it("lists a Paused row on the Memory card while the worker's memory-pressure step pauses something", () => {
const paused = (step: string | undefined) =>
figure(
inspect(
worker({
capacity: {
...CAPACITY,
...(step === undefined ? {} : { memoryPressure: { step } }),
} as unknown as WorkerView["capacity"],
load: LOAD,
}),
),
"Memory",
)?.details.find((detail) => detail.label === "Paused");
expect(paused("new-devices-paused")).toEqual({
label: "Paused",
text: "new devices",
tone: "error",
});
expect(paused("warming-paused")).toEqual({ label: "Paused", text: "warming", tone: "warn" });
expect(paused("none")).toBeUndefined();
expect(paused(undefined)).toBeUndefined();
});

it("fills each meter to the figure's own percent", () => {
const inspector = inspect(worker({ load: LOAD }));

Expand Down
13 changes: 13 additions & 0 deletions ui/src/model/worker-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@ function limited(text: string, isLimited: boolean): string {
return isLimited ? `${text} (limit)` : text;
}

// why: the step names what the worker refuses to start, so the row is there only while it refuses.
function pausedDetail(worker: WorkerView): readonly LoadDetail[] {
switch (worker.capacity?.memoryPressure?.step) {
case "new-devices-paused":
return [{ label: "Paused", text: "new devices", tone: "error" }];
case "warming-paused":
return [{ label: "Paused", text: "warming", tone: "warn" }];
default:
return [];
}
}

function figureCards(worker: WorkerView): readonly FigureCard[] {
const { load } = worker;
if (load === undefined) return [];
Expand Down Expand Up @@ -243,6 +255,7 @@ function figureCards(worker: WorkerView): readonly FigureCard[] {
tone: pressureStatus(memory.pressure).tone,
},
]),
...pausedDetail(worker),
],
label: "Memory",
text: limited(
Expand Down
4 changes: 2 additions & 2 deletions website/src/content/docs/docs/worker/console.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ The square shows the worst thing wrong with the worker, and always has a word be

| Colour | When |
| --- | --- |
| Red | The worker's health is `failed`, its memory pressure is `critical`, or its CPU, memory or disk is 95% full or more. |
| Amber | The worker is `starting` or `over RAM budget`, its memory pressure is `warn`, or a figure is 85% full or more. |
| Red | The worker's health is `failed`, its memory pressure is `critical`, it has `new devices paused`, or its CPU, memory or disk is 95% full or more. |
| Amber | The worker is `starting` or `over RAM budget`, its memory pressure is `warn`, it has `warming paused`, or a figure is 85% full or more. |
| Green | Nothing is wrong. The word is `connected`. |

**Issues** shows only workers whose square is not green. **Busy** shows workers using three quarters of their device slots or more.
Expand Down
Loading