Skip to content

Commit

Permalink
add pod status:unknown and terminating
Browse files Browse the repository at this point in the history
  • Loading branch information
zehuaiWANG committed Jan 15, 2020
1 parent c9c029a commit dd72cc8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/app/backend/resource/common/resourcestatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,10 @@ type ResourceStatus struct {

// Number of resources that are in succeeded state.
Succeeded int `json:"succeeded"`

// Number of resources that are in unknown state.
Unknown int `json:"unknown"`

// Number of resources that are in terminating state.
Terminating int `json:"terminating"`
}
12 changes: 11 additions & 1 deletion src/app/backend/resource/pod/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func getPodStatus(pod v1.Pod, warnings []common.Event) PodStatus {
}
}

// getPodStatusPhase returns one of four pod status phases (Pending, Running, Succeeded, Failed)
// getPodStatusPhase returns one of four pod status phases (Pending, Running, Succeeded, Failed, Unknow, Terminating)
func getPodStatusPhase(pod v1.Pod, warnings []common.Event) v1.PodPhase {
// For terminated pods that failed
if pod.Status.Phase == v1.PodFailed {
Expand Down Expand Up @@ -79,6 +79,12 @@ func getPodStatusPhase(pod v1.Pod, warnings []common.Event) v1.PodPhase {
return v1.PodFailed
}

if pod.DeletionTimestamp != nil && pod.Status.Reason == "NodeLost" {
return v1.PodUnknown
} else if pod.DeletionTimestamp != nil {
return "Terminating"
}

// pending
return v1.PodPending
}
Expand Down Expand Up @@ -160,6 +166,10 @@ func getStatus(list *v1.PodList, events []v1.Event) common.ResourceStatus {
info.Running++
case v1.PodPending:
info.Pending++
case v1.PodUnknown:
info.Unknown++
case "Terminating":
info.Terminating++
}
}

Expand Down

0 comments on commit dd72cc8

Please sign in to comment.