Browse Source

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
(cherry picked from commit 0f7d03feca4e3a4796c9c1a5a55d8da2adc44ebd)
changes/56/714856/1
Ann Kamyshnikova 4 months ago
committed by Ann Taraday
parent
commit
a0f75b10ed
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      octavia/db/repositories.py

+ 3
- 1
octavia/db/repositories.py View File

@@ -29,6 +29,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
@@ -1398,7 +1399,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…
Cancel
Save