From 0f9f5bc594b3824142b3ed6c0b6448ef3b2f8e79 Mon Sep 17 00:00:00 2001 From: Yossi Boaron Date: Wed, 23 Jan 2019 18:01:06 +0200 Subject: [PATCH] Handle exception raised in FIP allocation In case an exception is raised in FIP allocation (due to wrong configuration), Kuryr will not annotate LB components and a result of that we'll end up with orphan LB after service deletion. With this patch, Kuryr will log the exception and annotate LB components. Change-Id: Iada0891786883d2348fca52a621bb196a3438df7 Closes-Bug:#1813015 --- kuryr_kubernetes/controller/drivers/lb_public_ip.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kuryr_kubernetes/controller/drivers/lb_public_ip.py b/kuryr_kubernetes/controller/drivers/lb_public_ip.py index 876899faf..6fb24041e 100644 --- a/kuryr_kubernetes/controller/drivers/lb_public_ip.py +++ b/kuryr_kubernetes/controller/drivers/lb_public_ip.py @@ -69,12 +69,15 @@ class FloatingIpServicePubIPDriver(base.ServicePubIpDriver): if not public_network_id: raise cfg.RequiredOptError('external_svc_net', cfg.OptGroup('neutron_defaults')) - - res_id, alloc_ip_addr = ( - self._drv_pub_ip.allocate_ip( + try: + res_id, alloc_ip_addr = (self._drv_pub_ip.allocate_ip( public_network_id, project_id, pub_subnet_id=public_subnet_id, description='kuryr_lb', port_id_to_be_associated=port_id_to_be_associated)) + except Exception: + LOG.exception("Failed to allocate public IP - net_id:%s", + public_network_id) + return None service_pub_ip_info = obj_lbaas.LBaaSPubIp(ip_id=res_id, ip_addr=alloc_ip_addr, alloc_method='pool')