Skip to content

fix(mesh): proactive SVID near-expiry detection + SPIRE TTL right-sizing + 503 docs (Part of #1899) - #2464

Merged
cwiklik merged 10 commits into
rossoctl:mainfrom
cwiklik:fix/mesh-selfheal-detection-ttl-1899
Aug 25, 2026
Merged

cwiklik merged 10 commits into
rossoctl:mainfrom
cwiklik:fix/mesh-selfheal-detection-ttl-1899

Conversation

@cwiklik

@cwiklik cwiklik commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Advances #1899 (mesh-wide 503 from expired SPIRE SVIDs after a long host suspend) beyond the merged reactive self-heal (Part A #2179 / Part B #2452) with three additions. This is "Part of #1899", not a close — the root cause (SPIRE re-attest deadlock / ztunnel not re-fetching) is upstream istio/ztunnel#1679.

What & why

  1. Proactive near-expiry detection (scripts/k8s/mesh-recover.sh) — a new check_cert_expiry() reads the soonest-expiring ztunnel workload SVID from ztunnel's admin config_dump (the data istioctl ztunnel-config certificates surfaces), via kubectl exec + jq. It emits a new advisory WARN status → exit code 4 → the CronJob wrapper emits a MeshNearExpiry Warning Event. Advisory only — never restarts. Degrades to a non-fatal SKIP when jq is absent or kubectl exec is denied (the CronJob ServiceAccount has no pods/exec), so proactive warning is a manual / k8s:health-path capability and the CronJob stays reactive-only — no new RBAC.

  2. SPIRE TTL right-sizing (Kind-dev-only) (scripts/kind/setup-rossoctl.sh) — CA TTL 24h → 168h (7d), x509 SVID TTL → 24h, so a normal overnight suspend no longer expires every mesh credential at once. OpenShift path untouched.

  3. Troubleshooting docs — a "503 after host suspend" section in docs/users-guides/troubleshooting.md and a proactive-detection note in the k8s:health skill.

Exit-code semantics

DEGRADED(2) > INCONCLUSIVE(3) > WARN/near-expiry(4) > OK(0). A skipped near-expiry check is neutral (does not flip a healthy mesh off OK).

Validation (live, kind-rossoctl)

  • Detection WARN reports the real ~24h SVID expiry → exit 4; OK → exit 0; healthy CronJob run (exec denied) → cert-expiry: SKIP → MeshHealthy (not a false MeshInconclusive).
  • rc=4 → MeshNearExpiry Warning Event with the full JSON summary, no rollout restart (ztunnel restart count unchanged).
  • shellcheck clean on all edited scripts; mesh-recover.sh chart-copy sync guard passes.

Caveats / notes for reviewers

  • TTL change is render-verified, not live-reinstalled. helm template confirms ca_ttl: 168h and ClusterSPIFFEID ttl: 24h render correctly; a live SPIRE reinstall was intentionally skipped to avoid disrupting a running cluster, so it takes effect on the next fresh Kind install.
  • Design pivot vs. the committed spec. The spec doc (docs/superpowers/specs/2026-08-24-…) describes an openssl-on-trust-bundle-CA approach. Live testing showed that only ever reads the 10-year Istio root CA (the SPIRE bundle is JWKS, not PEM), so it would never warn before a real outage; the implementation was reworked to read the actual short-lived workload SVID instead. The spec is left as the historical record.
  • Pre-existing follow-up (not fixed here): mesh-recover.sh check_spire_agent uses -l app=spire-agent, which matches no pods (real label app.kubernetes.io/name=agent); it only runs under --include-spire. Worth a separate fix.

Assisted-By: Claude Code

…03 docs (Part of rossoctl#1899)

Design spec for the remaining rossoctl#1899 items after Parts A (rossoctl#2179) and B (rossoctl#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]>
…octl#1899)

Add check_cert_expiry() + advisory WARN status (exit 4) to mesh-recover.sh:
openssl -checkend on the SPIRE trust-bundle CA warns before the mesh 503s.
No restart (advisory). Degrades to INCONCLUSIVE where openssl is absent.

Assisted-By: Claude Code
Signed-off-by: cwiklik <[email protected]>
…t of rossoctl#1899)

Set CA TTL 7d and x509 SVID TTL 24h on the Kind SPIRE install so an overnight
laptop suspend no longer expires every mesh credential at once. Kind-dev-only.

Assisted-By: Claude Code
Signed-off-by: cwiklik <[email protected]>
… on re-probe (Part of rossoctl#1899)

check_cert_expiry()'s two "can't check" branches (no openssl, trust-bundle
ConfigMap not found) were recording status INCONCLUSIVE. record() maps
INCONCLUSIVE to the INCONCLUSIVE flag, which the final exit line promotes to
exit code 3 — so a healthy mesh on the tool-less CronJob image (alpine/k8s,
no openssl) would exit 3 and the remediator would emit a false
MeshInconclusive Warning every tick, even though nothing is actually wrong.

Introduce a neutral SKIP status for these "graceful skip, non-fatal" cases.
record() already falls through on any status it doesn't recognize, so SKIP
sets no flag by construction; add a comment documenting that OK/SKIP
intentionally set no flag.

Also reset NEAR_EXPIRY=false alongside DEGRADED/INCONCLUSIVE on the --fix
re-probe, so a successful recovery doesn't leave a stale warn:true from the
pre-recovery probe.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>
…ot CA (Part of rossoctl#1899)

Live testing showed the openssl-on-trust-bundle approach only ever reads the
10-year Istio root CA (the SPIRE bundle is JWKS, not PEM), so it never warned
before a real rossoctl#1899 outage. Rework check_cert_expiry to read the soonest-expiring
ztunnel workload SVID from ztunnel's admin config_dump (the data istioctl
ztunnel-config certificates surfaces), via kubectl exec + jq, with jq doing the
time math (portable, no date(1)). Degrades to a non-fatal SKIP when jq is absent
or exec is denied (the CronJob SA has no pods/exec) — proactive warning stays a
manual / k8s:health capability, CronJob stays reactive-only, no new RBAC. Drop
the now-unused HAVE_OPENSSL. Docs updated to match.

Verified live on kind-rossoctl: WARN reports the real ~24h SVID expiry (exit 4);
OK exits 0; CronJob path SKIPs (exec denied) and a healthy mesh emits MeshHealthy.

Assisted-By: Claude Code
Signed-off-by: cwiklik <[email protected]>

@pdettori pdettori left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, well-documented maintainer PR advancing #1899 with proactive SVID near-expiry detection, Kind-only SPIRE TTL right-sizing, and troubleshooting docs. All CI checks pass; no blocking issues.

Reviewed: Shell (mesh-recover.sh + chart copy, mesh-selfheal-wrapper.sh), Helm/Kind setup (caTTL/ClusterSPIFFEID ttl), docs, and the .claude/skills/k8s:health/SKILL.md change (inspected in full — benign doc-only blockquote, no hooks/commands/executables).

Verified good:

  • scripts/k8s/mesh-recover.sh and charts/rossoctl-deps/files/mesh-recover.sh are byte-identical (sync guard intact).
  • Exit-code precedence DEGRADED(2) > INCONCLUSIVE(3) > WARN(4) > OK(0) is correct, and OK/SKIP correctly set no flag.
  • All check_cert_expiry degradation paths (no jq, no pods/exec, empty/unparseable config_dump) are non-fatal SKIPs — a healthy mesh never flips off OK.

One minor accuracy suggestion inline (design-pivot leftover); non-blocking.

Assisted-By: Claude Code

0) emit_event Normal MeshHealthy "gateway reachable, mesh certs OK"; exit 0 ;;
3) emit_event Warning MeshInconclusive "cannot confirm mesh health (restart would not help): ${summary}"; exit 0 ;;
2) : ;; # degraded/recoverable — fall through to gating
4) emit_event Warning MeshNearExpiry "trust-bundle CA nearing expiry (advisory; no restart): ${summary}"; exit 0 ;;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): stale wording from the design pivot. This MeshNearExpiry Event message says "trust-bundle CA nearing expiry", but per the PR's design-pivot note (and commit d730b9b) check_cert_expiry now reads the workload SVID expiry, not the trust-bundle CA. If this branch ever fires, the emitted Kubernetes Warning Event would be misleading. Suggest something like "workload SVID nearing expiry".

(The docs/superpowers/specs/... doc is fine to leave as-is — it's intentionally kept as the historical CA-approach record.)

@cwiklik
cwiklik merged commit a4ea4cb into rossoctl:main Aug 25, 2026
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New/ToDo

Development

Successfully merging this pull request may close these issues.

2 participants