mirror of https://github.com/docker/compose.git
Check the status of pod containers on `compose up`
Signed-off-by: aiordache <anca.iordache@docker.com>
This commit is contained in:
parent
d0e8ebef15
commit
9279954193
|
@ -28,11 +28,27 @@ import (
|
|||
)
|
||||
|
||||
func podToContainerSummary(pod corev1.Pod) compose.ContainerSummary {
|
||||
state := compose.RUNNING
|
||||
|
||||
if pod.DeletionTimestamp != nil {
|
||||
state = compose.REMOVING
|
||||
} else {
|
||||
for _, container := range pod.Status.ContainerStatuses {
|
||||
if container.State.Waiting != nil || container.State.Terminated != nil {
|
||||
state = compose.UPDATING
|
||||
break
|
||||
}
|
||||
}
|
||||
if state == compose.RUNNING && pod.Status.Phase != corev1.PodRunning {
|
||||
state = string(pod.Status.Phase)
|
||||
}
|
||||
}
|
||||
|
||||
return compose.ContainerSummary{
|
||||
ID: pod.GetObjectMeta().GetName(),
|
||||
Name: pod.GetObjectMeta().GetName(),
|
||||
Service: pod.GetObjectMeta().GetLabels()[compose.ServiceTag],
|
||||
State: string(pod.Status.Phase),
|
||||
State: state,
|
||||
Project: pod.GetObjectMeta().GetLabels()[compose.ProjectTag],
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +62,13 @@ func checkPodsState(services []string, pods []corev1.Pod, status string) (bool,
|
|||
if len(services) > 0 && !utils.StringContains(services, service) {
|
||||
continue
|
||||
}
|
||||
containersRunning := true
|
||||
for _, container := range pod.Status.ContainerStatuses {
|
||||
if container.State.Running == nil {
|
||||
containersRunning = false
|
||||
break
|
||||
}
|
||||
}
|
||||
servicePods[service] = pod.Status.Message
|
||||
|
||||
if status == compose.REMOVING {
|
||||
|
@ -54,7 +77,7 @@ func checkPodsState(services []string, pods []corev1.Pod, status string) (bool,
|
|||
if pod.Status.Phase == corev1.PodFailed {
|
||||
return false, servicePods, fmt.Errorf(pod.Status.Reason)
|
||||
}
|
||||
if status == compose.RUNNING && pod.Status.Phase != corev1.PodRunning {
|
||||
if status == compose.RUNNING && (pod.Status.Phase != corev1.PodRunning || !containersRunning) {
|
||||
stateReached = false
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue