Merge "Skip unscheduled pods when deleting NPs"
This commit is contained in:
commit
6eedb21426
|
@ -83,6 +83,13 @@ def is_host_network(pod):
|
||||||
return pod['spec'].get('hostNetwork', False)
|
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):
|
def get_pods(selector, namespace=None):
|
||||||
"""Return a k8s object list with the pods matching the selector.
|
"""Return a k8s object list with the pods matching the selector.
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,8 @@ class KuryrNetworkPolicyHandler(k8s_base.ResourceEventHandler):
|
||||||
|
|
||||||
if crd_sg:
|
if crd_sg:
|
||||||
for pod in pods_to_update:
|
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
|
continue
|
||||||
pod_sgs = self._drv_pod_sg.get_security_groups(pod, project_id)
|
pod_sgs = self._drv_pod_sg.get_security_groups(pod, project_id)
|
||||||
if crd_sg in pod_sgs:
|
if crd_sg in pod_sgs:
|
||||||
|
|
Loading…
Reference in New Issue