]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Allow 'max_l3_agents_per_router' to be set to '0'
authorYoni Shafrir <yshafrir@redhat.com>
Mon, 26 Jan 2015 07:32:55 +0000 (09:32 +0200)
committerYoni Shafrir <yshafrir@redhat.com>
Wed, 28 Jan 2015 07:09:24 +0000 (09:09 +0200)
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
neutron/tests/unit/db/test_l3_ha_db.py

index d3215bb47c02773882633663127d8e6d65239baf..4ef9f4773618fa2425dafe61b535efb22c1a2ce8 100644 (file)
@@ -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)
 
index c8625c06232db2ef64699168d9b1e8ba74518dfc..692ec5659ce840732fc2914eb992db6c0dc5dfc2 100644 (file)
@@ -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()