You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
forcontainerinpod["status"]["containerStatuses"] or []:
It is possible for a pod not to have a containerStatus field, e.g. when it is in "Pending" state because no compatible node is available for it to be scheduled onto. If kill-host-pods.py runs when there are one or more pods in this condition, it fails with the following traceback:
Traceback (most recent call last):
File "/snap/microk8s/6364/scripts/kill-host-pods.py", line 104, in <module>
main()
File "/snap/microk8s/6364/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/snap/microk8s/6364/usr/lib/python3/dist-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/snap/microk8s/6364/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/snap/microk8s/6364/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/snap/microk8s/6364/scripts/kill-host-pods.py", line 88, in main
if not post_filter_has_known_containers(pod, containers):
File "/snap/microk8s/6364/scripts/kill-host-pods.py", line 24, in post_filter_has_known_containers
for container in pod["status"]["containerStatuses"] or []:
KeyError: 'containerStatuses'
Two possible fixes:
use .get instead of []
add another layer of try/except around the whole for loop
The text was updated successfully, but these errors were encountered:
ianroberts
added a commit
to ianroberts/microk8s
that referenced
this issue
Mar 29, 2024
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).
Closescanonical#4471
ianroberts
added a commit
to ianroberts/microk8s
that referenced
this issue
Mar 29, 2024
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).
microk8s/scripts/kill-host-pods.py
Line 24 in f9eb294
It is possible for a pod not to have a
containerStatus
field, e.g. when it is in "Pending" state because no compatible node is available for it to be scheduled onto. Ifkill-host-pods.py
runs when there are one or more pods in this condition, it fails with the following traceback:Two possible fixes:
.get
instead of[]
for
loopThe text was updated successfully, but these errors were encountered: