Skip to content

Commit 6a1d72b

Browse files
committed
Revert "neonvm: Use container statuses, not pod phase, to trigger restart (#749)"
This reverts commit 7f17032. Signed-off-by: Oleg Vasilev <[email protected]>
1 parent 3e6da9c commit 6a1d72b

File tree

2 files changed

+3
-52
lines changed

2 files changed

+3
-52
lines changed

neonvm/controllers/vm_controller.go

+3-50
Original file line numberDiff line numberDiff line change
@@ -932,20 +932,8 @@ const (
932932

933933
// runnerStatus returns a description of the status of the VM inside the runner pod.
934934
//
935-
// This is *similar* to the value of pod.Status.Phase, but takes into consideration the statuses of
936-
// the individual containers within the pod. This is because Kubernetes sets the pod phase to Failed
937-
// or Succeeded only if *all* pods have exited, whereas we'd like to consider the VM to be Failed or
938-
// Succeeded if *any* pod has exited.
939-
//
940-
// The full set of outputs is:
941-
//
942-
// - runnerUnknown, if pod.Status.Phase is Unknown
943-
// - runnerPending, if pod.Status.Phase is "" or Pending
944-
// - runnerRunning, if pod.Status.Phase is Running, and no containers have exited
945-
// - runnerFailed, if pod.Status.Phase is Failed, or if any container has failed, or if any
946-
// container other than neonvm-runner has exited
947-
// - runnerSucceeded, if pod.Status.Phase is Succeeded, or if neonvm-runner has exited
948-
// successfully
935+
// This is *similar* to the value of pod.Status.Phase, but we'd like to retain our own abstraction
936+
// to have more control over the semantics.
949937
func runnerStatus(pod *corev1.Pod) runnerStatusKind {
950938
switch pod.Status.Phase {
951939
case "", corev1.PodPending:
@@ -956,43 +944,8 @@ func runnerStatus(pod *corev1.Pod) runnerStatusKind {
956944
return runnerFailed
957945
case corev1.PodUnknown:
958946
return runnerUnknown
959-
960-
// See comment above for context on this logic
961947
case corev1.PodRunning:
962-
nonRunnerContainerSucceeded := false
963-
runnerContainerSucceeded := false
964-
965-
for _, stat := range pod.Status.ContainerStatuses {
966-
if stat.State.Terminated != nil {
967-
failed := stat.State.Terminated.ExitCode != 0
968-
isRunner := stat.Name == "neonvm-runner"
969-
970-
if failed {
971-
// return that the "runner" has failed if any container has.
972-
return runnerFailed
973-
} else /* succeeded */ {
974-
if isRunner {
975-
// neonvm-runner succeeded. We'll return runnerSucceeded if no other
976-
// container has failed.
977-
runnerContainerSucceeded = true
978-
} else {
979-
// Other container has succeeded. We'll return runnerSucceeded if
980-
// neonvm-runner has succeeded, but runnerFailed if this exited while
981-
// neonvm-runner is still going.
982-
nonRunnerContainerSucceeded = true
983-
}
984-
}
985-
}
986-
}
987-
988-
if runnerContainerSucceeded {
989-
return runnerSucceeded
990-
} else if nonRunnerContainerSucceeded {
991-
return runnerFailed
992-
} else {
993-
return runnerRunning
994-
}
995-
948+
return runnerRunning
996949
default:
997950
panic(fmt.Errorf("unknown pod phase: %q", pod.Status.Phase))
998951
}

tests/e2e/runner-pod/01-assert.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ status:
1313
conditions:
1414
- type: Available
1515
status: "True"
16-
- type: Degraded
17-
status: "True"
1816
cpus: 250m
1917
memorySize: 1Gi
2018
restartCount: 1

0 commit comments

Comments
 (0)