Ignore CRD creation errors when ns is terminated
There is a delay between namespace termination and having all the objects from that namespace marked as being terminated. This means that if on CRD creation we'll get a response stating that the namespace is being terminated - we should ignore it, not fail. This commit makes sure we only log a warning for those errors. Change-Id: I87006ffbabea90babd0245753f0d3a0b860b88b5 Closes-Bug: 1893772
This commit is contained in:
parent
75eb6236c6
commit
59651aa66b
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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…
Reference in New Issue