Fix failover when the last listener is deleted

This patch fixes an issue when deleting the last listener from a load balancer
may trigger a failover.

Story: 2010652
Task: 47683
Change-Id: I02804b7075edac72776b0377b7b283d0c7bfd8a2
(cherry picked from commit ba92aeb946)
(cherry picked from commit e7f4b1b4c2)
(cherry picked from commit 658173e5b7)
(cherry picked from commit 4e15e81208)
(cherry picked from commit c58f2cb591)
This commit is contained in:
Michael Johnson
2023-03-17 22:17:05 +00:00
committed by Gregory Thiemonge
parent a1c40d42dd
commit f81563f9ee
3 changed files with 22 additions and 3 deletions

View File

@@ -156,9 +156,15 @@ def run_sender(cmd_queue):
def get_stats(stat_sock_file):
stats_query = haproxy_query.HAProxyQuery(stat_sock_file)
stats = stats_query.show_stat()
pool_status = stats_query.get_pool_status()
try:
stats_query = haproxy_query.HAProxyQuery(stat_sock_file)
stats = stats_query.show_stat()
pool_status = stats_query.get_pool_status()
except Exception as e:
LOG.warning('Unable to query the HAProxy stats (%s) due to: %s',
stat_sock_file, str(e))
# Return empty lists so that the heartbeat will still be sent
return [], {}
return stats, pool_status

View File

@@ -319,6 +319,14 @@ class TestHealthDaemon(base.TestCase):
stats_query_mock.show_stat.assert_called_once_with()
stats_query_mock.get_pool_status.assert_called_once_with()
@mock.patch('octavia.amphorae.backends.utils.haproxy_query.HAProxyQuery')
def test_get_stats_exception(self, mock_query):
mock_query.side_effect = Exception('Boom')
stats, pool_status = health_daemon.get_stats('TEST')
self.assertEqual([], stats)
self.assertEqual({}, pool_status)
@mock.patch('octavia.amphorae.backends.agent.api_server.'
'util.is_lb_running')
@mock.patch('octavia.amphorae.backends.health_daemon.'

View File

@@ -0,0 +1,5 @@
---
fixes:
- |
Fixed an issue when deleting the last listener from a load balancer may
trigger a failover.