Skip to content

Commit

Permalink
Fix: Removal tasks' revert methods assume that removal worked
Browse files Browse the repository at this point in the history
RemoveSelfIP.revert and RemoveSubnetRoute.revert assume that the
SelfIP/subnet route was successfully removed. So restoring can fail
and cause another exception due to HTTP 409 CONFLICT.

Check whether the SelfIP/subnet route was actually deleted before
attempting to restore.
  • Loading branch information
BenjaminLudwigSAP committed Jul 3, 2024
1 parent d34c99b commit 040887b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions octavia_f5/controller/worker/tasks/f5_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,12 @@ def revert(self, bigip: bigip_restclient.BigIPRestClient,
f"was run: {subnet_route_name}")
return

# don't restore subnet route if it wasn't removed
res = bigip.get(path=f"/mgmt/tm/net/route/~Common~{subnet_route_name}")
if res.status_code != 404:
LOG.warning(f"Reverting RemoveSubnetRoute: Subnet route {subnet_route_name} was not removed, no need to restore")
return

# restore subnet route
payload = {'name': subnet_route_name,
'tmInterface': subnet_route['tmInterface'],
Expand Down Expand Up @@ -468,6 +474,12 @@ def revert(self, bigip: bigip_restclient.BigIPRestClient,
f"was run: {selfip['name']}")
return

# don't restore SelfIP if it wasn't removed
res = bigip.get(path=f"/mgmt/tm/net/self/{selfip['port_id']}")
if res.status_code != 404:
LOG.warning(f"Reverting RemoveSelfIP: SelfIP {selfip['name']} was not removed, no need to restore")
return

# restore SelfIP
payload = {'name': selfip['name'], 'vlan': selfip['vlan'], 'address': selfip['address']}
LOG.warning(f"Reverting RemoveSelfIP: Restoring SelfIP: {selfip['name']}")
Expand Down

0 comments on commit 040887b

Please sign in to comment.