Browse Source

Avoid _get_pods_ips KeyError exception

This patch ensures that _get_pods_ips function doesn't fail when a
Network Policy is pointing to pods that have not yet received their
IP

Change-Id: I147c69e86f8b7608ecfda0f3241ff8b35ec42b90
Closes-Bug: 1816385
Luis Tomas Bolivar 2 months ago
parent
commit
dc9e39b16e
1 changed files with 1 additions and 1 deletions
  1. 1
    1
      kuryr_kubernetes/controller/drivers/network_policy.py

+ 1
- 1
kuryr_kubernetes/controller/drivers/network_policy.py View File

@@ -216,7 +216,7 @@ class NetworkPolicyDriver(base.NetworkPolicyDriver):
216 216
         else:
217 217
             matching_pods = driver_utils.get_pods(pod_selector, namespace)
218 218
         for pod in matching_pods.get('items'):
219
-            if pod['status']['podIP']:
219
+            if pod['status'].get('podIP'):
220 220
                 pod_ip = pod['status']['podIP']
221 221
                 ns = pod['metadata']['namespace']
222 222
                 ips.append({'cidr': pod_ip, 'namespace': ns})

Loading…
Cancel
Save