@@ -932,20 +932,8 @@ const (
932
932
933
933
// runnerStatus returns a description of the status of the VM inside the runner pod.
934
934
//
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.
949
937
func runnerStatus (pod * corev1.Pod ) runnerStatusKind {
950
938
switch pod .Status .Phase {
951
939
case "" , corev1 .PodPending :
@@ -956,43 +944,8 @@ func runnerStatus(pod *corev1.Pod) runnerStatusKind {
956
944
return runnerFailed
957
945
case corev1 .PodUnknown :
958
946
return runnerUnknown
959
-
960
- // See comment above for context on this logic
961
947
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
996
949
default :
997
950
panic (fmt .Errorf ("unknown pod phase: %q" , pod .Status .Phase ))
998
951
}
0 commit comments