From 0eb4322793b4a31989307fa5057cfc7336c7782c Mon Sep 17 00:00:00 2001 From: Martyn Dale Date: Fri, 14 Jun 2024 17:02:07 -0700 Subject: [PATCH 1/2] Update pod status logic to support native sidecars Signed-off-by: Martyn Dale --- pkg/kubectl-argo-rollouts/info/pod_info.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/kubectl-argo-rollouts/info/pod_info.go b/pkg/kubectl-argo-rollouts/info/pod_info.go index e53f350848..7751a7433b 100644 --- a/pkg/kubectl-argo-rollouts/info/pod_info.go +++ b/pkg/kubectl-argo-rollouts/info/pod_info.go @@ -53,6 +53,12 @@ func newPodInfo(pod *corev1.Pod) rollout.PodInfo { }, } restarts := 0 + rs := make(map[string]bool, len(pod.Spec.InitContainers)) + for _, c := range pod.Spec.InitContainers { + p := c.RestartPolicy + rs[c.Name] = p != nil && *p == corev1.ContainerRestartPolicyAlways + } + totalContainers := len(pod.Spec.Containers) readyContainers := 0 @@ -69,7 +75,7 @@ func newPodInfo(pod *corev1.Pod) rollout.PodInfo { continue case container.State.Terminated != nil: // initialization is failed - if len(container.State.Terminated.Reason) == 0 { + if container.State.Terminated.Reason == "" { if container.State.Terminated.Signal != 0 { reason = fmt.Sprintf("Init:Signal:%d", container.State.Terminated.Signal) } else { @@ -79,6 +85,10 @@ func newPodInfo(pod *corev1.Pod) rollout.PodInfo { reason = "Init:" + container.State.Terminated.Reason } initializing = true + case rs[container.Name] && container.Started != nil && *container.Started: + if container.Ready { + continue; + } case container.State.Waiting != nil && len(container.State.Waiting.Reason) > 0 && container.State.Waiting.Reason != "PodInitializing": reason = "Init:" + container.State.Waiting.Reason initializing = true From ee1afd1379545cad9b414906da6507459a4abdf5 Mon Sep 17 00:00:00 2001 From: Martyn Dale Date: Thu, 25 Jul 2024 15:11:19 -0700 Subject: [PATCH 2/2] Fix lint issues Signed-off-by: Martyn Dale --- pkg/kubectl-argo-rollouts/info/pod_info.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/kubectl-argo-rollouts/info/pod_info.go b/pkg/kubectl-argo-rollouts/info/pod_info.go index 7751a7433b..463657d70d 100644 --- a/pkg/kubectl-argo-rollouts/info/pod_info.go +++ b/pkg/kubectl-argo-rollouts/info/pod_info.go @@ -53,11 +53,11 @@ func newPodInfo(pod *corev1.Pod) rollout.PodInfo { }, } restarts := 0 - rs := make(map[string]bool, len(pod.Spec.InitContainers)) - for _, c := range pod.Spec.InitContainers { - p := c.RestartPolicy - rs[c.Name] = p != nil && *p == corev1.ContainerRestartPolicyAlways - } + rs := make(map[string]bool, len(pod.Spec.InitContainers)) + for _, c := range pod.Spec.InitContainers { + p := c.RestartPolicy + rs[c.Name] = p != nil && *p == corev1.ContainerRestartPolicyAlways + } totalContainers := len(pod.Spec.Containers) readyContainers := 0 @@ -85,10 +85,10 @@ func newPodInfo(pod *corev1.Pod) rollout.PodInfo { reason = "Init:" + container.State.Terminated.Reason } initializing = true - case rs[container.Name] && container.Started != nil && *container.Started: - if container.Ready { - continue; - } + case rs[container.Name] && container.Started != nil && *container.Started: + if container.Ready { + continue + } case container.State.Waiting != nil && len(container.State.Waiting.Reason) > 0 && container.State.Waiting.Reason != "PodInitializing": reason = "Init:" + container.State.Waiting.Reason initializing = true