fix(reboot): load runtime slo scorecard artifact
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 1s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 1m5s
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 1s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 1m5s
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
"""P0-006 reboot auto-recovery SLO scorecard readback.
|
||||
|
||||
This loader promotes the committed reboot recovery scorecard into a stable API
|
||||
contract. It does not reboot hosts, restart services, query runtime secrets, or
|
||||
write StockPlatform data; it only reads the committed JSON scorecard.
|
||||
This loader promotes the committed reboot recovery scorecard and the latest
|
||||
runtime verifier artifact into a stable API contract. It does not reboot hosts,
|
||||
restart services, query runtime secrets, or write StockPlatform data.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -23,8 +23,8 @@ _API_SCHEMA_VERSION = "reboot_auto_recovery_slo_scorecard_readback_v1"
|
||||
_PUBLIC_MAINTENANCE_RUNTIME_FILE_ENV = (
|
||||
"AWOOOI_PUBLIC_MAINTENANCE_FALLBACK_READBACK_FILE"
|
||||
)
|
||||
_PUBLIC_MAINTENANCE_RUNTIME_DIR_ENV = "AWOOOI_REBOOT_RECOVERY_LOG_DIR"
|
||||
_RUNTIME_SCORECARD_FILE_ENV = "AWOOOI_REBOOT_RECOVERY_SLO_SCORECARD_FILE"
|
||||
_PUBLIC_MAINTENANCE_RUNTIME_DIR_ENV = "AWOOOI_REBOOT_RECOVERY_LOG_DIR"
|
||||
_RUNTIME_SCORECARD_DIR_ENV = "AWOOOI_REBOOT_RECOVERY_LOG_DIR"
|
||||
_DEFAULT_REBOOT_RECOVERY_LOG_DIR = Path("/home/wooo/reboot-recovery")
|
||||
_PUBLIC_MAINTENANCE_RUNTIME_PATTERN = (
|
||||
@@ -45,7 +45,7 @@ def load_latest_reboot_auto_recovery_slo_scorecard(
|
||||
runtime_scorecard_path: Path | None = None,
|
||||
runtime_scorecard_dir: Path | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""Load and validate the committed P0-006 reboot recovery scorecard."""
|
||||
"""Load the committed P0-006 scorecard and overlay trusted runtime artifacts."""
|
||||
directory = operations_dir or _DEFAULT_OPERATIONS_DIR
|
||||
path = directory / _SCORECARD_FILE
|
||||
with path.open(encoding="utf-8") as handle:
|
||||
@@ -106,9 +106,15 @@ def _load_latest_runtime_scorecard(
|
||||
return {}, None
|
||||
if not candidates:
|
||||
return {}, None
|
||||
latest = max(candidates, key=lambda path: path.stat().st_mtime)
|
||||
payload = _read_json_file(latest)
|
||||
return _runtime_scorecard_if_supported(payload), latest
|
||||
for latest in sorted(
|
||||
candidates,
|
||||
key=lambda path: path.stat().st_mtime,
|
||||
reverse=True,
|
||||
):
|
||||
payload = _runtime_scorecard_if_supported(_read_json_file(latest))
|
||||
if payload:
|
||||
return payload, latest
|
||||
return {}, None
|
||||
|
||||
|
||||
def _runtime_scorecard_if_supported(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
@@ -446,6 +452,11 @@ def _build_payload(scorecard: dict[str, Any], path: Path) -> dict[str, Any]:
|
||||
snapshot_generated_at = str(scorecard.get("generated_at") or "")
|
||||
runtime_readback_generated_at = _taipei_now_iso()
|
||||
latest_verify_metric = _dict(scorecard.get("latest_verify_only_metric"))
|
||||
source_scorecard_ref = (
|
||||
f"docs/operations/{path.name}"
|
||||
if path.name == _SCORECARD_FILE
|
||||
else str(path)
|
||||
)
|
||||
active_blocker_count = len(active_blockers)
|
||||
observed_host_count = len(_strings(host_boot_detection.get("observed_hosts")))
|
||||
missing_host_count = len(_strings(host_boot_detection.get("missing_hosts")))
|
||||
@@ -673,7 +684,7 @@ def _build_payload(scorecard: dict[str, Any], path: Path) -> dict[str, Any]:
|
||||
"readback": {
|
||||
"workplan_id": "P0-006",
|
||||
"workplan_title": "主機重啟自動偵測、自動觸發與 10 分鐘恢復 SLO",
|
||||
"source_scorecard_ref": f"docs/operations/{path.name}",
|
||||
"source_scorecard_ref": source_scorecard_ref,
|
||||
"generated_at": runtime_readback_generated_at,
|
||||
"runtime_readback_generated_at": runtime_readback_generated_at,
|
||||
"snapshot_generated_at": snapshot_generated_at,
|
||||
|
||||
Reference in New Issue
Block a user