Browse Source

Fix uncaught DB exception when trying to get a spare amphora

The MapLoadbalancerToAmphora task performs some database queries but
doesn't catch any exception from it.

In case something goes wrong with the database or the query, this commit
catchs any exception from the DB call, logs it and then returns None to
switch to the next decider branch (boot a new amphora).

Note: In Queens, string format method in the LOG.error call was changed
to please pep8/pylint.

Story 2007320
Task 38831

Change-Id: Ifb6c34426e0927534d332a8bbf2c66aac6c002c5
(cherry picked from commit 3bbd32a2a5588ab1502efdb6f9556c646d6e8f19)
(cherry picked from commit 0c1cb417e904daa75deedaabc72a20d07b138eb9)
(cherry picked from commit 372e047a840334ea61c23e21f24fb3c9bfbed902)
(cherry picked from commit e7376be7afec98192da969dc9382ad860b1cbe01)
changes/69/709569/2
Gregory Thiemonge 4 months ago
parent
commit
5528268e2f
1 changed files with 10 additions and 3 deletions
  1. +10
    -3
      octavia/controller/worker/tasks/database_tasks.py

+ 10
- 3
octavia/controller/worker/tasks/database_tasks.py View File

@@ -498,9 +498,16 @@ class MapLoadbalancerToAmphora(BaseDatabaseTask):
"pool allocation.")
return None

amp = self.amphora_repo.allocate_and_associate(
db_apis.get_session(),
loadbalancer_id)
try:
amp = self.amphora_repo.allocate_and_associate(
db_apis.get_session(),
loadbalancer_id)
except Exception as e:
LOG.error("Failed to get a spare amphora for "
"loadbalancer %s due to: %s",
loadbalancer_id, e)
return None

if amp is None:
LOG.debug("No Amphora available for load balancer with id %s",
loadbalancer_id)


Loading…
Cancel
Save