myxce/src/frontend/apiserver/backend
lei.chen 2bbe894f99 feat(apiserver): fail-fast circuit breaker when backend controller is down (Req 4)
component-failover-adoption Req 4: when the apiserver's controller connection
is down, backend-requiring API requests must return a clear service-unavailable
error rather than hanging. Adds:

- health.go: an atomic circuit breaker (IsDegraded/MarkDegraded/MarkHealthy).
- callBackend: the four write calls (jobsubmit/jobctrl/queuectrl/hostctrl)
  now route through it — degraded ⇒ immediate "backend controller unavailable"
  error without invoking the lib; a transport OR XCE not-ready/masterless/
  standby failure (E_XCE_NOMASTER/REDIRECT/NOT_READY/STANDBY) trips the breaker
  so the NEXT call fails fast. Semantic rejections (-EINVAL/-ENOENT/E_XCE_BAD_*)
  never trip it.
- StartHeartbeat: a failed tick marks degraded; recovery re-joins (rejoinBackend)
  and marks healthy.

Verified live (t1 cluster): kill controller → first submit returns
xcecli_jobsubmit failed: -10013 (bounded, no hang), second submit returns
"backend controller unavailable (reconnecting)" in ~11ms. 7 unit tests.
Recovery-via-heartbeat after a FULL controller death is NOT yet reliable — the
lib transport reconnect does not always re-establish to the restarted
controller (same class as the scheduler reconnect; tracked under task 13).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-14 05:20:52 +00:00
..
auth Merge Go frontend (apiserver + xcecli) into meson build 2026-04-14 11:23:18 +08:00
broker.go feat(apiserver): SSE job-event stream + EventBroker (Phase 2, ADR-004) 2026-08-12 08:30:18 +00:00
broker_test.go feat(apiserver): SSE job-event stream + EventBroker (Phase 2, ADR-004) 2026-08-12 08:30:18 +00:00
clib.go feat(apiserver): fail-fast circuit breaker when backend controller is down (Req 4) 2026-08-14 05:20:52 +00:00
config.go Merge branch 'working' into job_peek_lchen 2026-07-22 13:57:25 +08:00
control_host_test.go fix: address P0-2b review issues - build tag and actionType guard 2026-04-17 08:25:05 +00:00
convert.go feat(apiserver): expose PEND reason end-to-end (scheduler → API) 2026-08-13 09:16:13 +00:00
convert_pure.go feat(apiserver): expose PEND reason end-to-end (scheduler → API) 2026-08-13 09:16:13 +00:00
convert_test.go feat(apiserver): expose PEND reason end-to-end (scheduler → API) 2026-08-13 09:16:13 +00:00
handler.go feat(apiserver): SSE job-event stream + EventBroker (Phase 2, ADR-004) 2026-08-12 08:30:18 +00:00
handler_test.go feat(apiserver): SSE job-event stream + EventBroker (Phase 2, ADR-004) 2026-08-12 08:30:18 +00:00
health.go feat(apiserver): fail-fast circuit breaker when backend controller is down (Req 4) 2026-08-14 05:20:52 +00:00
health_test.go feat(apiserver): fail-fast circuit breaker when backend controller is down (Req 4) 2026-08-14 05:20:52 +00:00
heartbeat.go fix: P1-3 address heartbeat timer leak, test drain, and store consistency 2026-04-17 14:20:02 +00:00
heartbeat_test.go fix: P1-3 address heartbeat timer leak, test drain, and store consistency 2026-04-17 14:20:02 +00:00
integration_test.go fix front end issues 2026-05-01 21:22:45 +08:00
notification.go fix front end issues 2026-05-01 21:22:45 +08:00
peers.go refactor: simplify HA backend peer handling 2026-05-08 03:41:11 +00:00
peers_test.go feat: add HA candidate failover to API server backend 2026-05-08 03:31:35 +00:00
stub.go Init commit of jobs output/error message peek project. 2026-05-09 16:57:54 +08:00
stub_funcs_test.go feat: add HA candidate failover to API server backend 2026-05-08 03:31:35 +00:00
val_helpers.h test(apiserver): add integration tests for P0+P1 backend features 2026-04-18 11:56:31 +00:00
wire_dispatch_support.go fix(schema): rename struct Data -> XceData to unshadow capnp builtin blob type 2026-07-22 09:22:04 +00:00
wire_dispatch_test.go test(job-array-single-wal-record): end-to-end integration test for the compact push 2026-07-15 17:27:34 +00:00