Skip to content

Commit

Permalink
OPENSTACK-2799: fix to delete pool
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zhang-shengping committed Jun 19, 2023
1 parent e3126b3 commit d7efa2b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
5 changes: 4 additions & 1 deletion f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import json
import os

from requests import HTTPError
from time import strftime

from oslo_config import cfg
Expand Down Expand Up @@ -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."""
Expand Down
12 changes: 7 additions & 5 deletions f5_openstack_agent/lbaasv2/drivers/bigip/network_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
Expand Down
21 changes: 17 additions & 4 deletions f5_openstack_agent/lbaasv2/drivers/bigip/resource_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit d7efa2b

Please sign in to comment.