Ensure pool object contains the listener_id if passed

When creating a pool with an associated listener_id, sometimes the
listener_id is not set. Problem comes from [1] not setting the listeners
property on db_pool pool object even if it is passed.

[1] https://github.com/openstack/octavia/blob/master/octavia/api/v2/controllers/pool.py#L244-L245

Story: 2003833
Change-Id: I414a3c6d2e97d30ff12eda4ecf71ec032998df7d
This commit is contained in:
Luis Tomas Bolivar 2018-09-21 18:33:42 +02:00
parent e9bd56f094
commit feff3b472c
1 changed files with 7 additions and 0 deletions

View File

@ -226,6 +226,13 @@ class Repositories(object):
if listener_id:
self.listener.update(session, listener_id,
default_pool_id=pool_dict['id'])
# Immediate refresh, as we have found that sqlalchemy will sometimes
# cache the above query and the pool object may miss the listener_id
# information
if listener_id:
pool = session.query(models.Pool).filter_by(id=db_pool.id).first()
session.refresh(pool)
return self.pool.get(session, id=db_pool.id)
def update_pool_and_sp(self, session, pool_id, pool_dict):