Merge "Ignore CRD creation errors when ns is terminated"

This commit is contained in:
Zuul 2020-09-02 12:08:45 +00:00 committed by Gerrit Code Review
commit 1b99b1170c
3 changed files with 29 additions and 4 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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 "