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:
@@ -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.")
- 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.")
+ 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)
def on_deleted(self, namespace, net_crd=None):
LOG.debug("Deleting namespace: %s", namespace)
