feat(cluster-state): add pod issue reason counts

This commit is contained in:
Brad Stein 2026-01-29 05:59:09 -03:00
parent fbfa701d42
commit bdb7cc4fcd

View File

@ -714,6 +714,8 @@ def _summarize_pod_issues(payload: dict[str, Any]) -> dict[str, Any]:
items: list[dict[str, Any]] = [] items: list[dict[str, Any]] = []
counts: dict[str, int] = {key: 0 for key in _PHASE_SEVERITY} counts: dict[str, int] = {key: 0 for key in _PHASE_SEVERITY}
pending_oldest: list[dict[str, Any]] = [] pending_oldest: list[dict[str, Any]] = []
waiting_reason_counts: dict[str, int] = {}
phase_reason_counts: dict[str, int] = {}
for pod in _items(payload): for pod in _items(payload):
metadata = pod.get("metadata") if isinstance(pod.get("metadata"), dict) else {} metadata = pod.get("metadata") if isinstance(pod.get("metadata"), dict) else {}
status = pod.get("status") if isinstance(pod.get("status"), dict) else {} status = pod.get("status") if isinstance(pod.get("status"), dict) else {}
@ -740,6 +742,10 @@ def _summarize_pod_issues(payload: dict[str, Any]) -> dict[str, Any]:
reason = waiting.get("reason") reason = waiting.get("reason")
if isinstance(reason, str) and reason: if isinstance(reason, str) and reason:
waiting_reasons.append(reason) waiting_reasons.append(reason)
waiting_reason_counts[reason] = waiting_reason_counts.get(reason, 0) + 1
phase_reason = status.get("reason")
if isinstance(phase_reason, str) and phase_reason:
phase_reason_counts[phase_reason] = phase_reason_counts.get(phase_reason, 0) + 1
if phase in counts: if phase in counts:
counts[phase] += 1 counts[phase] += 1
if phase in _PHASE_SEVERITY or restarts > 0: if phase in _PHASE_SEVERITY or restarts > 0:
@ -779,6 +785,8 @@ def _summarize_pod_issues(payload: dict[str, Any]) -> dict[str, Any]:
"counts": counts, "counts": counts,
"items": items[:20], "items": items[:20],
"pending_oldest": pending_oldest[:10], "pending_oldest": pending_oldest[:10],
"waiting_reasons": waiting_reason_counts,
"phase_reasons": phase_reason_counts,
} }