From 43af4dba82a33ddf55a24c8d8b086a4f540f365f Mon Sep 17 00:00:00 2001 From: Moshe Immermam Date: Thu, 28 Nov 2024 11:59:08 +0200 Subject: [PATCH] chore: fix pod readiness --- pkg/health/health_pod.go | 10 ++++++++-- pkg/health/testdata/Kubernetes/Pod/healthy.yaml | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/health/health_pod.go b/pkg/health/health_pod.go index 3d4bf00..e031790 100644 --- a/pkg/health/health_pod.go +++ b/pkg/health/health_pod.go @@ -101,8 +101,13 @@ func getContainerStatus(containerStatus corev1.ContainerStatus) (waiting *Health terminated.Status = HealthStatusCode(state.Reason) terminated.AppendMessage("exit=%d", state.ExitCode) } else if state.Reason == string(HealthStatusCompleted) { - // completed with restart - terminated.Status = "RestartLoop" + if waiting != nil && waiting.Status == HealthStatusCrashLoopBackoff { + // completed with crash loop backoff + terminated.Status = "RestartLoopBackOff" + } else { + // completed with restart + terminated.Status = "RestartLoop" + } } else { terminated.Status = HealthStatusCode(state.Reason) } @@ -119,6 +124,7 @@ func getCorev1PodHealth(pod *corev1.Pod) (*HealthStatus, error) { isStarting := age < deadline hr := HealthStatus{ Health: lo.Ternary(isReady, HealthHealthy, HealthUnhealthy), + Ready: isReady, } if pod.ObjectMeta.DeletionTimestamp != nil && !pod.ObjectMeta.DeletionTimestamp.IsZero() { diff --git a/pkg/health/testdata/Kubernetes/Pod/healthy.yaml b/pkg/health/testdata/Kubernetes/Pod/healthy.yaml index cbb55b0..11525f6 100644 --- a/pkg/health/testdata/Kubernetes/Pod/healthy.yaml +++ b/pkg/health/testdata/Kubernetes/Pod/healthy.yaml @@ -10,6 +10,7 @@ metadata: namespace: kube-system annotations: eks.amazonaws.com/compute-type: ec2 + expected-ready: "true" generateName: coredns-7448775847- ownerReferences: - uid: 3b4888e3-9330-4148-b0f4-559ceb4c6463