From 421b5cd43b52e1fcec0713a9ad29bf9c90b5f45b Mon Sep 17 00:00:00 2001 From: Yoni Shafrir Date: Mon, 26 Jan 2015 09:32:55 +0200 Subject: [PATCH] Allow 'max_l3_agents_per_router' to be set to '0' Currently the field 'max_l3_agents_per_router' from 'neutron.conf' cannot be set to '0' even though the comments and code indicate it is be supported. The value means 'unlimited' agents per router is allowed on HA routers. This issue is a regression that was caused by: 7da314434e445ce3a6f3642c784954ef61154b7f This patch adds a special handling for this value when validating the config. When a value of '0' is used, the further validation of max value is skipped. Change-Id: Iac85768b350ee16c34893218738974a2692202aa Closes-Bug: #1414548 --- neutron/db/l3_hamode_db.py | 8 +++++++- neutron/tests/unit/db/test_l3_ha_db.py | 9 +++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/neutron/db/l3_hamode_db.py b/neutron/db/l3_hamode_db.py index d3215bb47..4ef9f4773 100644 --- a/neutron/db/l3_hamode_db.py +++ b/neutron/db/l3_hamode_db.py @@ -32,6 +32,7 @@ from neutron.openstack.common import log as logging VR_ID_RANGE = set(range(1, 255)) MAX_ALLOCATION_TRIES = 10 +UNLIMITED_AGENTS_PER_ROUTER = 0 LOG = logging.getLogger(__name__) @@ -131,9 +132,14 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin): if ('/' not in self.ha_cidr or net.network != net.ip): raise l3_ha.HANetworkCIDRNotValid(cidr=self.ha_cidr) + self._check_num_agents_per_router() + + def _check_num_agents_per_router(self): max_agents = cfg.CONF.max_l3_agents_per_router min_agents = cfg.CONF.min_l3_agents_per_router - if max_agents < min_agents: + + if (max_agents != UNLIMITED_AGENTS_PER_ROUTER + and max_agents < min_agents): raise l3_ha.HAMaximumAgentsNumberNotValid( max_agents=max_agents, min_agents=min_agents) diff --git a/neutron/tests/unit/db/test_l3_ha_db.py b/neutron/tests/unit/db/test_l3_ha_db.py index c8625c062..692ec5659 100644 --- a/neutron/tests/unit/db/test_l3_ha_db.py +++ b/neutron/tests/unit/db/test_l3_ha_db.py @@ -120,14 +120,19 @@ class L3HATestCase(L3HATestFramework): cfg.CONF.set_override('min_l3_agents_per_router', 0) self.assertRaises( l3_ext_ha_mode.HAMinimumAgentsNumberNotValid, - self.plugin._verify_configuration) + self.plugin._check_num_agents_per_router) def test_verify_configuration_max_l3_agents_below_min_l3_agents(self): cfg.CONF.set_override('max_l3_agents_per_router', 3) cfg.CONF.set_override('min_l3_agents_per_router', 4) self.assertRaises( l3_ext_ha_mode.HAMaximumAgentsNumberNotValid, - self.plugin._verify_configuration) + self.plugin._check_num_agents_per_router) + + def test_verify_configuration_max_l3_agents_unlimited(self): + cfg.CONF.set_override('max_l3_agents_per_router', + l3_hamode_db.UNLIMITED_AGENTS_PER_ROUTER) + self.plugin._check_num_agents_per_router() def test_ha_router_create(self): router = self._create_router() -- 2.45.2