diff --git a/ariadne/services/cluster_state_attention.py b/ariadne/services/cluster_state_attention.py index ac29186..3766582 100644 --- a/ariadne/services/cluster_state_attention.py +++ b/ariadne/services/cluster_state_attention.py @@ -104,12 +104,7 @@ def _workload_attention_entries(workloads_health: dict[str, Any]) -> list[dict[s return entries -def _build_attention_ranked( - metrics: dict[str, Any], - node_context: list[dict[str, Any]], - pod_issues: dict[str, Any], - workloads_health: dict[str, Any], -) -> list[dict[str, Any]]: +def _build_attention_ranked(metrics: dict[str, Any], node_context: list[dict[str, Any]], pod_issues: dict[str, Any], workloads_health: dict[str, Any]) -> list[dict[str, Any]]: entries = ( _node_attention_entries(node_context) + _pvc_attention_entries(metrics) diff --git a/tests/unit/services/test_cluster_state_context_domains.py b/tests/unit/services/test_cluster_state_context_domains.py index 04aaadb..acbed33 100644 --- a/tests/unit/services/test_cluster_state_context_domains.py +++ b/tests/unit/services/test_cluster_state_context_domains.py @@ -244,6 +244,20 @@ def test_profile_builders_filter_bad_nodes_and_workload_nodes() -> None: assert workload_profiles[1]["nodes_top"] == [] +def test_attention_filters_edge_entries(monkeypatch) -> None: + assert attention._node_attention_entries([None, {"node": ""}, {"node": "quiet"}]) == [] + + monkeypatch.setattr(attention, "_pvc_pressure_entries", lambda _metrics: [None, {"namespace": "apps", "pvc": "data", "used_percent": 90.0}]) + assert attention._pvc_attention_entries({}) == [ + { + "kind": "pvc", + "target": "apps/data", + "score": 2.0, + "reasons": ["usage 90.0%"], + } + ] + + def test_health_helpers_handle_clean_and_malformed_inputs() -> None: bullets = health._health_bullets( {"pods_running": 1, "pods_pending": 0, "pods_failed": 0},