fix(ops): verify EwoooC metrics payload
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
This commit is contained in:
@@ -310,6 +310,19 @@ def _wait_prometheus_ready(timeout_seconds: int = 45) -> None:
|
||||
raise RuntimeError("Prometheus did not become ready after controlled rebind")
|
||||
|
||||
|
||||
def _parse_metrics_canary(output: str) -> tuple[str, bool]:
|
||||
marker = "\n__EWOOOC_HTTP_STATUS__:"
|
||||
if marker not in output:
|
||||
raise RuntimeError("metrics canary response has no HTTP status marker")
|
||||
body, status = output.rsplit(marker, 1)
|
||||
product_marker_present = (
|
||||
"momo_app_info" in body
|
||||
and "momo_app_health" in body
|
||||
and "momo_database_up" in body
|
||||
)
|
||||
return status.strip(), product_marker_present
|
||||
|
||||
|
||||
def apply_metrics_edge_plan(
|
||||
plan: dict[str, Any],
|
||||
*,
|
||||
@@ -400,24 +413,31 @@ def apply_metrics_edge_plan(
|
||||
if metrics_canary_resolve:
|
||||
canary_command.extend(["--resolve", metrics_canary_resolve])
|
||||
canary_command.extend([
|
||||
"-o", "/dev/null", "-w", "%{http_code}", metrics_canary_url,
|
||||
"-w", "\n__EWOOOC_HTTP_STATUS__:%{http_code}", metrics_canary_url,
|
||||
])
|
||||
internal = _run(canary_command)
|
||||
internal_code = internal.stdout.strip()
|
||||
internal_code, product_marker_present = _parse_metrics_canary(internal.stdout)
|
||||
target_health = _prometheus_target_health(max(10, canary_timeout))
|
||||
receipt["post_verifier"] = {
|
||||
"nginx_config_valid": apply_scope == "full",
|
||||
"prometheus_config_valid": True,
|
||||
"internal_metrics_http_code": internal_code,
|
||||
"metrics_internal_canary": internal_code == "200",
|
||||
"metrics_product_marker_present": product_marker_present,
|
||||
"metrics_target_health": target_health,
|
||||
"prometheus_config_inode_reconciled": True,
|
||||
"prometheus_identity_preserved": identity_preserved,
|
||||
}
|
||||
if internal_code != "200" or target_health != "up" or not identity_preserved:
|
||||
if (
|
||||
internal_code != "200"
|
||||
or not product_marker_present
|
||||
or target_health != "up"
|
||||
or not identity_preserved
|
||||
):
|
||||
raise RuntimeError(
|
||||
"post-verifier failed: "
|
||||
f"internal={internal_code}, target={target_health}, "
|
||||
f"internal={internal_code}, product_marker={product_marker_present}, "
|
||||
f"target={target_health}, "
|
||||
f"identity_preserved={identity_preserved}"
|
||||
)
|
||||
receipt["status"] = "pass"
|
||||
|
||||
Reference in New Issue
Block a user