Browse Source

Merge "Ignore CRD creation errors when ns is terminated"

changes/69/749769/1
Zuul 11 months ago
committed by Gerrit Code Review
parent
commit
1b99b1170c
  1. 9
      kuryr_kubernetes/controller/drivers/network_policy.py
  2. 20
      kuryr_kubernetes/controller/handlers/lbaas.py
  3. 4
      kuryr_kubernetes/controller/handlers/vif.py

9
kuryr_kubernetes/controller/drivers/network_policy.py

@ -52,7 +52,14 @@ class NetworkPolicyDriver(base.NetworkPolicyDriver):
knp = self._get_knp_crd(policy)
if not knp:
self._create_knp_crd(policy, i_rules, e_rules)
try:
self._create_knp_crd(policy, i_rules, e_rules)
except exceptions.K8sNamespaceTerminating:
LOG.warning('Namespace %s is being terminated, ignoring '
'NetworkPolicy %s in that namespace.',
policy['metadata']['namespace'],
policy['metadata']['name'])
return
else:
self._patch_knp_crd(policy, i_rules, e_rules, knp)

20
kuryr_kubernetes/controller/handlers/lbaas.py

@ -62,9 +62,16 @@ class ServiceHandler(k8s_base.ResourceEventHandler):
raise
if loadbalancer_crd is None:
loadbalancer_crd = self.create_crd_spec(service)
try:
self.create_crd_spec(service)
except k_exc.K8sNamespaceTerminating:
LOG.warning('Namespace %s is being terminated, ignoring '
'Service %s in that namespace.',
service['metadata']['namespace'],
service['metadata']['name'])
return
elif self._has_lbaas_spec_changes(service, loadbalancer_crd):
loadbalancer_crd = self._update_crd_spec(loadbalancer_crd, service)
self._update_crd_spec(loadbalancer_crd, service)
def _is_supported_type(self, service):
spec = service['spec']
@ -281,7 +288,14 @@ class EndpointsHandler(k8s_base.ResourceEventHandler):
return
if loadbalancer_crd is None:
self._create_crd_spec(endpoints)
try:
self._create_crd_spec(endpoints)
except k_exc.K8sNamespaceTerminating:
LOG.warning('Namespace %s is being terminated, ignoring '
'Endpoints %s in that namespace.',
endpoints['metadata']['namespace'],
endpoints['metadata']['name'])
return
else:
self._update_crd_spec(loadbalancer_crd, endpoints)

4
kuryr_kubernetes/controller/handlers/vif.py

@ -97,6 +97,10 @@ class VIFHandler(k8s_base.ResourceEventHandler):
except k_exc.K8sNamespaceTerminating:
# The underlying namespace is being terminated, we can
# ignore this and let `on_finalize` handle this now.
LOG.warning('Namespace %s is being terminated, ignoring Pod '
'%s in that namespace.',
pod['metadata']['namespace'],
pod['metadata']['name'])
return
except k_exc.K8sClientException as ex:
LOG.exception("Kubernetes Client Exception creating "

Loading…
Cancel
Save