Check pod container ready state (#861)

Ensure pod is ready by checking pod’s containers state and deletionTimestamp
This commit is contained in:
Ta-Ching Chen
2018-09-07 22:17:07 +08:00
committed by GitHub
parent 2dbae32f20
commit a4f58fbf10
2 changed files with 11 additions and 14 deletions
+3 -13
View File
@@ -47,8 +47,6 @@ import (
"github.com/fission/fission/executor/util"
)
const POD_PHASE_RUNNING string = "Running"
type (
GenericPool struct {
env *crd.Environment
@@ -228,21 +226,13 @@ func (gp *GenericPool) _choosePod(newLabels map[string]string) (*apiv1.Pod, erro
for i := range podList.Items {
pod := podList.Items[i]
// If a pod has no IP it's not ready
if len(pod.Status.PodIP) == 0 || string(pod.Status.Phase) != POD_PHASE_RUNNING {
// Ignore not ready pod here
if !fission.IsReadyPod(&pod) {
continue
}
// Wait for all containers in the pod to be ready
podReady := true
for _, cs := range pod.Status.ContainerStatuses {
podReady = podReady && cs.Ready
}
// add it to the list of ready pods
if podReady {
readyPods = append(readyPods, &pod)
}
readyPods = append(readyPods, &pod)
}
log.Printf("[%v] found %v ready pods of %v total", newLabels, len(readyPods), len(podList.Items))