From fe771a456d81b6600457b78210e21b88a3a9d83e Mon Sep 17 00:00:00 2001 From: archiephan Date: Wed, 22 Apr 2020 17:59:20 +0700 Subject: [PATCH] Fix healthmanager not update amphora health when LB disable When disable a loadbalancer have listener, the Heath Manager not update amphora heath make it keep failover after heartbeat_timeout end time Story: 2007587 Task: 39521 Change-Id: Ia6d3f40ae1b9b352492162513c9262748ee67e6f --- .../healthmanager/health_drivers/update_db.py | 3 ++- .../health_drivers/test_update_db.py | 22 +++++++++++++++++-- ...lth-when-LB-disabled-46a4fb295c6d0850.yaml | 6 +++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/Fix-healthmanager-not-update-amphora-health-when-LB-disabled-46a4fb295c6d0850.yaml diff --git a/octavia/controller/healthmanager/health_drivers/update_db.py b/octavia/controller/healthmanager/health_drivers/update_db.py index 39cad47e94..c9e4659ece 100644 --- a/octavia/controller/healthmanager/health_drivers/update_db.py +++ b/octavia/controller/healthmanager/health_drivers/update_db.py @@ -162,7 +162,8 @@ class UpdateHealthDb(update_base.HealthUpdateBase): if db_lb: expected_listener_count = 0 - if 'PENDING' in db_lb['provisioning_status']: + if ('PENDING' in db_lb['provisioning_status'] or + not db_lb['enabled']): ignore_listener_count = True else: for key, listener in db_lb.get('listeners', {}).items(): diff --git a/octavia/tests/unit/controller/healthmanager/health_drivers/test_update_db.py b/octavia/tests/unit/controller/healthmanager/health_drivers/test_update_db.py index b9f3c6117d..27cef11542 100644 --- a/octavia/tests/unit/controller/healthmanager/health_drivers/test_update_db.py +++ b/octavia/tests/unit/controller/healthmanager/health_drivers/test_update_db.py @@ -110,9 +110,10 @@ class TestUpdateHealthDb(base.TestCase): def _make_fake_lb_health_dict(self, listener=True, pool=True, health_monitor=True, members=1, lb_prov_status=constants.ACTIVE, - listener_protocol=constants.PROTOCOL_TCP): + listener_protocol=constants.PROTOCOL_TCP, + enabled=True): - lb_ref = {'enabled': True, 'id': self.FAKE_UUID_1, + lb_ref = {'enabled': enabled, 'id': self.FAKE_UUID_1, constants.OPERATING_STATUS: 'bogus', constants.PROVISIONING_STATUS: lb_prov_status} @@ -158,6 +159,23 @@ class TestUpdateHealthDb(base.TestCase): self.assertTrue(self.loadbalancer_repo.update.called) self.assertTrue(self.amphora_health_repo.replace.called) + def test_update_health_lb_disabled(self): + + health = { + "id": self.FAKE_UUID_1, + "ver": 1, + "listeners": {}, + "recv_time": time.time() + } + + lb_ref = self._make_fake_lb_health_dict( + listener=True, pool=True, enabled=False) + self.hm.amphora_repo.get_lb_for_health_update.return_value = lb_ref + self.hm.update_health(health, '192.0.2.1') + self.assertTrue(self.amphora_repo.get_lb_for_health_update.called) + self.assertTrue(self.loadbalancer_repo.update.called) + self.assertTrue(self.amphora_health_repo.replace.called) + def test_update_health_lb_pending_no_listener(self): health = { diff --git a/releasenotes/notes/Fix-healthmanager-not-update-amphora-health-when-LB-disabled-46a4fb295c6d0850.yaml b/releasenotes/notes/Fix-healthmanager-not-update-amphora-health-when-LB-disabled-46a4fb295c6d0850.yaml new file mode 100644 index 0000000000..7266316b84 --- /dev/null +++ b/releasenotes/notes/Fix-healthmanager-not-update-amphora-health-when-LB-disabled-46a4fb295c6d0850.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixed an issue when a loadbalancer is disabled, Octavia Health Manager + keeps failovering the amphorae +