Skip to content

Commit

Permalink
fixup! Revert method: Change availability zone back
Browse files Browse the repository at this point in the history
Don't log the current LB's AZ, since that would be one additional DB
query, and the new AZ has already been logged by the execute method.
  • Loading branch information
BenjaminLudwigSAP committed Jan 23, 2025
1 parent 220cc1a commit 8a3397c
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions octavia_f5/api/drivers/f5_driver/tasks/reschedule_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class RewriteLoadBalancerEntry(RescheduleTasks):
def execute(self, load_balancer: models.LoadBalancer, candidate: str, *args, **kwargs):
with db_apis.get_session() as session:

LOG.debug(f"RewriteLoadBalancerEntry.execute: load_balancer.availability_zone == {load_balancer.availability_zone}")

# find out new availability zone
azps, _ = self._azp_repo.get_all(session)
az = None
Expand All @@ -125,14 +127,17 @@ def execute(self, load_balancer: models.LoadBalancer, candidate: str, *args, **k
LOG.debug("RewriteLoadBalancerEntry for LB %s: Changing host from '%s' to '%s' and availability zone from '%s' to '%s'.",
load_balancer.id, load_balancer.server_group_id, candidate, load_balancer.availability_zone, az)
self._loadbalancer_repo.update(session, load_balancer.id, server_group_id=candidate, availability_zone=az)
raise Exception()

def revert(self, result, load_balancer: models.LoadBalancer, candidate: str, removal_host: str, **kwargs):
"""Handle a failure to force adding a loadbalancer."""

if isinstance(result, failure.Failure):
LOG.error("RewriteLoadBalancerEntry: Unable to update loadbalancer %s",
load_balancer.id)
return
LOG.warning("RewriteLoadBalancerEntry: Reverting host change of loadbalancer %s from '%s' to '%s'",
load_balancer.id, candidate, removal_host)
self._loadbalancer_repo.update(db_apis.get_session(), load_balancer.id, server_group_id=removal_host)
#if isinstance(result, failure.Failure):
# LOG.error("RewriteLoadBalancerEntry: Unable to update loadbalancer %s",
# load_balancer.id)
# return

LOG.warning("RewriteLoadBalancerEntry: Reverting host change of loadbalancer %s: Changing host from '%s' to '%s' and availability zone back to '%s'.",
load_balancer.id, candidate, removal_host, load_balancer.availability_zone)
self._loadbalancer_repo.update(db_apis.get_session(), load_balancer.id,
server_group_id=removal_host, availability_zone=load_balancer.availability_zone)

0 comments on commit 8a3397c

Please sign in to comment.