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
This commit is contained in:
Christian Rohmann 2024-02-08 15:27:18 +01:00
parent a097f363d1
commit fa28c3c35c
2 changed files with 2 additions and 6 deletions

View File

@ -14,8 +14,6 @@ from neutron_lib.db import api as db_api
from neutron_lib.objects import common_types from neutron_lib.objects import common_types
from oslo_versionedobjects import fields as obj_fields from oslo_versionedobjects import fields as obj_fields
from sqlalchemy import sql
from neutron.common import _constants as n_const from neutron.common import _constants as n_const
from neutron.db.models import agent as agent_model from neutron.db.models import agent as agent_model
from neutron.db.models import l3_attrs from neutron.db.models import l3_attrs
@ -59,9 +57,7 @@ class RouterL3AgentBinding(base.NeutronDbObject):
agent_model.Agent.admin_state_up).outerjoin( agent_model.Agent.admin_state_up).outerjoin(
l3_attrs.RouterExtraAttributes, l3_attrs.RouterExtraAttributes,
l3_attrs.RouterExtraAttributes.router_id == l3_attrs.RouterExtraAttributes.router_id ==
l3agent.RouterL3AgentBinding.router_id).filter( l3agent.RouterL3AgentBinding.router_id))
l3_attrs.RouterExtraAttributes.ha.in_(
[sql.false(), sql.null()])))
bindings = [cls._load_object(context, db_obj) for db_obj in bindings = [cls._load_object(context, db_obj) for db_obj in
query.all()] query.all()]
return bindings return bindings

View File

@ -1718,7 +1718,7 @@ class L3AgentSchedulerDbMixinTestCase(L3HATestCaseMixin):
self._set_l3_agent_dead(self.agent_id1) self._set_l3_agent_dead(self.agent_id1)
with mock.patch.object(self.plugin, 'reschedule_router') as reschedule: with mock.patch.object(self.plugin, 'reschedule_router') as reschedule:
self.plugin.reschedule_routers_from_down_agents() self.plugin.reschedule_routers_from_down_agents()
self.assertFalse(reschedule.called) self.assertTrue(reschedule.called)
def test_list_l3_agents_hosting_ha_router(self): def test_list_l3_agents_hosting_ha_router(self):
router = self._create_ha_router() router = self._create_ha_router()