From 76606b4c4dc9595a015afb4c997f5d02ac7a7343 Mon Sep 17 00:00:00 2001 From: Gregory Thiemonge Date: Sun, 6 Jun 2021 08:00:36 +0200 Subject: [PATCH] Fix using host_routes in VIP subnet with amphorav2 Ensure that amphorae_network_config parameter is not modified in AmphoraPostVIPPlug. Modifying it would break amphorav2 persistence by introducing non-serializable elements in the subnet dict Story: 2008955 Task: 42580 Change-Id: I8f0d3ba1d083c7e37e7e26617826400a538a0890 --- octavia/controller/worker/v2/tasks/amphora_driver_tasks.py | 6 ++++-- .../controller/worker/v2/tasks/test_amphora_driver_tasks.py | 5 +++++ ...tes-with-amphorav2-and-persistence-54b99d651a4ee9c4.yaml | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/fix-host-routes-with-amphorav2-and-persistence-54b99d651a4ee9c4.yaml diff --git a/octavia/controller/worker/v2/tasks/amphora_driver_tasks.py b/octavia/controller/worker/v2/tasks/amphora_driver_tasks.py index bffc022bc6..fdf91d23d1 100644 --- a/octavia/controller/worker/v2/tasks/amphora_driver_tasks.py +++ b/octavia/controller/worker/v2/tasks/amphora_driver_tasks.py @@ -13,6 +13,7 @@ # under the License. # +import copy from cryptography import fernet from oslo_config import cfg from oslo_log import log as logging @@ -334,8 +335,9 @@ class AmphoraPostVIPPlug(BaseAmphoraTask): **amphorae_network_config[ amphora.get(constants.ID)][constants.VRRP_PORT]) # Required for noop-case - vip_arg = amphorae_network_config[amphora.get( - constants.ID)][constants.VIP_SUBNET] + vip_arg = copy.deepcopy( + amphorae_network_config[ + amphora.get(constants.ID)][constants.VIP_SUBNET]) if vip_arg: host_routes = vip_arg.get('host_routes') if host_routes: diff --git a/octavia/tests/unit/controller/worker/v2/tasks/test_amphora_driver_tasks.py b/octavia/tests/unit/controller/worker/v2/tasks/test_amphora_driver_tasks.py index 3e80e3df59..28de5af50e 100644 --- a/octavia/tests/unit/controller/worker/v2/tasks/test_amphora_driver_tasks.py +++ b/octavia/tests/unit/controller/worker/v2/tasks/test_amphora_driver_tasks.py @@ -630,6 +630,11 @@ class TestAmphoraDriverTasks(base.TestCase): self.assertEqual(hr1['destination'], hr2.destination) self.assertEqual(hr1['nexthop'], hr2.nexthop) + self.assertEqual( + host_routes, + amphorae_net_config_mock[AMP_ID][ + constants.VIP_SUBNET]['host_routes']) + @mock.patch('octavia.db.repositories.LoadBalancerRepository.update') @mock.patch('octavia.db.repositories.LoadBalancerRepository.get') def test_amphorae_post_vip_plug(self, mock_lb_get, diff --git a/releasenotes/notes/fix-host-routes-with-amphorav2-and-persistence-54b99d651a4ee9c4.yaml b/releasenotes/notes/fix-host-routes-with-amphorav2-and-persistence-54b99d651a4ee9c4.yaml new file mode 100644 index 0000000000..24a859073e --- /dev/null +++ b/releasenotes/notes/fix-host-routes-with-amphorav2-and-persistence-54b99d651a4ee9c4.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fix a serialization error when using host_routes in VIP subnets when + persistence in the amphorav2 driver is enabled.