From e3126b34a13910525d9e3feb9135a3dde0fae775 Mon Sep 17 00:00:00 2001 From: Pzhang Date: Tue, 13 Jun 2023 17:19:05 +0800 Subject: [PATCH 1/2] OPENSTACK-2799: fix to delete monitor if pool nonexists, the pool update method will create a new pool. check if pool exist, before delete monitor. if the pool exists, we delete monitor directly. --- .../lbaasv2/drivers/bigip/resource_manager.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/f5_openstack_agent/lbaasv2/drivers/bigip/resource_manager.py b/f5_openstack_agent/lbaasv2/drivers/bigip/resource_manager.py index ae1963911..1275dc493 100644 --- a/f5_openstack_agent/lbaasv2/drivers/bigip/resource_manager.py +++ b/f5_openstack_agent/lbaasv2/drivers/bigip/resource_manager.py @@ -1730,8 +1730,16 @@ def _delete(self, bigip, payload, healthmonitor, service): ) pool_payload['monitor'] = '' try: - # update the pool - mgr._update(bigip, pool_payload, None, None, service) + # check if pool exist, if not exist, + # we delete healthmonitor directly + exist = mgr.resource_helper.exists( + bigip, + name=pool_payload['name'], + partition=pool_payload['partition'] + ) + if exist: + # update the pool + mgr._update(bigip, pool_payload, None, None, service) super(MonitorManager, self)._delete( bigip, payload, healthmonitor, service From d7efa2b60770489f2a3f6131f21a4466d230dc4d Mon Sep 17 00:00:00 2001 From: Pzhang Date: Wed, 14 Jun 2023 14:52:04 +0800 Subject: [PATCH 2/2] OPENSTACK-2799: fix to delete pool if bigip partition is missing, we can not delete pool in neutron db. it is because pool has relationship with pool member and listener. when the partition is missing, member can not update(create if missing) allocate route domain in the misssing partition. when the partition is missing, listener can not update(create if missing) in the missing partition. --- .../lbaasv2/drivers/bigip/icontrol_driver.py | 5 ++++- .../lbaasv2/drivers/bigip/network_service.py | 12 ++++++----- .../lbaasv2/drivers/bigip/resource_manager.py | 21 +++++++++++++++---- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py b/f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py index e36e43daf..ea8f9d060 100644 --- a/f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py +++ b/f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py @@ -17,6 +17,7 @@ import json import os +from requests import HTTPError from time import strftime from oslo_config import cfg @@ -835,10 +836,12 @@ def annotate_service_members(self, service): self.network_builder._annotate_service_route_domains(service) except f5ex.InvalidNetworkType as exc: LOG.warning(exc.message) + except HTTPError as err: + raise err except Exception as err: LOG.exception(err) raise f5ex.RouteDomainCreationException( - "Route domain annotation error") + "Service Member Route domain annotation error") def update_service_status(self, service, timed_out=False): """Update status of objects in controller.""" diff --git a/f5_openstack_agent/lbaasv2/drivers/bigip/network_service.py b/f5_openstack_agent/lbaasv2/drivers/bigip/network_service.py index 3e6396bd4..5eb23a4ae 100644 --- a/f5_openstack_agent/lbaasv2/drivers/bigip/network_service.py +++ b/f5_openstack_agent/lbaasv2/drivers/bigip/network_service.py @@ -396,7 +396,6 @@ def create_rd_by_net( exists = self.network_helper.route_domain_exists( bigip, partition=partition, name=name ) - if exists: LOG.info("route domain: %s, %s exists on bigip: %s" % (name, route_domain, bigip.hostname)) @@ -411,13 +410,16 @@ def create_rd_by_net( LOG.info("create route domain: %s, %s on bigip: %s" % (name, route_domain, bigip.hostname)) - except Exception as ex: - if ex.response.status_code == 409: + except HTTPError as err: + if err.response.status_code == 409: LOG.info("route domain %s already exists: %s, ignored.." % ( - route_domain, ex.message)) + route_domain, err.message)) + elif err.response.status_code == 400: + LOG.info("maybe partition is misssing, dirty data.") + raise err else: # FIXME(pzhang): what to do with multiple agent race? - LOG.error(ex.message) + LOG.error(err.message) raise f5_ex.RouteDomainCreationException( "Failed to create route domain: %s, %s on bigip %s" % (name, route_domain, bigip.hostname) diff --git a/f5_openstack_agent/lbaasv2/drivers/bigip/resource_manager.py b/f5_openstack_agent/lbaasv2/drivers/bigip/resource_manager.py index 1275dc493..d444b1d07 100644 --- a/f5_openstack_agent/lbaasv2/drivers/bigip/resource_manager.py +++ b/f5_openstack_agent/lbaasv2/drivers/bigip/resource_manager.py @@ -1612,6 +1612,13 @@ def _delete(self, bigip, payload, pool, service): service['listener'] = listener """ Unmap listener and pool""" vs = self.driver.service_adapter.get_virtual_name(service) + vs_exist = mgr.resource_helper.exists( + bigip, name=vs['name'], + partition=vs['partition'] + ) + if not vs_exist: + continue + vs['pool'] = "" # Need to remove persist profile from virtual server, # if its persist profile is configured by its default pool. @@ -1641,7 +1648,13 @@ def update(self, old_pool, pool, service, **kwargs): @serialized('PoolManager.delete') @log_helpers.log_method_call def delete(self, pool, service, **kwargs): - self.driver.annotate_service_members(service) + try: + self.driver.annotate_service_members(service) + except HTTPError as err: + if err.response.status_code == 400: + LOG.debug(err) + else: + raise err super(PoolManager, self).delete(pool, service) @@ -1730,11 +1743,11 @@ def _delete(self, bigip, payload, healthmonitor, service): ) pool_payload['monitor'] = '' try: - # check if pool exist, if not exist, + # check if pool exist, if not exist, # we delete healthmonitor directly exist = mgr.resource_helper.exists( - bigip, - name=pool_payload['name'], + bigip, + name=pool_payload['name'], partition=pool_payload['partition'] ) if exist: