@@ -21,15 +21,25 @@ def get_pod_statuses():
21
21
pod_name = pod .metadata .name
22
22
pod_status = pod .status .phase
23
23
container_statuses = pod .status .container_statuses or []
24
- ready_containers = sum (1 for status in container_statuses if status .ready )
25
- total_containers = len (container_statuses )
26
- statuses [pod_name ] = (pod_status , ready_containers , total_containers )
24
+ ready = 0
25
+ total = 0
26
+ waiting_messages = []
27
+ for status in container_statuses :
28
+ total += 1
29
+ if status .ready :
30
+ ready += 1
31
+ if status .state .waiting is not None :
32
+ if status .state .waiting .message is not None :
33
+ waiting_messages .append (f'Waiting on Container: { status .name } - { status .state .waiting .reason } : { status .state .waiting .message } ' )
34
+ else :
35
+ waiting_messages .append (f'Waiting on Container: { status .name } - { status .state .waiting .reason } ' )
36
+ statuses [pod_name ] = (pod_status , ready , total , waiting_messages )
27
37
return statuses
28
38
29
39
30
40
def all_pods_ready (statuses ):
31
41
return all (pod_status == 'Running' and ready == total
32
- for pod_status , ready , total in statuses .values ())
42
+ for pod_status , ready , total , _ in statuses .values ())
33
43
34
44
35
45
def check_pods (calm_time = 10 , timeout = 600 , retries_after_ready = 5 ):
@@ -41,8 +51,10 @@ def check_pods(calm_time=10, timeout=600, retries_after_ready=5):
41
51
current_statuses = get_pod_statuses ()
42
52
43
53
logging .info ("Checking pod statuses..." )
44
- for pod_name , (pod_status , ready , total ) in current_statuses .items ():
54
+ for pod_name , (pod_status , ready , total , waiting_messages ) in current_statuses .items ():
45
55
logging .info (f"Pod { pod_name } - Status: { pod_status } , Ready: { ready } /{ total } " )
56
+ for waiting_msg in waiting_messages :
57
+ logging .info (waiting_msg )
46
58
47
59
if current_statuses == previous_statuses :
48
60
if all_pods_ready (current_statuses ):
@@ -65,7 +77,7 @@ def check_pods(calm_time=10, timeout=600, retries_after_ready=5):
65
77
raise Exception ("Pods did not stabilize within the timeout period." )
66
78
67
79
logging .info ("Final pod statuses:" )
68
- for pod_name , (pod_status , ready , total ) in previous_statuses .items ():
80
+ for pod_name , (pod_status , ready , total , _ ) in previous_statuses .items ():
69
81
if pod_status == 'Running' and ready == total :
70
82
logging .info (f"Pod { pod_name } is fully ready ({ ready } /{ total } )" )
71
83
else :
0 commit comments