Pick stale amphora randomly
Avoid getting the same amphora all the time if its loadbalancer stuck in PENDING state and could not be failovered. Story: 2007340 Task: 38877 Change-Id: I2f680a00be695c3828166e6803882765af79b79e
This commit is contained in:
parent
801b99ed00
commit
0f7d03feca
@ -30,6 +30,7 @@ from oslo_utils import uuidutils
|
||||
from sqlalchemy.orm import joinedload
|
||||
from sqlalchemy.orm import noload
|
||||
from sqlalchemy.orm import subqueryload
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
from octavia.common import constants as consts
|
||||
from octavia.common import data_models
|
||||
@ -1521,7 +1522,8 @@ class AmphoraHealthRepository(BaseRepository):
|
||||
|
||||
amp = session.query(self.model_class).with_for_update().filter_by(
|
||||
busy=False).filter(
|
||||
self.model_class.last_update < expired_time).first()
|
||||
self.model_class.last_update < expired_time).order_by(
|
||||
func.random()).first()
|
||||
|
||||
if amp is None:
|
||||
return None
|
||||
|
Loading…
x
Reference in New Issue
Block a user