Repository navigation
feat(runtime): /ready reports cluster driver health when multi-replica is declared - #31711
Conversation
… on a declared multi-node deployment A declared multi-node deployment (OS_EXPECT_MULTI_NODE / OS_CLUSTER_REPLICAS>1) on the redis cluster driver now carries a cluster entry on /ready's 200 body; an unreachable store answers 200 status degraded, never 503. Single-node bodies, the booting/stopping 503 and the primary-datasource 503 are unchanged. Claude-Session: https://claude.ai/code/session_01ADHkmQwuHPnJPK768Mta39 Co-authored-by: Claude <noreply@anthropic.com>
…de redis deployment Claude-Session: https://claude.ai/code/session_01ADHkmQwuHPnJPK768Mta39 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmQwuHPnJPK768Mta39 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmQwuHPnJPK768Mta39 Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 2 package(s): 12 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 7 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 31 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin ee492c12222adc6570a81eaf5fff7c0ef75c071e && git checkout ee492c12222adc6570a81eaf5fff7c0ef75c071e
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin b126c13065db29c80996efc7e0527a40f651c923 eddeda2669372f860f711f81681ac43cc5e62bbc && git checkout -B drift-repro b126c13065db29c80996efc7e0527a40f651c923 && git merge --no-ff eddeda2669372f860f711f81681ac43cc5e62bbc
node scripts/docs-audit/affected-docs.mjs --json b126c13065db29c80996efc7e0527a40f651c923
|
…is deployment Claude-Session: https://claude.ai/code/session_01ADHkmQwuHPnJPK768Mta39 Co-authored-by: Claude <noreply@anthropic.com>
|
domain:server#4 · os-steve · session_01ADHkmP8JJo4zF2sjTBRwnX Contract reviewServed-tier: The face is the ① Derived judgments
② Semver levelThe changeset puts ③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:server#4 · os-steve · session_01ADHkmP8JJo4zF2sjTBRwnX ACCEPT · PR #31711 · #31601 · 2026-11-08T23:20ZHead-sha:
|
Requested by Steve · project thread
Fixes #31601
/readyreports the cluster driver's health on a deployment that declares multi-replica and runs the redis cluster driver: Redis unreachable answers 200 withstatus: 'degraded'and aclusterentry naming the driver unreachable (PM decision D4: never 503). Child of cloud epic #3814; Claim 6727414288 (domain:server#4, card-thread session_01ADHkmQwuHPnJPK768Mta39).Clause-②: yes (widening) — measured on base
1a20cbc8(the merge base; itshttp-dispatcher.tsrestored under this PR's pins) and headce30cfbf: on a declared multi-node redis deployment with Redis down, base answers200 {"status":"ready","state":"running"}(expected { status: 'ready', state: 'running' } to deeply equal { status: 'degraded', …(2) }, the200assertion above it passing), head answers200 {"status":"degraded","state":"running","cluster":{"driver":"redis","reachable":false,"reason":"ping-failed"}}(also with a live redis-server stopped, below). Every request keeps the status code base answered; the200body gains aclusterkey and thedegradedvalue ofstatusonly behind the declaration plus the redis driver. Nothing base accepted is refused.Metadata-protocol: none
维护者速读
OS_EXPECT_MULTI_NODE=true或OS_CLUSTER_REPLICAS>1)且集群驱动是 redis 时,/ready的 200 响应多一个cluster条目;Redis 不可达时status变为degraded,仍是 200。/ready一直是普通的 200,运维看不到集群已失去协调(锁、计数器、跨副本事件全失效)。不用 503 是 D4 的决定:所有副本同时失去 Redis,503 会把整个集群摘出负载均衡。packages/runtime/src/http-dispatcher.ts(clusterReadiness()与两个 200 分支)、packages/services/service-cluster/src/driver-health.ts、packages/runtime/src/http-dispatcher.ready.test.ts新增的 describe。pnpm --filter @objectstack/runtime exec vitest run src/http-dispatcher.ready.test.ts—— 预期 41 passed。What changes
packages/services/service-cluster/src/driver-health.ts(new) —probeClusterDriverHealth(cluster, driver, { timeoutMs }): reads the connection the driver offers (readClusterDriverConnection, the seam the shared cache already reads), sends onePINGbounded byDEFAULT_CLUSTER_PROBE_TIMEOUT_MS(500 ms), and answers{ driver, reachable: true }onPONG, or{ driver, reachable: false, reason }withreasonfrom a closed set:timeout,ping-failed,unexpected-reply,no-probe. Answersundefinedwhen the cluster offers no connection for that driver (memory driver, no cluster). Never throws. The client's error text (it names the store's host and port) is never carried, because/readyanswers anonymous callers. Exported from the package index with its types.packages/runtime/src/http-dispatcher.ts—clusterReadiness(): applies only whendeclaresMultiNode(process.env)holds (the split-brain guard's predicate) AND the host kernel'sclusterservice offers aredisconnection; memoized on the same 1 s TTL as the data-driver probe. It is consulted on the two200branches only, throughwithClusterReading(), which returns the body object as given when there is no reading. The booting/stopping503and the primary-datasource503return before it.packages/runtime/src/http-dispatcher.ready.test.ts— new top-level describe in the existing/readyharness (no existing assertion edited): the card's four acceptance cases plus secondary-degraded beside Redis down, the primary503never probing Redis, the memo, and R3's "one half missing" cases (no declaration,OS_CLUSTER_REPLICAS=1, memory driver, no cluster service, a throwing lookup).packages/services/service-cluster/src/driver-health.test.ts(new) — the probe's eight readings, including a late rejection after the timeout not leaking as unhandled..changeset/31601-ready-cluster-driver-health.md—@objectstack/runtimeand@objectstack/service-clusterpatch, both declaration lines, who sees it.No test was forced to change.
Tests
On head
04ca432f(the merge oforigin/main); the last commitce30cfbfadds one collection-time import to the/readytest file (forcheck:test-source-alias), and that file was re-run once30cfbf: 41 passed.pnpm --filter @objectstack/runtime testpnpm --filter @objectstack/runtime typecheck@objectstack/driver-turso, a devDependency outside the runtime closure:check:test-typecheckfirst readTS2307onorganization-ownership-boot-guard.turso-remote.kernel.test.ts, a missing dist, not this diff)pnpm --filter @objectstack/service-cluster test/typecheckpnpm --filter @objectstack/service-cluster-redis testpnpm exec eslint --no-inline-config packages/runtime/packages/services/service-clusterlintscript)pnpm --filter @objectstack/dogfood test(lock)04ca432f·VERDICT command-exit 0· Test Files 440 passed, 3 skipped (443) · Tests 3652 passed, 41 skipped (3693). Not re-run once30cfbf: that commit touches only a runtime test file, which dogfood does not load.Real Redis smoke: a live redis-server and the real ioredis driver behind /ready
A one-off script (not committed):
defineCluster({ driver: 'redis', url })from the built@objectstack/service-cluster-redis, the builtHttpDispatcher, a fresh dispatcher per probe, aredis-serverthis run started and stopped.The first probe after the stop reads
ping-failed(ioredis gives up aftermaxRetriesPerRequest: 3); later ones readtimeout(the client queues while reconnecting) and are bounded at 500 ms. Recovery needs no restart.Ablations (each through scripts/ablation-replace.mjs; restore proven by blob == HEAD and an empty git diff HEAD)
The runtime test imports
./http-dispatcher.jsfrom source and the service-cluster test imports./driver-health.jsfrom source, so no leg needed a rebuild or a dist preflight.if (declaresMultiNode(…))→if (true)no declaration … no ping,OS_CLUSTER_REPLICAS=1,#13408 body, no cluster key)503 Cluster unavailableRedis down: 200 — not 503 …detailskernel idle/initializing/stopping/stoppedpins… byte-identical 503, and never probes Redis(expected "vi.fn()" to not be called at all, but actually been called 1 times). The first attempt was refused by the tool (the replacement contained the anchor, anchor count 1 → 1) and ran no test; re-run with a different anchor.no-probe→reachable: truereads an offered client with no ping() as no-probe — never as healthyreasonping-failedpins (the closed-reasontoEqualreds before thenot.toContain('10.0.0.7')line is reached)After the run:
git diff HEADempty,git status --porcelainclean apart from the then-uncommitted changeset.Gates
Final round on head
ce30cfbf:node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 71 commands (change set: 6 paths vs merge base1a20cbc84); every one ran once and exited 0.dispatch-gates --ran:71 derived famil(ies) accounted for — 71 run, 0 NOT-MEASURED(exit 0).An earlier round on
04ca432fread three non-zero exits, all cleared:check-plugin-teardown-shape --self-testexit 3 (its pinned fixture commit was absent from the shallow clone; fetched, then exit 0),check:dual-build-cjs-loadsexit 3 (Run pnpm build first: dists outside the runtime closure; exit 0 afterturbo run build --filter='./packages/**'), andcheck:test-source-aliasexit 1 (the edited/readytest reaches a lazy@objectstack/metadataimport; fixed ince30cfbfwith the collection-time import the gate prescribes).The 71 commands and their exits on ce30cfb
Acceptance notes
probeClusterDriverHealthlives in@objectstack/service-clusterbesidereadClusterDriverConnectionso F3a can feed or replace it in one place;/readyonly reads theClusterDriverHealthshape.[ioredis] Unhandled error event: Error: connect ECONNREFUSED …on every reconnect attempt because the driver's client has noerrorlistener. That is fix(cluster)!: a Redis outage must not crash replicas; resync caches on reconnect (#3814 F3a) #31596's subject; this diff adds no listener.status: 'degraded'vs the availability: a datasource whose driver fails to start pins /api/v1/ready to 503 cluster-wide and is not evicted on delete — one bad tenant datasource drains every LB upstream #13408 secondary branch. A degraded SECONDARY datasource still answersstatus: 'ready'with adegradedobject (unchanged, single node included). The cluster reading usesstatus: 'degraded'as the card and D4 specify. When both hold on a declared deployment,statusisdegradedand both entries are present. Unifying the two was out of scope (it would change a single-node body).content/docs/protocol/kernel/lifecycle.mdx(theGET /readyblock) andcontent/docs/deployment/self-hosting.mdx(the probe table) do not yet mention theclusterentry; the claim's file surface excludescontent/docs/**, so this is left to the seat./ready's body has no schema inpackages/spec(searched before the first edit), so nothing in the spec moves.Generated by Claude Code