From 4d3f5cdc82d911a7eb9978e47e3401bc0ab8082c Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Thu, 13 Jun 2024 15:12:56 -0700 Subject: [PATCH] kubelet: Add description for failed predicate Events **Problem:** When a Pod fails to run due to kubelet-side admission checks, the v1.Event objects emitted looks like these: Reason="NodeAffinity" Message="Predicate NodeAffinity failed" Reason="NodeName" Message="Predicate NodeName failed" Reason="NodePorts" Message="Predicate NodePorts failed" **Solution:** Expose human-readable predicate description in the failure so that kubelet submits an Event with this description, such as: Reason="NodeAffinity" Message="Predicate NodeAffinity failed: node(s) didn't match Pod's node affinity/selector" Reason="NodeName" Message="Predicate NodeName failed: node(s) didn't match the requested node name" Reason="NodePorts" Message="Predicate NodePorts failed: node(s) didn't have free ports for the requested pod ports" --- pkg/kubelet/lifecycle/predicate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kubelet/lifecycle/predicate.go b/pkg/kubelet/lifecycle/predicate.go index 8b93ba39ae3..286c8e0b64c 100644 --- a/pkg/kubelet/lifecycle/predicate.go +++ b/pkg/kubelet/lifecycle/predicate.go @@ -269,7 +269,7 @@ type PredicateFailureError struct { } func (e *PredicateFailureError) Error() string { - return fmt.Sprintf("Predicate %s failed", e.PredicateName) + return fmt.Sprintf("Predicate %s failed: %s", e.PredicateName, e.PredicateDesc) } // GetReason returns the reason of the PredicateFailureError.