Skip to content

Commit

Permalink
fix: job pod status get error
Browse files Browse the repository at this point in the history
Signed-off-by: 张启航 <[email protected]>
  • Loading branch information
ZhangSetSail committed Nov 15, 2024
1 parent eda9b78 commit 4ec30d9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions worker/util/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ func DescribePodStatus(clientset kubernetes.Interface, pod *corev1.Pod, podStatu
podStatus.Message = condition.Message
}
}
if podStatus.Type == pb.PodStatus_PENDING {
for _, cstatus := range pod.Status.ContainerStatuses {
for _, OwnerReference := range pod.OwnerReferences {
if OwnerReference.Kind == "Job" {
if cstatus.State.Terminated.Reason == "Completed" {
podStatus.Type = pb.PodStatus_SUCCEEDED
}
if cstatus.State.Terminated.Reason == "DeadlineExceeded" {
podStatus.Type = pb.PodStatus_FAILED
}
if cstatus.State.Terminated.Reason == "Error" {
podStatus.Type = pb.PodStatus_ABNORMAL
}
}
}
return
}
}
if podStatus.Type == pb.PodStatus_INITIATING {
podStatus.Advice = PodStatusAdviceInitiating.String()
// if all main container ready
Expand Down

0 comments on commit 4ec30d9

Please sign in to comment.