Delete Kuryr Net CRD in case of k8s exception

When a kubernetes exception is raised on namespace creation
we are deleting the neutron resources, but not the Kuryr Net
CRD. This commit adds the deletion of the leftover CRD.


Closes-Bug: 1836395

Change-Id: I68ea4fc35169cda93e27fac5db268563da352846
This commit is contained in:
Maysa Macedo 2019-07-12 16:13:29 +00:00 committed by Maysa de Macedo Souza
parent 135b4ea393
commit 67954fad19
1 changed files with 3 additions and 8 deletions

View File

@ -107,17 +107,12 @@ class NamespaceHandler(k8s_base.ResourceEventHandler):
self._set_net_crd(namespace, net_crd)
self._drv_sg.create_namespace_sg_rules(namespace)
self._set_namespace_labels(namespace, current_namespace_labels)
except exceptions.K8sResourceNotFound:
LOG.debug("Namespace could not be annotated. Rolling back "
"resources created for it.")
except exceptions.K8sClientException:
LOG.exception("Kubernetes client exception. Rolling back "
"resources created for the namespace.")
self._drv_subnets.rollback_network_resources(net_crd_spec, ns_name)
self._drv_sg.delete_sg(net_crd_sg['sgId'])
self._del_kuryrnet_crd(net_crd_name)
except exceptions.K8sClientException:
LOG.exception("Kuryrnet CRD could not be added. Rolling back "
"network resources created for the namespace.")
self._drv_subnets.rollback_network_resources(net_crd_spec, ns_name)
self._drv_sg.delete_sg(net_crd_sg['sgId'])
def on_deleted(self, namespace, net_crd=None):
LOG.debug("Deleting namespace: %s", namespace)