Skip to content

Commit 4b55c8a

Browse files
committed
fix: don't error if pod has no containerStatuses (#4471)
In certain circumstances pod["status"] may not have a containerStatuses child property at all (e.g. if the pod is Pending and not yet scheduled to any node). Guard against this by using .get (returns None) instead of [] (raises KeyError).
1 parent 54d0f73 commit 4b55c8a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scripts/kill-host-pods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def post_filter_has_known_containers(pod, containers: list) -> bool:
2121
Return true if any of the container IDs on the pod match the list of
2222
containers passed on the second argument.
2323
"""
24-
for container in pod["status"]["containerStatuses"] or []:
24+
for container in pod["status"].get("containerStatuses") or []:
2525
try:
2626
_, container_id = container["containerID"].split("containerd://", 2)
2727
if container_id in containers:

0 commit comments

Comments
 (0)