diff --git a/octavia/amphorae/backends/health_daemon/health_daemon.py b/octavia/amphorae/backends/health_daemon/health_daemon.py index ec1ed470cc..f4247682af 100644 --- a/octavia/amphorae/backends/health_daemon/health_daemon.py +++ b/octavia/amphorae/backends/health_daemon/health_daemon.py @@ -157,9 +157,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 diff --git a/octavia/tests/unit/amphorae/backends/health_daemon/test_health_daemon.py b/octavia/tests/unit/amphorae/backends/health_daemon/test_health_daemon.py index 6ad8ae0a14..5b81d7716b 100644 --- a/octavia/tests/unit/amphorae/backends/health_daemon/test_health_daemon.py +++ b/octavia/tests/unit/amphorae/backends/health_daemon/test_health_daemon.py @@ -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.' diff --git a/releasenotes/notes/Fix-listener-delete-causing-failover-251efdb79af24c0a.yaml b/releasenotes/notes/Fix-listener-delete-causing-failover-251efdb79af24c0a.yaml new file mode 100644 index 0000000000..60c99fae8f --- /dev/null +++ b/releasenotes/notes/Fix-listener-delete-causing-failover-251efdb79af24c0a.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixed an issue when deleting the last listener from a load balancer may + trigger a failover.