From 55f17126dcc7baa5af860d1301ef4173014266f2 Mon Sep 17 00:00:00 2001 From: ilaylow Date: Tue, 10 Dec 2024 19:52:47 +1100 Subject: [PATCH] adds reason label for unschedulable pod --- internal/store/pod.go | 4 ++-- internal/store/pod_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/store/pod.go b/internal/store/pod.go index d597667e9..2c1eba924 100644 --- a/internal/store/pod.go +++ b/internal/store/pod.go @@ -1628,8 +1628,8 @@ func createPodStatusUnschedulableFamilyGenerator() generator.FamilyGenerator { for _, c := range p.Status.Conditions { if c.Type == v1.PodScheduled && c.Status == v1.ConditionFalse { ms = append(ms, &metric.Metric{ - LabelKeys: []string{}, - LabelValues: []string{}, + LabelKeys: []string{"reason"}, + LabelValues: []string{c.Message}, Value: 1, }) } diff --git a/internal/store/pod_test.go b/internal/store/pod_test.go index 8645e8707..a6b9b8918 100644 --- a/internal/store/pod_test.go +++ b/internal/store/pod_test.go @@ -1691,7 +1691,7 @@ func TestPodStore(t *testing.T) { Want: ` # HELP kube_pod_status_unschedulable [STABLE] Describes the unschedulable status for the pod. # TYPE kube_pod_status_unschedulable gauge - kube_pod_status_unschedulable{namespace="ns2",pod="pod2",uid="uid2"} 1 + kube_pod_status_unschedulable{namespace="ns2",pod="pod2",uid="uid2",reason="0/3 nodes are available: 3 Insufficient cpu."} 1 `, MetricNames: []string{"kube_pod_status_unschedulable"}, },