Show the reason for a waiting state, or default to the phase
@@ -19,6 +19,14 @@ from datetime import datetime
from .pod import Pod
+def get_status(status):
+ # try to find the error reasons, if any
+ try:
+ reasons = [x.state.waiting.reason for x in status.container_statuses]
+ return ','.join(reasons)
+ except:
+ return status.phase
+
class K8sInventory():
""" Kubernetes inventory - deal with namespaces, deployments and pods.
Also manages cache.
@@ -100,7 +108,7 @@ class K8sInventory():
ip=item.status.pod_ip,
container_ids=container_ids,
restart_count=sum(restart_count),
- state=item.status.phase,
+ state=get_status(item.status),
labels=item.metadata.labels,
meta=item,
))
