From 70d5209437cf4d0700a92f28b1d12e6620e6ef1e Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Fri, 29 May 2026 09:57:55 +0200 Subject: [PATCH 1/5] Only check pod phase in isPodReady This is a quick test. The current impl doesn't work, when there are init containers that are sidecars. They stay in state=running and currently this will always make `isPodReady` return false. --- internal/controller/status.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/controller/status.go b/internal/controller/status.go index 3dbb79b6..13291ef5 100644 --- a/internal/controller/status.go +++ b/internal/controller/status.go @@ -45,8 +45,9 @@ func podIsReady(pod *v1.Pod) bool { return false } phaseOk := pod.Status.Phase == v1.PodSucceeded || pod.Status.Phase == v1.PodRunning - initCounts, counts := containerCounts(pod) - return initCounts.Ok() && counts.Ok() && phaseOk + // initCounts, counts := containerCounts(pod) + // return initCounts.Ok() && counts.Ok() && phaseOk + return phaseOk } func podIsCompleted(pod *v1.Pod) bool { From 410e16a68ba854967c13bc90ffb78b60de33a9b9 Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Fri, 29 May 2026 11:35:00 +0200 Subject: [PATCH 2/5] Check sidcar containers as running --- internal/controller/status.go | 36 ++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/internal/controller/status.go b/internal/controller/status.go index 13291ef5..c5ba924d 100644 --- a/internal/controller/status.go +++ b/internal/controller/status.go @@ -21,10 +21,17 @@ func containerCounts(pod *v1.Pod) (amaltheadevv1alpha1.ContainerCounts, amalthea if pod == nil { return initCounts, counts } + for _, container := range pod.Status.InitContainerStatuses { - containerCompleted := container.State.Terminated != nil && container.State.Terminated.ExitCode == 0 && container.State.Terminated.Reason == "Completed" + var containerOk bool + if isContainerSidecar(container, *pod) { + containerOk = container.Ready && container.State.Running != nil + } else { + containerOk = container.State.Terminated != nil && container.State.Terminated.ExitCode == 0 && container.State.Terminated.Reason == "Completed" + } + initCounts.Total += 1 - if containerCompleted { + if containerOk { initCounts.Ready += 1 } } @@ -39,15 +46,34 @@ func containerCounts(pod *v1.Pod) (amaltheadevv1alpha1.ContainerCounts, amalthea return initCounts, counts } +func containerRestartPolicy(status v1.ContainerStatus, pod v1.Pod) *v1.ContainerRestartPolicy { + for _, c := range pod.Spec.Containers { + if c.Name == status.Name { + return c.RestartPolicy + } + } + return nil +} + +func isContainerSidecar(status v1.ContainerStatus, pod v1.Pod) bool { + restartPolicy := containerRestartPolicy(status, pod) + if restartPolicy != nil { + switch *restartPolicy { + case v1.ContainerRestartPolicyAlways: + return true + } + } + return false +} + func podIsReady(pod *v1.Pod) bool { if pod == nil || pod.GetDeletionTimestamp() != nil { // A missing pod or a pod being deleted is not considered ready return false } phaseOk := pod.Status.Phase == v1.PodSucceeded || pod.Status.Phase == v1.PodRunning - // initCounts, counts := containerCounts(pod) - // return initCounts.Ok() && counts.Ok() && phaseOk - return phaseOk + initCounts, counts := containerCounts(pod) + return initCounts.Ok() && counts.Ok() && phaseOk } func podIsCompleted(pod *v1.Pod) bool { From 478f1a8c0b59ca1bb67697d40be3375ae40acc11 Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Fri, 29 May 2026 13:52:52 +0200 Subject: [PATCH 3/5] logging --- internal/controller/status.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/controller/status.go b/internal/controller/status.go index c5ba924d..1bb9c5ef 100644 --- a/internal/controller/status.go +++ b/internal/controller/status.go @@ -26,6 +26,7 @@ func containerCounts(pod *v1.Pod) (amaltheadevv1alpha1.ContainerCounts, amalthea var containerOk bool if isContainerSidecar(container, *pod) { containerOk = container.Ready && container.State.Running != nil + fmt.Println(">>>>> Container is sidecar: ", container.Name, " ready: ", container.Ready, " running: ", container.State.Running) } else { containerOk = container.State.Terminated != nil && container.State.Terminated.ExitCode == 0 && container.State.Terminated.Reason == "Completed" } @@ -49,6 +50,7 @@ func containerCounts(pod *v1.Pod) (amaltheadevv1alpha1.ContainerCounts, amalthea func containerRestartPolicy(status v1.ContainerStatus, pod v1.Pod) *v1.ContainerRestartPolicy { for _, c := range pod.Spec.Containers { if c.Name == status.Name { + fmt.Println(">>>>>> RestartPolicy: ", c.RestartPolicy) return c.RestartPolicy } } @@ -67,6 +69,20 @@ func isContainerSidecar(status v1.ContainerStatus, pod v1.Pod) bool { } func podIsReady(pod *v1.Pod) bool { + if pod == nil || pod.GetDeletionTimestamp() != nil { + return false + } + phaseOk := pod.Status.Phase == v1.PodSucceeded || pod.Status.Phase == v1.PodRunning + condOk := false + for _, c := range pod.Status.Conditions { + if c.Type == v1.PodReady && c.Status == v1.ConditionTrue { + condOk = true + } + } + return phaseOk && condOk +} + +func podIsReady_prev(pod *v1.Pod) bool { if pod == nil || pod.GetDeletionTimestamp() != nil { // A missing pod or a pod being deleted is not considered ready return false From 4fe2b74ae7d3685eb0bd509fee6f762e078f8e4f Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Fri, 29 May 2026 14:04:12 +0200 Subject: [PATCH 4/5] revert --- internal/controller/status.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/controller/status.go b/internal/controller/status.go index 1bb9c5ef..f6921c70 100644 --- a/internal/controller/status.go +++ b/internal/controller/status.go @@ -68,7 +68,7 @@ func isContainerSidecar(status v1.ContainerStatus, pod v1.Pod) bool { return false } -func podIsReady(pod *v1.Pod) bool { +func podIsReady_n(pod *v1.Pod) bool { if pod == nil || pod.GetDeletionTimestamp() != nil { return false } @@ -82,7 +82,7 @@ func podIsReady(pod *v1.Pod) bool { return phaseOk && condOk } -func podIsReady_prev(pod *v1.Pod) bool { +func podIsReady(pod *v1.Pod) bool { if pod == nil || pod.GetDeletionTimestamp() != nil { // A missing pod or a pod being deleted is not considered ready return false From 18c8b7d083f5eecd171cb25907f5e25182aa7a51 Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Fri, 29 May 2026 14:17:47 +0200 Subject: [PATCH 5/5] Use condition "Ready" --- internal/controller/status.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/internal/controller/status.go b/internal/controller/status.go index f6921c70..c1b02cbe 100644 --- a/internal/controller/status.go +++ b/internal/controller/status.go @@ -26,7 +26,6 @@ func containerCounts(pod *v1.Pod) (amaltheadevv1alpha1.ContainerCounts, amalthea var containerOk bool if isContainerSidecar(container, *pod) { containerOk = container.Ready && container.State.Running != nil - fmt.Println(">>>>> Container is sidecar: ", container.Name, " ready: ", container.Ready, " running: ", container.State.Running) } else { containerOk = container.State.Terminated != nil && container.State.Terminated.ExitCode == 0 && container.State.Terminated.Reason == "Completed" } @@ -50,7 +49,6 @@ func containerCounts(pod *v1.Pod) (amaltheadevv1alpha1.ContainerCounts, amalthea func containerRestartPolicy(status v1.ContainerStatus, pod v1.Pod) *v1.ContainerRestartPolicy { for _, c := range pod.Spec.Containers { if c.Name == status.Name { - fmt.Println(">>>>>> RestartPolicy: ", c.RestartPolicy) return c.RestartPolicy } } @@ -68,7 +66,7 @@ func isContainerSidecar(status v1.ContainerStatus, pod v1.Pod) bool { return false } -func podIsReady_n(pod *v1.Pod) bool { +func podIsReady(pod *v1.Pod) bool { if pod == nil || pod.GetDeletionTimestamp() != nil { return false } @@ -82,16 +80,6 @@ func podIsReady_n(pod *v1.Pod) bool { return phaseOk && condOk } -func podIsReady(pod *v1.Pod) bool { - if pod == nil || pod.GetDeletionTimestamp() != nil { - // A missing pod or a pod being deleted is not considered ready - return false - } - phaseOk := pod.Status.Phase == v1.PodSucceeded || pod.Status.Phase == v1.PodRunning - initCounts, counts := containerCounts(pod) - return initCounts.Ok() && counts.Ok() && phaseOk -} - func podIsCompleted(pod *v1.Pod) bool { if pod == nil || pod.GetDeletionTimestamp() != nil { // A missing pod or a pod being deleted is not completed