Merge "Skip unscheduled pods when deleting NPs"

This commit is contained in:
Zuul 2020-12-03 09:25:40 +00:00 committed by Gerrit Code Review
commit 6eedb21426
2 changed files with 9 additions and 1 deletions

View File

@ -83,6 +83,13 @@ def is_host_network(pod):
return pod['spec'].get('hostNetwork', False)
def is_pod_scheduled(pod):
try:
return bool(pod['spec']['nodeName'])
except KeyError:
return False
def get_pods(selector, namespace=None):
"""Return a k8s object list with the pods matching the selector.

View File

@ -273,7 +273,8 @@ class KuryrNetworkPolicyHandler(k8s_base.ResourceEventHandler):
if crd_sg:
for pod in pods_to_update:
if driver_utils.is_host_network(pod):
if (driver_utils.is_host_network(pod)
or not driver_utils.is_pod_scheduled(pod)):
continue
pod_sgs = self._drv_pod_sg.get_security_groups(pod, project_id)
if crd_sg in pod_sgs: