Skip to content

Commit 186d8a3

Browse files
authored
Match pod status with resource status (#38)
1 parent e0be959 commit 186d8a3

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

pkg/operator/k8s/pod.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,19 @@ func GetPodStatus(pod *corev1.Pod) string {
105105
case corev1.PodSucceeded:
106106
return PodStatusSucceeded
107107
case corev1.PodFailed:
108+
for _, containerStatus := range pod.Status.ContainerStatuses {
109+
if containerStatus.LastTerminationState.Terminated != nil {
110+
exitCode := containerStatus.LastTerminationState.Terminated.ExitCode
111+
if killStatuses[exitCode] {
112+
return PodStatusKilled
113+
}
114+
} else if containerStatus.State.Terminated != nil {
115+
exitCode := containerStatus.State.Terminated.ExitCode
116+
if killStatuses[exitCode] {
117+
return PodStatusKilled
118+
}
119+
}
120+
}
108121
return PodStatusFailed
109122
case corev1.PodRunning:
110123
if pod.ObjectMeta.DeletionTimestamp != nil {

pkg/operator/workloads/workload_spec.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/cortexlabs/cortex/pkg/lib/sets/strset"
3030
"github.com/cortexlabs/cortex/pkg/operator/aws"
3131
ocontext "github.com/cortexlabs/cortex/pkg/operator/context"
32+
"github.com/cortexlabs/cortex/pkg/operator/k8s"
3233
)
3334

3435
type WorkloadSpec struct {
@@ -148,7 +149,12 @@ func UpdateDataWorkflowErrors(failedPods []corev1.Pod) error {
148149
if savedStatus.Start == nil {
149150
savedStatus.Start = nowTime
150151
}
152+
151153
savedStatus.ExitCode = resource.ExitCodeDataFailed
154+
if k8s.GetPodStatus(&pod) == k8s.PodStatusKilled {
155+
savedStatus.ExitCode = resource.ExitCodeDataKilled
156+
}
157+
152158
savedStatusesToUpload = append(savedStatusesToUpload, savedStatus)
153159
}
154160
}

0 commit comments

Comments
 (0)