From 5034747fff6c05e08277e393077a27887de5343d Mon Sep 17 00:00:00 2001 From: Jwalant Modi Date: Fri, 27 Sep 2024 12:25:04 +0530 Subject: [PATCH] Added reasons to logs for unscheduled pods --- pkg/utils/pod.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/utils/pod.go b/pkg/utils/pod.go index 1504d753..a5b9368a 100644 --- a/pkg/utils/pod.go +++ b/pkg/utils/pod.go @@ -35,8 +35,8 @@ func CheckPodFailed(pod *corev1.Pod) error { } if pod.Status.Phase == corev1.PodPending { - if isPodUnschedulable, err := IsPodReasonUnschedulable(pod); isPodUnschedulable { - return fmt.Errorf("pod %s is in unschedulable state and reason is %v", pod.Name, err) + if isPodUnschedulable, reason := IsPodReasonUnschedulable(pod); isPodUnschedulable { + return fmt.Errorf("pod %s is in unschedulable state and reason is %s", pod.Name, reason) } } @@ -202,13 +202,13 @@ func isPodError(reason string) bool { return strings.HasSuffix(reason, "Error") } -func IsPodReasonUnschedulable(pod *corev1.Pod) (bool, error) { +func IsPodReasonUnschedulable(pod *corev1.Pod) (isPodUnschedulable bool, reason string) { for _, condition := range pod.Status.Conditions { if condition.Type == corev1.PodScheduled && (condition.Reason == corev1.PodReasonUnschedulable || condition.Reason == corev1.PodReasonSchedulerError) { - return true, fmt.Errorf("%s", condition.Message) + return true, condition.Message } } - return false, nil + return false, "" }