From 729c3a67679e4ff17952cf62d39192532b0fbb72 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Thu, 29 Nov 2018 04:17:04 -0500 Subject: [PATCH] Fix error where pod has error and no containers (#49154) k8s: Fix error where pod has error and no containers --- lib/ansible/plugins/inventory/k8s.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ansible/plugins/inventory/k8s.py b/lib/ansible/plugins/inventory/k8s.py index 65598b31211..b57adee2df6 100644 --- a/lib/ansible/plugins/inventory/k8s.py +++ b/lib/ansible/plugins/inventory/k8s.py @@ -236,6 +236,9 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable, K8sAnsibleM else: pod_labels = {} + if not pod.status.containerStatuses: + continue + for container in pod.status.containerStatuses: # add each pod_container to the namespace group, and to each label_value group container_name = '{0}_{1}'.format(pod.metadata.name, container.name)