From c63a2cbbadc0db9485843254b90932984e9aa36a Mon Sep 17 00:00:00 2001 From: rabi Date: Fri, 12 Nov 2021 18:51:12 +0530 Subject: [PATCH] Fix Pool resource update for session_persistence Pool session_persistence property should be update allowed. Task: 43952 Change-Id: Idee8893844bfd776a81c9e3ac45aa6804092a440 --- heat/engine/resources/openstack/octavia/pool.py | 10 ++++++++-- heat/tests/openstack/octavia/test_pool.py | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/heat/engine/resources/openstack/octavia/pool.py b/heat/engine/resources/openstack/octavia/pool.py index 6254837369..729af0793f 100644 --- a/heat/engine/resources/openstack/octavia/pool.py +++ b/heat/engine/resources/openstack/octavia/pool.py @@ -87,6 +87,7 @@ class Pool(octavia_base.OctaviaBase): 'required if type is APP_COOKIE.') ) }, + update_allowed=True, ), NAME: properties.Schema( properties.Schema.STRING, @@ -177,12 +178,15 @@ class Pool(octavia_base.OctaviaBase): props['listener_id'] = props.pop(self.LISTENER) if self.LOADBALANCER in props: props['loadbalancer_id'] = props.pop(self.LOADBALANCER) + self._prepare_session_persistence(props) + return props + + def _prepare_session_persistence(self, props): session_p = props.get(self.SESSION_PERSISTENCE) if session_p is not None: session_props = dict( (k, v) for k, v in session_p.items() if v is not None) props[self.SESSION_PERSISTENCE] = session_props - return props def validate(self): super(Pool, self).validate() @@ -215,7 +219,9 @@ class Pool(octavia_base.OctaviaBase): return self.client().pool_create(json={'pool': properties})['pool'] def _resource_update(self, prop_diff): - self.client().pool_set(self.resource_id, json={'pool': prop_diff}) + props = dict((k, v) for k, v in prop_diff.items() if v is not None) + self._prepare_session_persistence(props) + self.client().pool_set(self.resource_id, json={'pool': props}) def _resource_delete(self): self.client().pool_delete(self.resource_id) diff --git a/heat/tests/openstack/octavia/test_pool.py b/heat/tests/openstack/octavia/test_pool.py index 1192d53d76..703c2695d3 100644 --- a/heat/tests/openstack/octavia/test_pool.py +++ b/heat/tests/openstack/octavia/test_pool.py @@ -135,6 +135,7 @@ class PoolTest(common.HeatTestCase): exceptions.Conflict(409), None] prop_diff = { 'admin_state_up': False, + 'session_persistence': {'type': 'source_ip'}, 'name': 'your_pool', 'lb_algorithm': 'SOURCE_IP' }