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).
Story 2007320
Task 38831
Conflicts:
octavia/controller/worker/v1/tasks/database_tasks.py
Change-Id: Ifb6c34426e0927534d332a8bbf2c66aac6c002c5
(cherry picked from commit 3bbd32a2a5
)
This commit is contained in:
parent
a741eb1fbb
commit
0c1cb417e9
@ -522,9 +522,16 @@ class MapLoadbalancerToAmphora(BaseDatabaseTask):
|
|||||||
"allocation.")
|
"allocation.")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
amp = self.amphora_repo.allocate_and_associate(
|
amp = self.amphora_repo.allocate_and_associate(
|
||||||
db_apis.get_session(),
|
db_apis.get_session(),
|
||||||
loadbalancer_id)
|
loadbalancer_id)
|
||||||
|
except Exception as e:
|
||||||
|
LOG.error("Failed to get a spare amphora for "
|
||||||
|
"loadbalancer {} due to: {}".format(
|
||||||
|
loadbalancer_id, e))
|
||||||
|
return None
|
||||||
|
|
||||||
if amp is None:
|
if amp is None:
|
||||||
LOG.debug("No Amphora available for load balancer with id %s",
|
LOG.debug("No Amphora available for load balancer with id %s",
|
||||||
loadbalancer_id)
|
loadbalancer_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user