From fcc5f64c6ab7984cb1d172970563252779d13b3c Mon Sep 17 00:00:00 2001 From: Oleg Vasilev Date: Thu, 29 Aug 2024 15:14:27 +0200 Subject: [PATCH] Revert "neonvm: Use container statuses, not pod phase, to trigger restart (#749)" This reverts commit 7f17032a38e22a6320797fa503cd0e3b166f751e. Signed-off-by: Oleg Vasilev --- neonvm/controllers/vm_controller.go | 52 ++--------------------------- tests/e2e/runner-pod/01-assert.yaml | 2 -- 2 files changed, 2 insertions(+), 52 deletions(-) diff --git a/neonvm/controllers/vm_controller.go b/neonvm/controllers/vm_controller.go index bdf8f8e53..8989be075 100644 --- a/neonvm/controllers/vm_controller.go +++ b/neonvm/controllers/vm_controller.go @@ -932,20 +932,7 @@ const ( // runnerStatus returns a description of the status of the VM inside the runner pod. // -// This is *similar* to the value of pod.Status.Phase, but takes into consideration the statuses of -// the individual containers within the pod. This is because Kubernetes sets the pod phase to Failed -// or Succeeded only if *all* pods have exited, whereas we'd like to consider the VM to be Failed or -// Succeeded if *any* pod has exited. -// -// The full set of outputs is: -// -// - runnerUnknown, if pod.Status.Phase is Unknown -// - runnerPending, if pod.Status.Phase is "" or Pending -// - runnerRunning, if pod.Status.Phase is Running, and no containers have exited -// - runnerFailed, if pod.Status.Phase is Failed, or if any container has failed, or if any -// container other than neonvm-runner has exited -// - runnerSucceeded, if pod.Status.Phase is Succeeded, or if neonvm-runner has exited -// successfully +// This is *similar* to the value of pod.Status.Phaseg . func runnerStatus(pod *corev1.Pod) runnerStatusKind { switch pod.Status.Phase { case "", corev1.PodPending: @@ -956,43 +943,8 @@ func runnerStatus(pod *corev1.Pod) runnerStatusKind { return runnerFailed case corev1.PodUnknown: return runnerUnknown - - // See comment above for context on this logic case corev1.PodRunning: - nonRunnerContainerSucceeded := false - runnerContainerSucceeded := false - - for _, stat := range pod.Status.ContainerStatuses { - if stat.State.Terminated != nil { - failed := stat.State.Terminated.ExitCode != 0 - isRunner := stat.Name == "neonvm-runner" - - if failed { - // return that the "runner" has failed if any container has. - return runnerFailed - } else /* succeeded */ { - if isRunner { - // neonvm-runner succeeded. We'll return runnerSucceeded if no other - // container has failed. - runnerContainerSucceeded = true - } else { - // Other container has succeeded. We'll return runnerSucceeded if - // neonvm-runner has succeeded, but runnerFailed if this exited while - // neonvm-runner is still going. - nonRunnerContainerSucceeded = true - } - } - } - } - - if runnerContainerSucceeded { - return runnerSucceeded - } else if nonRunnerContainerSucceeded { - return runnerFailed - } else { - return runnerRunning - } - + return runnerRunning default: panic(fmt.Errorf("unknown pod phase: %q", pod.Status.Phase)) } diff --git a/tests/e2e/runner-pod/01-assert.yaml b/tests/e2e/runner-pod/01-assert.yaml index a26f74f49..383f72db7 100644 --- a/tests/e2e/runner-pod/01-assert.yaml +++ b/tests/e2e/runner-pod/01-assert.yaml @@ -13,8 +13,6 @@ status: conditions: - type: Available status: "True" - - type: Degraded - status: "True" cpus: 250m memorySize: 1Gi restartCount: 1