Skip to content

Commit

Permalink
Merge pull request #2094 from zhaoqin-github/vlan-9.10.5
Browse files Browse the repository at this point in the history
[OPENSTACK-2867] Fix creating vlan racing problem (9.10.5)
  • Loading branch information
zhaoqin-github authored Aug 25, 2023
2 parents 1db18d9 + 4721eb1 commit e227d1a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
3 changes: 3 additions & 0 deletions docs/RELEASE-NOTES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Bug Fixes
* [OPENSTACK-2847] Retry 401 when initialize bigip connection
* [OPENSTACK-2847] Retry 401 when cleanup partition
* [OPENSTACK-2859] Ignore icontrol 409 by default when creating resource
* [OPENSTACK-2867] Fix creating route domain racing problem
* [OPENSTACK-2867] Needn't to detach redirect policy after removing vs
* [OPENSTACK-2867] Fix creating vlan racing problem

Limitations
```````````
Expand Down
32 changes: 20 additions & 12 deletions f5_openstack_agent/lbaasv2/drivers/bigip/network_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,15 @@ def create_route_domain(self, bigip, rd_id, name,
name += '_aux_' + str(rd_id)
payload = NetworkHelper.route_domain_defaults
payload['name'] = name
payload['partition'] = '/' + partition
payload['partition'] = partition
payload['id'] = rd_id

if strictness:
payload['strict'] = 'enabled'
else:
payload['parent'] = '/' + const.DEFAULT_PARTITION + '/0'
return rd.create(bigip, payload)

rd.create(bigip, payload)

@log_helpers.log_method_call
def delete_route_domain(self, bigip, partition=const.DEFAULT_PARTITION,
Expand Down Expand Up @@ -440,16 +441,24 @@ def create_vlan(self, bigip, model):
if not name:
return None
v = Vlan()
if v.exists(bigip, name=name, partition=partition):
obj = v.load(bigip, name=name, partition=partition)
else:
payload = {'name': name,
'partition': partition,
'tag': tag}

if description:
payload['description'] = description
obj = v.create(bigip, payload)
payload = {'name': name,
'partition': partition,
'tag': tag}

if description:
payload['description'] = description

vlan_exists = False
try:
obj = v.create(bigip, payload, ignore=[])
except HTTPError as ex:
if ex.response.status_code == 409:
vlan_exists = True
else:
raise

if not vlan_exists:
interface = model.get('interface', None)
if interface:
payload = {'name': interface}
Expand All @@ -469,7 +478,6 @@ def create_vlan(self, bigip, model):
if not partition == const.DEFAULT_PARTITION:
self.add_vlan_to_domain_by_id(bigip, name, partition,
route_domain_id)
return obj

@log_helpers.log_method_call
def delete_vlan(
Expand Down
4 changes: 2 additions & 2 deletions f5_openstack_agent/lbaasv2/drivers/bigip/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class BigIPResource(object):
def __init__(self, **kwargs):
pass

def create(self, bigip, model):
return self.helper.create(bigip, model)
def create(self, bigip, model, overwrite=False, ignore=[409]):
return self.helper.create(bigip, model, overwrite, ignore)

def exists(self, bigip, name=None, partition=None):
return self.helper.exists(bigip, name=name, partition=partition)
Expand Down
7 changes: 4 additions & 3 deletions f5_openstack_agent/lbaasv2/drivers/bigip/resource_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,13 +1279,14 @@ def _update_redirect_policy(self, bigip, vs, old_listener, listener):
if old_proto != new_proto or old_port != new_port:
self._create_redirect_policy(bigip, vs, listener)

def _delete_redirect_policy(self, bigip, vs):
def _delete_redirect_policy(self, bigip, vs, detach=True):
policy = LTMPolicyRedirect(
bigip=bigip,
partition=vs['partition'],
vs_name=vs['name']
)
policy.detach_from_vs()
if detach:
policy.detach_from_vs()
policy.delete()

def _get_tcp_options(self, ip_version):
Expand Down Expand Up @@ -1484,7 +1485,7 @@ def _delete(self, bigip, vs, listener, service):
self._delete_persist_profile(bigip, vs)
self._delete_ssl_profiles(bigip, vs, service)
self._delete_extended_profiles(bigip, listener, vs)
self._delete_redirect_policy(bigip, vs)
self._delete_redirect_policy(bigip, vs, detach=False)
ftp_enable = self.ftp_helper.enable_ftp(service)
if ftp_enable:
self.ftp_helper.remove_profile(service, vs, bigip)
Expand Down

0 comments on commit e227d1a

Please sign in to comment.