Skip to content

fix(health-check): reset backends marked DOWN when the health check is removed - #1814

Merged
FlorentinDUBOIS merged 3 commits into
mainfrom
fix/health-check-remove-resets-backends
Oct 3, 2026
Merged

FlorentinDUBOIS merged 3 commits into
mainfrom
fix/health-check-remove-resets-backends

Conversation

@FlorentinDUBOIS

@FlorentinDUBOIS FlorentinDUBOIS commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

What

sozu cluster health-check remove now resets the backends a probe marked DOWN, as doc/health_checks.md already states. Server::remove_health_check_state only dropped the cluster from BackendMap::health_check_configs; it now goes through BackendMap::set_health_check_config(cluster_id, None), the path AddCluster takes, which resets every backend of the cluster to healthy and re-emits the availability gauges.

Every path that clears a health check:

  • RemoveHealthCheck: fixed (drops in-flight probes, then resets the backends).
  • AddCluster upsert without health_check: already reset the backends, but kept in-flight probes, whose own config copy (record_check_result uses check.config) could mark a backend DOWN after the reset. It now drops them too.
  • RemoveCluster: removes the backends outright; unchanged (the reset is a no-op on a removed cluster, record_cluster_availability returns early).
  • Master state replay: ConfigState holds no backend health and a fresh worker starts with healthy backends; a replayed AddCluster into a live worker takes the upsert path above.

Tests

  • server::remove_health_check_tests::remove_health_check_resets_a_backend_marked_down: red without the fix (backend stays DOWN), green with it.
  • server::remove_health_check_tests::add_cluster_without_health_check_resets_a_backend_marked_down: guard for the upsert path, which already reset; red when the set_health_check_config call is removed from Server::add_cluster.
  • e2e health_check_mode_tests::test_remove_health_check_restores_down_backend: two backends, one answering 404 on the probe path but 200 on traffic; waits until it is DOWN (health_check.down == 1) and excluded (10 consecutive requests to the other backend), sends RemoveHealthCheck, then requires a response from it. Two backends because a cluster with every backend down fails open. Without the fix: the backend marked DOWN never served traffic after RemoveHealthCheck; with it: ok.
  • Not covered: dropping the in-flight probes on the upsert path (needs a live probe socket in flight).

Validation: cargo +nightly fmt --check, cargo +1.93.1 clippy --all-features --all-targets --locked -- -D warnings, cargo +1.93.1 test -p sozu-lib --lib --all-features --locked (1588 passed), the 11 health_check e2e tests, the full e2e suite (--features opentelemetry,splice,simd -- --test-threads=4: 622 passed), check_doc_citations.py --base origin/main.

Interplay with #1809

#1809 (merged) rewrote the health-check remove paragraph of doc/health_checks.md to describe the behaviour this PR fixes. The merge of origin/main keeps this PR's wording (backends reset to healthy, in-flight probes dropped) and drops the clause of #1809's CHANGELOG entry that documented the old behaviour.

Fixes #1811

…s removed

`RemoveHealthCheck` only dropped the cluster from
`BackendMap::health_check_configs`: a backend a probe had marked DOWN stayed
out of rotation with nothing left to probe it UP again, until the cluster was
added again without a health check. `Server::remove_health_check_state` now
clears the health check through `set_health_check_config(cluster_id, None)`,
the path `AddCluster` already took, which resets every backend of the cluster
to healthy and re-emits the availability gauges.

An `AddCluster` upsert without a health check reset the backends but kept the
cluster's in-flight probes, whose own config copy could mark a backend DOWN
after the reset; it now drops them, as `RemoveHealthCheck` and
`RemoveCluster` do. `RemoveCluster` removes the backends outright, and a
master state replay reaches a fresh worker whose backends start healthy.

Worker-level tests cover both clearing paths, and an e2e test removes the
health check of a two-backend cluster after a probe marked one backend DOWN
and checks that backend serves traffic again (two backends, since a cluster
with every backend down fails open). doc/health_checks.md already described
the reset; it now names the in-flight probes and the upsert path.

Fixes #1811

Signed-off-by: Florentin Dubois <[email protected]>
…ve-resets-backends

#1809 rewrote the `health-check remove` paragraph of doc/health_checks.md
to describe the behaviour #1811 fixes; keep this branch's wording (backends
reset to healthy, in-flight probes dropped) and drop the clause of #1809's
CHANGELOG entry that documented the old behaviour.

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS merged commit 6c3b8e8 into main Oct 3, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

health-check remove does not reset backends marked DOWN

1 participant