From feff3b472c7902af3ccb4cc10f1e2ae140d66b32 Mon Sep 17 00:00:00 2001 From: Luis Tomas Bolivar Date: Fri, 21 Sep 2018 18:33:42 +0200 Subject: [PATCH] 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 --- octavia/db/repositories.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/octavia/db/repositories.py b/octavia/db/repositories.py index 7494d4e41d..5e344ad04a 100644 --- a/octavia/db/repositories.py +++ b/octavia/db/repositories.py @@ -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):