diff --git a/docs/app-ops.md b/docs/app-ops.md index bba04a3..0aa6cd6 100644 --- a/docs/app-ops.md +++ b/docs/app-ops.md @@ -6,7 +6,9 @@ Compact `status` and `doctor-homelab` run independent read-only probes in parallel (four at a time by default, capped at eight). Set `LAB_REPORT_PARALLELISM=1` to serialize them or `LAB_REPORT_TIMING=true` to print probe elapsed time. Identical selected HTTP/container probes reuse results -only within that report. Healing performs its own live identity checks. +only within that report. HTTP checks for the same URL also share one response +while retaining each check's accepted status codes. Healing performs its own +live identity checks. Compact reports also share one nodes, pods, Deployments, and StatefulSets list per resource type as needed; snapshots are point-in-time, may differ across resource types, and are discarded when the report ends. API readiness, logs, diff --git a/docs/templates/app-ops.md.tmpl b/docs/templates/app-ops.md.tmpl index dd1fac5..6a37514 100644 --- a/docs/templates/app-ops.md.tmpl +++ b/docs/templates/app-ops.md.tmpl @@ -6,7 +6,9 @@ Compact `status` and `doctor-homelab` run independent read-only probes in parallel (four at a time by default, capped at eight). Set `LAB_REPORT_PARALLELISM=1` to serialize them or `LAB_REPORT_TIMING=true` to print probe elapsed time. Identical selected HTTP/container probes reuse results -only within that report. Healing performs its own live identity checks. +only within that report. HTTP checks for the same URL also share one response +while retaining each check's accepted status codes. Healing performs its own +live identity checks. Compact reports also share one nodes, pods, Deployments, and StatefulSets list per resource type as needed; snapshots are point-in-time, may differ across resource types, and are discarded when the report ends. API readiness, logs, diff --git a/lib/jeannie/commands.sh b/lib/jeannie/commands.sh index cbe1f48..92cf1c4 100644 --- a/lib/jeannie/commands.sh +++ b/lib/jeannie/commands.sh @@ -1389,16 +1389,20 @@ status_http() { fi } -status_http_ok() { +status_http_response() { local url="$1" - local status - if ! command -v curl >/dev/null 2>&1; then echo "curl not installed" >&2 return 1 fi + curl -k -sS -o /dev/null --connect-timeout 5 --max-time 10 -w '%{http_code}' "${url}" +} - status="$(curl -k -sS -o /dev/null --connect-timeout 5 --max-time 10 -w '%{http_code}' "${url}")" || { +status_http_ok() { + local url="$1" + local status + + status="$(report_ui_cached_probe status_http_response "${url}")" || { echo "unreachable ${url}" >&2 return 1 } @@ -1417,12 +1421,7 @@ status_http_reachable() { local url="$1" local status - if ! command -v curl >/dev/null 2>&1; then - echo "curl not installed" >&2 - return 1 - fi - - status="$(curl -k -sS -o /dev/null --connect-timeout 5 --max-time 10 -w '%{http_code}' "${url}")" || { + status="$(report_ui_cached_probe status_http_response "${url}")" || { echo "unreachable ${url}" >&2 return 1 } diff --git a/tests/jeannie/test_report_parallel.py b/tests/jeannie/test_report_parallel.py index 92f042c..3b5466a 100644 --- a/tests/jeannie/test_report_parallel.py +++ b/tests/jeannie/test_report_parallel.py @@ -11,6 +11,28 @@ ROOT = Path(__file__).resolve().parents[2] class ParallelReportTests(unittest.TestCase): + def test_http_response_shared_without_changing_health_semantics(self): + with tempfile.TemporaryDirectory() as directory: + env = dict(os.environ, PROBE_COUNTER=str(Path(directory) / "calls"), LAB_REPORT_PARALLELISM="2") + program = r''' +set -euo pipefail +source scripts/report-ui +source lib/jeannie/commands.sh +curl() { printf 'call\n' >>"$PROBE_COUNTER"; printf 404; } +report_ui_begin +REPORT_UI_PARALLEL=true +report_ui_check fail A strict fix '' '' status_http_ok http://example.invalid/ +report_ui_check fail A reachable fix '' '' status_http_reachable http://example.invalid/ +report_ui_finish +cat "$REPORT_UI_ROWS_FILE" +report_ui_cleanup +''' + result = subprocess.run(["bash", "-c", program], cwd=ROOT, env=env, + text=True, capture_output=True, check=True) + lines = result.stdout.splitlines() + self.assertEqual([line.split("\t")[0] for line in lines], ["fail", "ok"]) + self.assertEqual(Path(env["PROBE_COUNTER"]).read_text().splitlines(), ["call"]) + def test_order_cache_and_failure_are_preserved(self): with tempfile.TemporaryDirectory() as directory: env = dict(os.environ, PROBE_COUNTER=str(Path(directory) / "calls"), LAB_REPORT_PARALLELISM="2")