Skip to content

Commit

Permalink
chore: fix pod readiness
Browse files Browse the repository at this point in the history
  • Loading branch information
moshloop committed Nov 28, 2024
1 parent cda0e78 commit 43af4db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/health/health_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions pkg/health/testdata/Kubernetes/Pod/healthy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 43af4db

Please sign in to comment.