8000 fix(cluster): surface a degraded transport boot in /_cluster/health by xerj-org · Pull Request #1175 · xerj-org/xerj · GitHub
[go: up one dir, main page]

Skip to content

fix(cluster): surface a degraded transport boot in /_cluster/health - #1175

Merged
xerj-org merged 1 commit into
mainfrom
fix/cluster-degraded-health
Oct 6, 2026
Merged

xerj-org merged 1 commit into
mainfrom
fix/cluster-degraded-health

Conversation

@xerj-org
@xerj-org xerj-org commented Oct 6, 2026
Copy link
Copy Markdown
Owner

What

Addresses the remaining half of #1171. A configured cluster ring whose TCP transport failed to bind — or whose cluster-state storage was unavailable — degraded to single-node with one ERROR line at boot and then status: green forever on /_cluster/health. The operator believed the node was clustered; no API could say otherwise.

Root cause

The REST layer read the config (cluster.enabled — the ask) and had no field for the outcome (what the transport boot actually did). main.rs 8b recorded the outcome nowhere but the log.

Fix

  • xerj-api/state.rs — ClusterTransportStatus { Disabled, Running, Degraded } on AppState. The constructor cannot see a boot, so it seeds from the config alone (enabled -> Running, else Disabled — the model a direct-construction test of a configured ring assumes) and main.rs overwrites it with the truth before the first router exists (same default-then-overwrite pattern as --decide-mode at 9b-iia). A new field, not a constructor argument: AppState::new has ~126 call sites and none of them can know a boot outcome either.
  • xerj-server/main.rs 8b — the outcome starts Degraded on every enabled path and is upgraded to Running only inside the transport-Ok arm, so the bind-failure arm, the !storage_available arm, and any future early exit all inherit Degraded without each remembering to say so. Assigned at new section 9b-i.
  • xerj-api/es_compat.rs health — Degraded ⇒ status: yellow; node count drops to the 1 node actually serving (the configured peers are unreachable by construction — the transport that would reach them failed to bind — so counting them would be the fabrication cluster: REST endpoints fabricate multi-node topology — wait_for_nodes is echoed into number_of_nodes, _cat/nodes is a stub, health stays green with no ring #1169 removed, wearing the degraded state as a topology); and an additive xerj_cluster_transport: "degraded" field appears exactly when true, because yellow alone cannot distinguish "replicas unassigned" from "you are not clustered at all". Extra fields are additive on this wire (ES clients ignore unknowns; the ES-YAML assertions are match-shaped), so Running/Disabled responses stay byte-identical to before.

Deliberately not changed

The wait_for_status check stays red-only. The full observed <= requested comparison would start timing out wait_for_status=green on our yellow single-node replica indices — which the ES-YAML suite asks of exactly those. The narrowing comment at the site documents this; degraded-yellow surfaces via status/nodes/marker instead.

Tests (+4 in cluster_topology_honesty_tests)

  1. degraded health is yellow / 1 node / carries the marker
  2. degraded + wait_for_nodes=2 → 408 timed_out with the real count (and =1 still passes)
  3. the marker is absent on Disabled and Running states
  4. an unopenable index still outranks the marker — red is the headline, the marker rides beside it

The 6 existing #1169 tests pass unchanged.

Verification

  • cargo test -p xerj-api --lib: 335 passed / 0 failed; clippy clean; fmt clean
  • cargo build --release -p xerj-server: clean
  • ES-YAML on a private port (19501, throwaway data dir), 0 failed everywhere: cluster 10/0 · smoke 29/0 · indices 139/0 · search 452/0 (one co-tenant flake on the first run that did not reproduce) · bulk 21/0 · scroll 15/0 · aggregations 644/0

Issue #1171, remaining half. A configured ring whose TCP transport
failed to bind — port taken, address unusable — degraded to single-node
with one ERROR line and a "Continuing in degraded single-node mode"
warning, and then nothing: /_cluster/health answered
`status: green, number_of_nodes: 1` for the rest of the process life,
indistinguishable from an intentional single node. The same hole existed
on the !storage_available path (cluster-state storage unavailable), which
disabled the transport with one warn. An operator who configured a ring
had no API-visible signal that they were not getting one; only the boot
log held the truth, and only until it scrolled away.

Root cause: the REST layer could not know. It read the *config*
(cluster.enabled — the ask) and had no field for the *outcome* (what the
transport boot actually did), and main.rs 8b recorded the outcome nowhere
but the log.

Fix, in three small pieces:

- xerj-api/state.rs: `ClusterTransportStatus { Disabled, Running,
  Degraded }` on AppState. `AppState::new` cannot see a boot, so it seeds
  from the config alone (enabled -> Running, else Disabled — the model a
  direct-construction test of a configured ring assumes) and main.rs
  overwrites it with the truth before the first router exists, the same
  default-then-overwrite pattern `--decide-mode` already uses at 9b-iia.
  A new field, not a constructor argument: AppState::new has ~126 call
  sites and none of them can know a boot outcome either.
- xerj-server/main.rs 8b: the outcome starts Degraded on every enabled
  path and is upgraded to Running only inside the transport-Ok arm — so
  the bind-failure arm, the !storage_available arm, and any future early
  exit all inherit Degraded without each needing to remember to say so.
  Assigned to state.cluster_transport at new section 9b-i.
- xerj-api/es_compat.rs health: Degraded -> status yellow; node count
  drops to the 1 actually serving (the configured peers are unreachable
  by construction — the transport that would reach them failed to bind —
  so counting them would be the fabrication #1169 removed, wearing the
  degraded state as a topology); and an additive
  `xerj_cluster_transport: "degraded"` field appears exactly when true,
  because `status: yellow` alone cannot distinguish "replicas
  unassigned" from "you are not clustered at all". Extra fields are
  additive on this wire (ES clients ignore unknowns; the ES-YAML
  assertions are match-shaped), so Running/Disabled responses stay
  byte-identical to before.

Deliberately NOT changed: the wait_for_status check stays red-only. The
full `observed <= requested` comparison would start timing out
`wait_for_status=green` on our yellow single-node replica indices, which
the ES-YAML suite asks of exactly those — the narrowing comment at the
site documents this. Degraded-yellow surfaces via status/nodes/marker
instead.

Tests (cluster_topology_honesty_tests, +4): degraded health is yellow /
1 node / marked; degraded + wait_for_nodes=2 -> 408 timed_out with the
real count (and =1 still passes); the marker is absent on Disabled and
Running states; and an unopenable index still outranks the marker — red
is the headline, the marker rides beside it. The 6 existing #1169 tests
pass unchanged (the enabled->Running constructor seed models a ring that
came up, which is what they always assumed).

Verification: xerj-api lib tests 335 passed / 0 failed; clippy clean;
fmt clean; xerj-server release build clean. ES-YAML on a private port
(19501, throwaway dir): cluster 10/0, smoke 29/0, indices 139/0,
search 452/0 (one co-tenant flake on the first run that did not
reproduce), bulk 21/0, scroll 15/0, aggregations 644/0 — 0 failed
everywhere.

Addresses the remaining half of #1171 (the config-validation half landed
in #1172). Files:
- engine/crates/xerj-api/src/state.rs (ClusterTransportStatus, field, seed)
- engine/crates/xerj-server/src/main.rs (8b outcome, 9b-i assignment)
- engine/crates/xerj-api/src/es_compat.rs (health status/nodes/marker,
  cluster_topology_honesty_tests)
@cla-bot cla-bot Bot added the cla-signed label Oct 6, 2026
@xerj-org
xerj-org merged commit a7e78b7 into main Oct 6, 2026
22 checks passed
Ravandevil25 pushed a commit to Ravandevil25/xerj that referenced this pull request Oct 6, 2026
Version roll 1.0.0-rc.83 → 1.0.0-rc.84.

Engine window (all merged to main before this cut):
- xerj-org#1172 (fix/cluster-topology-honesty, closes xerj-org#1169): cluster endpoints
  stopped fabricating topology — health reports real configured
  membership, wait_for_nodes times out honestly (408 + timed_out),
  upper bounds enforced, _cat/nodes lists every configured member,
  _cluster/state reports the actual cluster address; multinode smoke
  skips with a recorded reason instead of passing vacuously. Also the
  xerj-org#1171 config half: peer-label≠address and cluster.port collisions
  refused at load.
- xerj-org#1175 (fix/cluster-degraded-health, closes xerj-org#1171 with xerj-org#1172): the
  transport boot outcome recorded on AppState
  (ClusterTransportStatus Disabled/Running/Degraded) before the first
  router exists; degraded boot → health yellow, number_of_nodes 1,
  additive xerj_cluster_transport:"degraded" marker; unopenable indices
  (red) still outrank the marker.
- xerj-org#1174 (fix/corpus-index-resume, xerj-org#1173 honesty half — throughput half
  stays open): xerj corpus index stopped reporting a converged corpus
  as a failed crawl; resume path re-crawls only what's missing.
- xerj-org#1167 (docs): hub counts un-staled — llms.txt:51 and the corpus-hub
  blog note said 75 live / 104 backlog from 2026-10-02; now 100/119.
- xerj-org#1163 (thomas-villani, docs): EPUB/notebook answer pages recaptured
  on the rc.83 build; \x08 man-page fact-check alias fix + self-test.

Mechanics of this commit:
- engine/Cargo.toml version → 1.0.0-rc.84; cargo update -w rolled 17
  Cargo.lock entries.
- landing/: 91 V1.0.0-RC.83 footer spans → V1.0.0-RC.84 across 54
  files (0 old spans remain); landing/index.html data-latest-tag span
  → v1.0.0-rc.84.
- CHANGELOG: [Unreleased] rolled into [1.0.0-rc.84] - 2026-10-06 with
  all five window PRs cited under Fixed.
- ROADMAP: Last-reviewed line → rc.84; open-defects shortlist
  re-verified live at cut time — eleven open (xerj-org#1091 xerj-org#1092 xerj-org#1094 xerj-org#1100
  xerj-org#1146 xerj-org#1147 xerj-org#1158 xerj-org#1122 carried forward, xerj-org#1168 xerj-org#1170 cluster
  liveness/leader-wiring, xerj-org#1173 throughput half); xerj-org#1169/xerj-org#1171 moved to
  the CHANGELOG; GA-window rc.84 paragraph added.

ES-YAML gate on the window PRs: 0 failed (452/452 re-run after one
non-reproducing co-tenant flake).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0