@@ -28,11 +28,27 @@ import (
28
28
)
29
29
30
30
func podToContainerSummary (pod corev1.Pod ) compose.ContainerSummary {
31
+ state := compose .RUNNING
32
+
33
+ if pod .DeletionTimestamp != nil {
34
+ state = compose .REMOVING
35
+ } else {
36
+ for _ , container := range pod .Status .ContainerStatuses {
37
+ if container .State .Waiting != nil || container .State .Terminated != nil {
38
+ state = compose .UPDATING
39
+ break
40
+ }
41
+ }
42
+ if state == compose .RUNNING && pod .Status .Phase != corev1 .PodRunning {
43
+ state = string (pod .Status .Phase )
44
+ }
45
+ }
46
+
31
47
return compose.ContainerSummary {
32
48
ID : pod .GetObjectMeta ().GetName (),
33
49
Name : pod .GetObjectMeta ().GetName (),
34
50
Service : pod .GetObjectMeta ().GetLabels ()[compose .ServiceTag ],
35
- State : string ( pod . Status . Phase ) ,
51
+ State : state ,
36
52
Project : pod .GetObjectMeta ().GetLabels ()[compose .ProjectTag ],
37
53
}
38
54
}
@@ -46,6 +62,13 @@ func checkPodsState(services []string, pods []corev1.Pod, status string) (bool,
46
62
if len (services ) > 0 && ! utils .StringContains (services , service ) {
47
63
continue
48
64
}
65
+ containersRunning := true
66
+ for _ , container := range pod .Status .ContainerStatuses {
67
+ if container .State .Running == nil {
68
+ containersRunning = false
69
+ break
70
+ }
71
+ }
49
72
servicePods [service ] = pod .Status .Message
50
73
51
74
if status == compose .REMOVING {
@@ -54,7 +77,7 @@ func checkPodsState(services []string, pods []corev1.Pod, status string) (bool,
54
77
if pod .Status .Phase == corev1 .PodFailed {
55
78
return false , servicePods , fmt .Errorf (pod .Status .Reason )
56
79
}
57
- if status == compose .RUNNING && pod .Status .Phase != corev1 .PodRunning {
80
+ if status == compose .RUNNING && ( pod .Status .Phase != corev1 .PodRunning || ! containersRunning ) {
58
81
stateReached = false
59
82
}
60
83
}
0 commit comments