Browse Source

Merge "Skip unscheduled pods when deleting NPs"

changes/19/765319/1
Zuul 2 months ago
committed by Gerrit Code Review
parent
commit
6eedb21426
2 changed files with 9 additions and 1 deletions
  1. +7
    -0
      kuryr_kubernetes/controller/drivers/utils.py
  2. +2
    -1
      kuryr_kubernetes/controller/handlers/kuryrnetworkpolicy.py

+ 7
- 0
kuryr_kubernetes/controller/drivers/utils.py 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.


+ 2
- 1
kuryr_kubernetes/controller/handlers/kuryrnetworkpolicy.py 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:


Loading…
Cancel
Save