Repository navigation
feat(k8s): mesh self-heal detect+recover for post-suspend 503 (Part of #1899) - #2179
Conversation
…rossoctl#1899) Add scripts/k8s/mesh-recover.sh (detect the Istio Ambient expired-cert 503 outage on long-running/suspended dev clusters; --fix restarts ztunnel + waypoints + gateway) and the istio:mesh-selfheal skill. Includes scripts/k8s/induce-mesh-outage.sh, a Kind-guarded test harness that induces the symptom and verifies the detect -> fix -> re-probe loop. Read-only by default; dev/Kind scope. Durable data-plane fix tracked upstream (istio/ztunnel#1679). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
clawgenti
left a comment
There was a problem hiding this comment.
Adds mesh-recover.sh + induce-mesh-outage.sh and the istio:mesh-selfheal skill — a clean, well-scoped detect/recover tool for the post-suspend Ambient 503 outage. All checks pass. Ready for human review.
Reviewed by clawgenti using github:pr-review
| fi | ||
| elif [[ "$code" == "000" ]]; then | ||
| record "mesh-reachability" "INCONCLUSIVE" "could not connect to ${GATEWAY_URL} — is the Kind port-map / port-forward up?" | ||
| log_warn "Gateway ${GATEWAY_URL} unreachable (curl 000). Not a 503; check the port-map. Treating as needs-attention." |
There was a problem hiding this comment.
nit: INCONCLUSIVE cases (curl 000, no ztunnel found) set DEGRADED=true inline rather than via record(), so they show up inconsistently in the JSON output — the record() call records INCONCLUSIVE status but the outer DEGRADED flag is set separately. Consider routing through record "mesh-reachability" "INCONCLUSIVE" "..." and then checking for both DEGRADED and INCONCLUSIVE statuses when deciding the exit code, for consistency.
| HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| RECOVER="${HERE}/mesh-recover.sh" | ||
|
|
||
| usage() { grep '^#' "$0" | sed 's/^# \{0,1\}//; 1d'; } |
There was a problem hiding this comment.
nit: usage() parses comment lines from the script header (grep '^#' "$0" | sed ...) — this is a common pattern but fragile if the shebang or leading comment format ever changes. Since the help text is short, an explicit cat <<'EOF' heredoc (like mesh-recover.sh uses) would be more robust.
- mesh-recover.sh: route INCONCLUSIVE through record() instead of setting DEGRADED inline; add a distinct INCONCLUSIVE state so an unreachable gateway (curl 000 = port-map issue, not a mesh outage) no longer triggers a pointless restart. New exit code 3 = inconclusive; JSON gains an "inconclusive" field. - induce-mesh-outage.sh: replace the comment-grep usage() with an explicit heredoc (robust to header/shebang changes). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
clawgenti
left a comment
There was a problem hiding this comment.
Adds mesh-recover.sh, induce-mesh-outage.sh, and the istio:mesh-selfheal skill — a well-scoped detect/recover tool for the post-suspend Ambient 503 outage. Both scripts use set -euo pipefail, DCO sign-off is present on all commits, and CI is green.
- Nit:
SKILL.mddocuments exit codes as0healthy ·2degraded ·1usage error, butmesh-recover.shadds a third exit code3(INCONCLUSIVE, e.g. gateway unreachable or no ztunnel found). The script's own--helpoutput and inline comments are correct; only the skill doc summary is missing this code.
Reviewed by clawgenti using github:pr-review
| scripts/k8s/mesh-recover.sh --fix --include-spire | ||
| ``` | ||
|
|
||
| Exit codes: `0` healthy · `2` degraded (or fix attempted) · `1` usage/precondition error. |
There was a problem hiding this comment.
nit: The exit code summary is missing exit 3 (INCONCLUSIVE — gateway unreachable or no ztunnel daemonset found). The script's own usage() output (and the inline comment at the INCONCLUSIVE variable declaration) are already correct; this line just needs · 3 inconclusive (unreachable / not Ambient) added. E.g.:
Exit codes: `0` healthy · `2` degraded (or fix attempted) · `3` inconclusive (unreachable / not Ambient) · `1` usage/precondition error.
|
Deploy & Test (e2e) failure is unrelated to this PR — safe to merge on the other green checks. Root cause (from the failed run): the AuthBridge Weather (advanced) E2E stage clones and runs All Kubernetes steps before it (secret sync, This PR only adds two shell scripts under All other checks (lint, shellcheck, chart/helm, backend-tests, security scans, DCO) pass. Assisted-By: Claude Code |
esnible
left a comment
There was a problem hiding this comment.
Summary
Well-scoped dev/Kind mesh self-heal tooling for the Ambient expired-cert 503 outage (#1899). mesh-recover.sh is read-only by default with --fix gated; induce-mesh-outage.sh is Kind-guarded and refuses to run outside a kind-* context without --force. No always-on components and no production behavior change. The backend-dependent probe-host choice (avoiding edge-redirect routes like kiali that would give a false-healthy) and the ztunnel-namespace discovery are nice touches. Reviewed the skill markdown and both scripts in full — no supply-chain concerns (the .claude/ changes are documentation only, no hooks or executable config).
The failing Deploy & Test check is unrelated to this PR: a langchain-core dependency-resolution conflict in the externally-cloned kagenti-extensions AuthBridge E2E. These scripts are dev-only and not exercised by CI.
Approving. Three cosmetic nits inline — take or leave.
Areas reviewed: Shell, Docs, .claude/ skills
Commits: 2, all signed-off
Assisted-By: Claude Code
| # Recovery | ||
| # --------------------------------------------------------------------------- | ||
| recover_mesh() { | ||
| local ns wp gw |
There was a problem hiding this comment.
nit: local ns wp gw declares wp, but it's never assigned or used in recover_mesh() (shellcheck SC2034). Safe to drop it from the declaration.
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| --break) MODE=break; shift ;; |
There was a problem hiding this comment.
nit: MODE=break / MODE=restore trip shellcheck SC2209 because break/restore read like builtins. It works correctly (assigns the literal string), but quoting — MODE='break' / MODE='restore' — silences the warning and makes the string-assignment intent explicit.
| scripts/k8s/mesh-recover.sh --fix --include-spire | ||
| ``` | ||
|
|
||
| Exit codes: `0` healthy · `2` degraded (or fix attempted) · `1` usage/precondition error. |
There was a problem hiding this comment.
nit: This lists exit codes 0 / 2 / 1, but the script's own --help also documents 3 inconclusive (gateway unreachable / not an Ambient cluster — a restart won't help). Worth adding 3 here so the skill doc matches the script.
- SKILL.md: add exit code 3 (inconclusive) to the exit-code summary so it matches the script's --help. - mesh-recover.sh: drop unused 'wp' from recover_mesh() locals (SC2034). - induce-mesh-outage.sh: quote MODE='break'/'restore'/'selftest' (SC2209). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
…preflight-1899 Signed-off-by: cwiklik <[email protected]>
Part B of the mesh-wide-503 self-heal (Part A = scripts/k8s/mesh-recover.sh + skills, shipped in 0.7 via #2179): a CronJob in rossoctl-deps that periodically probes the gateway and, on a recoverable outage (expired ztunnel/waypoint certs after a host suspend), runs mesh-recover.sh --fix with cooldown / max-restart safety and loud Events. - Feature flag meshSelfHeal.enabled (Helm value, OFF by default); renders only on non-OpenShift (the ambient cert-expiry failure mode is Kind/dev-specific). - Reuses mesh-recover.sh unchanged (auto-discovers ztunnel ns + probe host; exit 0 healthy / 2 degraded / 3 inconclusive). Helm .Files.Get can't read outside the chart, so a verbatim copy lives in charts/rossoctl-deps/files/ kept in sync by scripts/check-mesh-recover-sync.sh. - Wrapper adds scheduling + cooldown/max-restart(window) gating (state ConfigMap) + k8s Events. Probes the in-cluster gateway Service http-istio. - CronJob pod is out of ambient (istio.io/dataplane-mode: none) so its own kubectl calls don't traverse the broken ztunnel; nonroot/read-only/drop-ALL; least-priv RBAC (patch deployments/daemonsets for rollout restart; state CM; events). Verified: helm template OFF->none, ON+Kind->full set, ON+OCP->none; helm lint clean; wrapper shellcheck-clean; sync guard passing. Durable fix is upstream (istio/ztunnel#1679). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
…03 docs (Part of #1899) Design spec for the remaining #1899 items after Parts A (#2179) and B (#2452): proactive near-expiry SVID/CA detection (advisory WARN via k8s:health), Kind-only SPIRE TTL right-sizing, and a 503-after-suspend troubleshooting doc. Assisted-By: Claude Code Signed-off-by: cwiklik <[email protected]>
What
Adds a detect-and-recover tool + skill for the Istio Ambient "everything returns 503" outage seen on long-running / suspended dev/Kind clusters. Part A of the agreed A+B mitigation for #1899 (B = feature-flagged CronJob remediator, targeted for v0.8).
scripts/k8s/mesh-recover.sh— read-only by default: probes a backend-dependent gateway route (kagenti-ui/kagenti-api, which flip to 503 in an outage — not edge-redirect routes like kiali), checks ztunnel cert/logs (discovers the ztunnel namespace, since Kind usesistio-systemand the chart usesistio-ztunnel), and optionally the SPIRE agent.--fixruns the proven recovery —rollout restartof ztunnel + waypoints + the gateway (and, with--include-spire, the SPIRE agent).--jsonfor automation. Exit0healthy /2degraded..claude/skills/istio:mesh-selfheal/— skill wrapping the above: when-to-use, the two-domain note (mesh mTLS vs. the separate SPIRE reattest issue), manual fallback commands, diagnostics, and testing.scripts/k8s/induce-mesh-outage.sh— Kind-guarded test harness that induces the symptom (CA down + ztunnel pods deleted → mesh-wide 503) and asserts the fulldetect → --fix → re-probeloop;--break/--restore/--self-test.istioparent skill table, ak8s:healthcross-reference, and the skillsREADME.mdtree.Why
Root cause of #1899: the Ambient data plane serves expired istiod-issued mTLS certs and never re-fetches after a host suspend / clock jump, so every gateway route 503s while pods look healthy. (SPIRE is a separate identity plane; its reattest deadlock affects AuthBridge, not routing.) The durable data-plane fix is upstream — istio/ztunnel#1679; this is the kagenti-side dev-cluster mitigation.
Scope / safety
--fixand the induce harness are opt-in and refuse to run outside akind-*context (without--force).Testing
mesh-recover.sh— healthy cluster → exit 0; degraded (bad target) → exit 2 + printed dry-run recovery;--json→ clean JSON.induce-mesh-outage.sh --self-teston a live Kind cluster: induced 503 → detected (exit 2) →--fix→ healthy (exit 0). This caught and fixed a real probe bug (edge-redirect routes gave a false-healthy).Part of #1899. Durable fix tracked upstream: istio/ztunnel#1679.
Assisted-By: Claude Code