From fa28c3c35cc7ae5b25441d3d83bf78f00a54f477 Mon Sep 17 00:00:00 2001 From: Christian Rohmann Date: Thu, 8 Feb 2024 15:27:18 +0100 Subject: [PATCH] Allow HA routers to have automatic l3agent failover Currently routers with ha=true are NOT rescheduled form a dead L3 agent, even when `allow_automatic_l3agent_failover` is enabled. This is contrary to what the user expects and the feature description states: "Automatically reschedule routers from offline L3 agents to online L3 agents." There is no distinction made between HA and non-HA routers. Also HA and automatic-failover can work together: * HA allows for a fast failover to a standby router * Automatic failover then restores back full redundancy in case the failed L3 agent, which HA failed away from, does not come back within a certain time. Closes-Bug: #2050236 Change-Id: I1e5ee5048f61eef7fa4d9de25e69bf0e0a5ea442 --- neutron/objects/l3agent.py | 6 +----- neutron/tests/unit/scheduler/test_l3_agent_scheduler.py | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/neutron/objects/l3agent.py b/neutron/objects/l3agent.py index 51cc70a318e..c25f40b6df8 100644 --- a/neutron/objects/l3agent.py +++ b/neutron/objects/l3agent.py @@ -14,8 +14,6 @@ from neutron_lib.db import api as db_api from neutron_lib.objects import common_types from oslo_versionedobjects import fields as obj_fields -from sqlalchemy import sql - from neutron.common import _constants as n_const from neutron.db.models import agent as agent_model from neutron.db.models import l3_attrs @@ -59,9 +57,7 @@ class RouterL3AgentBinding(base.NeutronDbObject): agent_model.Agent.admin_state_up).outerjoin( l3_attrs.RouterExtraAttributes, l3_attrs.RouterExtraAttributes.router_id == - l3agent.RouterL3AgentBinding.router_id).filter( - l3_attrs.RouterExtraAttributes.ha.in_( - [sql.false(), sql.null()]))) + l3agent.RouterL3AgentBinding.router_id)) bindings = [cls._load_object(context, db_obj) for db_obj in query.all()] return bindings diff --git a/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py b/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py index 046825d3c30..7dcab0e038f 100644 --- a/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py +++ b/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py @@ -1718,7 +1718,7 @@ class L3AgentSchedulerDbMixinTestCase(L3HATestCaseMixin): self._set_l3_agent_dead(self.agent_id1) with mock.patch.object(self.plugin, 'reschedule_router') as reschedule: self.plugin.reschedule_routers_from_down_agents() - self.assertFalse(reschedule.called) + self.assertTrue(reschedule.called) def test_list_l3_agents_hosting_ha_router(self): router = self._create_ha_router()