From cce348040d43b92b59146adeb15a4f1486946a64 Mon Sep 17 00:00:00 2001 From: Gregory Thiemonge Date: Fri, 1 Sep 2023 11:35:34 -0400 Subject: [PATCH] Fix timeout duration in start_vrrp_service during failovers The timeout_dict argument was not passed to the _populate_amphora_api_version, it could have made the failover of broken amphora really long. Related-Bug: #2033894 Change-Id: I497f2d8587e25eda0d169aa919cb6fbede7e9fc6 --- .../drivers/keepalived/vrrp_rest_driver.py | 3 ++- .../drivers/keepalived/test_vrrp_rest_driver.py | 17 +++++++++++++++++ ...t-dict-when-start-vrrp-278d4837702bd247.yaml | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-timeout-dict-when-start-vrrp-278d4837702bd247.yaml diff --git a/octavia/amphorae/drivers/keepalived/vrrp_rest_driver.py b/octavia/amphorae/drivers/keepalived/vrrp_rest_driver.py index 9680d5ff23..33a2e7bbf8 100644 --- a/octavia/amphorae/drivers/keepalived/vrrp_rest_driver.py +++ b/octavia/amphorae/drivers/keepalived/vrrp_rest_driver.py @@ -88,7 +88,8 @@ class KeepalivedAmphoraDriverMixin(driver_base.VRRPDriverMixin): LOG.info("Start amphora %s VRRP Service.", amphora.id) - self._populate_amphora_api_version(amphora) + self._populate_amphora_api_version(amphora, + timeout_dict=timeout_dict) self.clients[amphora.api_version].start_vrrp(amphora, timeout_dict=timeout_dict) diff --git a/octavia/tests/unit/amphorae/drivers/keepalived/test_vrrp_rest_driver.py b/octavia/tests/unit/amphorae/drivers/keepalived/test_vrrp_rest_driver.py index 940aae5944..fabfbae917 100644 --- a/octavia/tests/unit/amphorae/drivers/keepalived/test_vrrp_rest_driver.py +++ b/octavia/tests/unit/amphorae/drivers/keepalived/test_vrrp_rest_driver.py @@ -107,6 +107,9 @@ class TestVRRPRestDriver(base.TestCase): self.keepalived_mixin.start_vrrp_service(self.amphora_mock) + populate_mock = self.keepalived_mixin._populate_amphora_api_version + populate_mock.assert_called_once_with(self.amphora_mock, + timeout_dict=None) self.clients[API_VERSION].start_vrrp.assert_called_once_with( self.amphora_mock, timeout_dict=None) @@ -121,6 +124,20 @@ class TestVRRPRestDriver(base.TestCase): self.clients[API_VERSION].start_vrrp.assert_not_called() + # With timeout_dict + self.clients[API_VERSION].start_vrrp.reset_mock() + populate_mock.reset_mock() + + timeout_dict = mock.Mock() + self.keepalived_mixin.start_vrrp_service(self.amphora_mock, + timeout_dict=timeout_dict) + + populate_mock = self.keepalived_mixin._populate_amphora_api_version + populate_mock.assert_called_once_with(self.amphora_mock, + timeout_dict=timeout_dict) + self.clients[API_VERSION].start_vrrp.assert_called_once_with( + self.amphora_mock, timeout_dict=timeout_dict) + def test_reload_vrrp_service(self): self.keepalived_mixin.reload_vrrp_service(self.lb_mock) diff --git a/releasenotes/notes/fix-timeout-dict-when-start-vrrp-278d4837702bd247.yaml b/releasenotes/notes/fix-timeout-dict-when-start-vrrp-278d4837702bd247.yaml new file mode 100644 index 0000000000..40d9f9012a --- /dev/null +++ b/releasenotes/notes/fix-timeout-dict-when-start-vrrp-278d4837702bd247.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixed a too long timeout when attempting to start the VRRP service in an + unreachable amphora during a failover. A specific shorter timeout should be + used during the failovers.