feat(ops): show deployment capability receipt
This commit is contained in:
@@ -43,6 +43,7 @@ from govoplan_core.db.session import get_database
|
||||
from govoplan_core.settings import settings as core_settings
|
||||
|
||||
from govoplan_ops.backend.manifest import OPS_READ_SCOPES, OPS_RUN_SCOPES
|
||||
from govoplan_ops.backend.infrastructure import deployment_capability_status
|
||||
|
||||
router = APIRouter(prefix="/ops", tags=["ops"])
|
||||
_module_check_cache: dict[str, tuple[float, dict[str, Any]]] = {}
|
||||
@@ -207,6 +208,7 @@ def _ops_status_payload(
|
||||
)
|
||||
storage_check = _storage_check()
|
||||
backup_check = _backup_restore_check()
|
||||
infrastructure = deployment_capability_status()
|
||||
recovery_metrics = runtime_cluster.get("recovery", {}).get("metrics", {})
|
||||
checks = [
|
||||
_check(
|
||||
@@ -229,6 +231,7 @@ def _ops_status_payload(
|
||||
storage_check,
|
||||
backup_check,
|
||||
_deployment_security_check(current_profile),
|
||||
_infrastructure_capability_check(infrastructure),
|
||||
*module_checks,
|
||||
]
|
||||
readiness = _readiness(checks, maintenance_mode)
|
||||
@@ -262,6 +265,12 @@ def _ops_status_payload(
|
||||
"failed_operation_count": int(recovery_metrics.get("failed") or 0),
|
||||
"outcome_unknown_count": int(recovery_metrics.get("outcome_unknown") or 0),
|
||||
"active_operation_count": int(recovery_metrics.get("active") or 0),
|
||||
"infrastructure_capability_count": len(
|
||||
infrastructure.get("capabilities", [])
|
||||
),
|
||||
"pending_post_install_task_count": len(
|
||||
infrastructure.get("post_install_tasks", [])
|
||||
),
|
||||
},
|
||||
"readiness": readiness,
|
||||
"checks": checks,
|
||||
@@ -269,9 +278,40 @@ def _ops_status_payload(
|
||||
"deployment_profiles": _deployment_profiles(current_profile),
|
||||
"sizing": _sizing_assumptions(),
|
||||
"runtime_cluster": runtime_cluster,
|
||||
"infrastructure": infrastructure,
|
||||
}
|
||||
|
||||
|
||||
def _infrastructure_capability_check(
|
||||
infrastructure: Mapping[str, object],
|
||||
) -> dict[str, Any]:
|
||||
if infrastructure.get("available") is True:
|
||||
capabilities = infrastructure.get("capabilities")
|
||||
count = len(capabilities) if isinstance(capabilities, list) else 0
|
||||
return _check(
|
||||
"infrastructure_capability_receipt",
|
||||
"Infrastructure capabilities",
|
||||
"ok",
|
||||
f"A validated non-secret deployment receipt reports {count} capabilities.",
|
||||
)
|
||||
if infrastructure.get("configured") is True:
|
||||
return _check(
|
||||
"infrastructure_capability_receipt",
|
||||
"Infrastructure capabilities",
|
||||
"warning",
|
||||
str(
|
||||
infrastructure.get("error")
|
||||
or "The configured deployment capability receipt is unavailable."
|
||||
),
|
||||
)
|
||||
return _check(
|
||||
"infrastructure_capability_receipt",
|
||||
"Infrastructure capabilities",
|
||||
"ok",
|
||||
"No deployment capability receipt is mounted in this runtime profile.",
|
||||
)
|
||||
|
||||
|
||||
def _runtime_cluster_status(
|
||||
*,
|
||||
expected_composition_hash: str | None = None,
|
||||
|
||||
Reference in New Issue
Block a user