[API] Fix race in load balancer deletion
A PENDING_DELETE status may not be written to the DB before the gearman thread executes. This means an exception is fired in send_delete(). This patch causes the DB data to be committed before the gearman thread is executed. It also makes sure that the remaining LBs don't include the one getting deleted. Change-Id: I17618af2709535c525ff99bd03958891d61f5624
This commit is contained in:
committed by
David Shrewsbury
parent
1af165fc59
commit
a5d676562e
@@ -573,11 +573,12 @@ class LoadBalancersController(RestController):
|
||||
filter(Node.lbid == lb.id).delete()
|
||||
session.query(HealthMonitor).\
|
||||
filter(HealthMonitor.lbid == lb.id).delete()
|
||||
session.commit()
|
||||
else:
|
||||
session.commit()
|
||||
submit_job(
|
||||
'DELETE', device.name, device.id, lb.id
|
||||
)
|
||||
session.commit()
|
||||
return None
|
||||
|
||||
def usage(self, load_balancer_id):
|
||||
|
||||
@@ -228,6 +228,7 @@ class GearmanClientThread(object):
|
||||
LoadBalancer
|
||||
).join(LoadBalancer.devices).\
|
||||
filter(Device.id == data).\
|
||||
filter(LoadBalancer.id != self.lbid).\
|
||||
filter(LoadBalancer.status != 'DELETED').\
|
||||
filter(LoadBalancer.status != 'PENDING_DELETE').\
|
||||
count()
|
||||
|
||||
Reference in New Issue
Block a user