Remove deprecated min_l3_agents_per_router

The option was deprecated [1] for removal in Newton
and is being removed in Ocata.

[1] Deprecated in patch with Gerrit Change-Id of:
    I8a5fc74a96c784d474aefe2d9b27eeb66521ca82

DocImpact remove all references to the option.

Change-Id: I3a9195ff6fd18fad9f85cec03a632e7e52d954e7
Closes-Bug: #1555042
This commit is contained in:
Assaf Muller 2016-10-12 15:32:45 -04:00
parent 1a528e817f
commit dd5aca38f9
8 changed files with 20 additions and 130 deletions

View File

@ -31,8 +31,6 @@ SNAT_ROUTER_INTF_KEY = '_snat_router_interfaces'
HA_NETWORK_NAME = 'HA network tenant %s'
HA_SUBNET_NAME = 'HA subnet tenant %s'
HA_PORT_NAME = 'HA port tenant %s'
MINIMUM_MINIMUM_AGENTS_FOR_HA = 1
DEFAULT_MINIMUM_AGENTS_FOR_HA = 2
HA_ROUTER_STATE_ACTIVE = 'active'
HA_ROUTER_STATE_STANDBY = 'standby'

View File

@ -72,15 +72,6 @@ L3_HA_OPTS = [
help=_("Maximum number of L3 agents which a HA router will be "
"scheduled on. If it is set to 0 then the router will "
"be scheduled on every agent.")),
cfg.IntOpt('min_l3_agents_per_router',
default=n_const.DEFAULT_MINIMUM_AGENTS_FOR_HA,
help=_("DEPRECATED: Minimum number of L3 agents that have to "
"be available in order to allow a new HA router to be "
"scheduled. This option is deprecated in the Newton "
"release and will be removed for the Ocata release "
"where the scheduling of new HA routers will always "
"be allowed."),
deprecated_for_removal=True),
cfg.StrOpt('l3_ha_net_cidr',
default=n_const.L3_HA_NET_CIDR,
help=_('Subnet used for the l3 HA admin network.')),
@ -114,15 +105,9 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
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 != UNLIMITED_AGENTS_PER_ROUTER
and max_agents < min_agents):
raise l3_ha.HAMaximumAgentsNumberNotValid(
max_agents=max_agents, min_agents=min_agents)
if min_agents < n_const.MINIMUM_MINIMUM_AGENTS_FOR_HA:
raise l3_ha.HAMinimumAgentsNumberNotValid()
if max_agents != UNLIMITED_AGENTS_PER_ROUTER and max_agents < 1:
raise l3_ha.HAMaximumAgentsNumberNotValid(max_agents=max_agents)
def __new__(cls, *args, **kwargs):
inst = super(L3_HA_NAT_db_mixin, cls).__new__(cls, *args, **kwargs)
@ -273,14 +258,8 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
return ha_network
def get_number_of_agents_for_scheduling(self, context):
"""Return the number of agents on which the router will be scheduled.
"""Return number of agents on which the router will be scheduled."""
Raises an exception if there are not enough agents available to honor
the min_agents config parameter. If the max_agents parameter is set to
0 all the agents will be used.
"""
min_agents = cfg.CONF.min_l3_agents_per_router
num_agents = len(self.get_l3_agents(context, active=True,
filters={'agent_modes': [constants.L3_AGENT_MODE_LEGACY,
constants.L3_AGENT_MODE_DVR_SNAT]}))
@ -293,10 +272,6 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
else:
num_agents = max_agents
if num_agents < min_agents:
raise l3_ha.HANotEnoughAvailableAgents(min_agents=min_agents,
num_agents=num_agents)
return num_agents
@db_api.retry_if_session_inactive()
@ -475,11 +450,6 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
'set router admin_state_up to False prior to upgrade.')
raise n_exc.BadRequest(resource='router', msg=msg)
if requested_ha_state:
# This will throw HANotEnoughAvailableAgents if there aren't
# enough l3 agents to handle this router.
self.get_number_of_agents_for_scheduling(context)
with context.session.begin(subtransactions=True):
router_db = super(L3_HA_NAT_db_mixin, self)._update_router_db(
context, router_id, data)

View File

@ -18,7 +18,6 @@ from neutron_lib import constants
from neutron_lib import exceptions
from neutron._i18n import _
from neutron.common import constants as n_const
HA_INFO = 'ha'
EXTENDED_ATTRIBUTES_2_0 = {
@ -76,21 +75,10 @@ class HANetworkCIDRNotValid(exceptions.NeutronException):
"isn't valid; %(cidr)s.")
class HANotEnoughAvailableAgents(exceptions.NeutronException):
message = _("Not enough l3 agents available to ensure HA. Minimum "
"required %(min_agents)s, available %(num_agents)s.")
class HAMaximumAgentsNumberNotValid(exceptions.NeutronException):
message = _("max_l3_agents_per_router %(max_agents)s config parameter "
"is not valid. It has to be greater than or equal to "
"min_l3_agents_per_router %(min_agents)s.")
class HAMinimumAgentsNumberNotValid(exceptions.NeutronException):
message = (_("min_l3_agents_per_router config parameter is not valid. "
"It has to be greater than or equal to %s for HA.") %
n_const.MINIMUM_MINIMUM_AGENTS_FOR_HA)
"is not valid as it cannot be negative. It must be 1 or "
"greater. Alternatively, it can be 0 to mean unlimited.")
class L3_ext_ha_mode(extensions.ExtensionDescriptor):

View File

@ -26,7 +26,7 @@ from oslo_log import log as logging
import six
from sqlalchemy import sql
from neutron._i18n import _LE, _LW
from neutron._i18n import _LW
from neutron.common import utils
from neutron.db import api as db_api
from neutron.db import l3_hamode_db
@ -44,7 +44,6 @@ cfg.CONF.register_opts(l3_hamode_db.L3_HA_OPTS)
class L3Scheduler(object):
def __init__(self):
self.min_ha_agents = cfg.CONF.min_l3_agents_per_router
self.max_ha_agents = cfg.CONF.max_l3_agents_per_router
@abc.abstractmethod
@ -299,13 +298,6 @@ class L3Scheduler(object):
return (min(self.max_ha_agents, candidates_count) if self.max_ha_agents
else candidates_count)
def _enough_candidates_for_ha(self, candidates):
if not candidates or len(candidates) < self.min_ha_agents:
LOG.error(_LE("Not enough candidates, a HA router needs at least "
"%s agents"), self.min_ha_agents)
return False
return True
def _add_port_from_net_and_ensure_vr_id(self, plugin, ctxt, router_db,
tenant_id, ha_net):
plugin._ensure_vr_id(ctxt, router_db, ha_net)
@ -379,9 +371,6 @@ class L3Scheduler(object):
tenant_id, candidates):
"""Bind a HA router to agents based on a specific policy."""
if not self._enough_candidates_for_ha(candidates):
return
chosen_agents = self._choose_router_agents_for_ha(
plugin, context, candidates)

View File

@ -344,10 +344,6 @@ class L3AZLeastRoutersSchedulerTestCase(L3AZSchedulerBaseTest):
Maximum number of agents on which a router will be scheduled.
0 means test for regular router.
min_l3_agents_per_router
Minimum number of agents on which a router will be scheduled.
N/A for regular router test.
down_agent_count[each az]
Number of l3 agents which are down.
@ -361,7 +357,6 @@ class L3AZLeastRoutersSchedulerTestCase(L3AZSchedulerBaseTest):
router_az_hints=1,
agent_count=[1, 1],
max_l3_agents_per_router=0,
min_l3_agents_per_router=0,
down_agent_count=[0, 0],
expected_scheduled_agent_count=[1, 0])),
@ -370,7 +365,6 @@ class L3AZLeastRoutersSchedulerTestCase(L3AZSchedulerBaseTest):
router_az_hints=2,
agent_count=[1, 1, 1],
max_l3_agents_per_router=2,
min_l3_agents_per_router=2,
down_agent_count=[0, 0, 0],
expected_scheduled_agent_count=[1, 1, 0])),
@ -379,18 +373,8 @@ class L3AZLeastRoutersSchedulerTestCase(L3AZSchedulerBaseTest):
router_az_hints=2,
agent_count=[2, 1],
max_l3_agents_per_router=3,
min_l3_agents_per_router=2,
down_agent_count=[0, 0],
expected_scheduled_agent_count=[2, 1])),
('HA router, not enough agents',
dict(az_count=3,
router_az_hints=2,
agent_count=[2, 2, 2],
max_l3_agents_per_router=3,
min_l3_agents_per_router=2,
down_agent_count=[1, 1, 0],
expected_scheduled_agent_count=[1, 1, 0])),
]
def setUp(self):
@ -402,7 +386,6 @@ class L3AZLeastRoutersSchedulerTestCase(L3AZSchedulerBaseTest):
ha = False
if self.max_l3_agents_per_router:
self.config(max_l3_agents_per_router=self.max_l3_agents_per_router)
self.config(min_l3_agents_per_router=self.min_l3_agents_per_router)
ha = True
# create l3 agents
@ -451,10 +434,6 @@ class L3AZAutoScheduleTestCaseBase(L3AZSchedulerBaseTest):
Maximum number of agents on which a router will be scheduled.
0 means test for regular router.
min_l3_agents_per_router
Minimum number of agents on which a router will be scheduled.
N/A for regular router test.
down_agent_count[each az]
Number of l3 agents which are down.
@ -472,7 +451,6 @@ class L3AZAutoScheduleTestCaseBase(L3AZSchedulerBaseTest):
agent_az='az0',
agent_count=[1, 1],
max_l3_agents_per_router=0,
min_l3_agents_per_router=0,
down_agent_count=[1, 1],
scheduled_agent_count=[0, 0],
expected_scheduled_agent_count=[1, 0])),
@ -483,7 +461,6 @@ class L3AZAutoScheduleTestCaseBase(L3AZSchedulerBaseTest):
agent_az='az1',
agent_count=[1, 1],
max_l3_agents_per_router=0,
min_l3_agents_per_router=0,
down_agent_count=[1, 1],
scheduled_agent_count=[0, 0],
expected_scheduled_agent_count=[0, 0])),
@ -494,7 +471,6 @@ class L3AZAutoScheduleTestCaseBase(L3AZSchedulerBaseTest):
agent_az='az1',
agent_count=[1, 1, 1],
max_l3_agents_per_router=2,
min_l3_agents_per_router=2,
down_agent_count=[0, 1, 0],
scheduled_agent_count=[0, 0, 0],
expected_scheduled_agent_count=[0, 1, 0])),
@ -505,7 +481,6 @@ class L3AZAutoScheduleTestCaseBase(L3AZSchedulerBaseTest):
agent_az='az2',
agent_count=[1, 1, 1],
max_l3_agents_per_router=2,
min_l3_agents_per_router=2,
down_agent_count=[0, 0, 1],
scheduled_agent_count=[0, 0, 0],
expected_scheduled_agent_count=[0, 0, 0])),
@ -517,7 +492,6 @@ class L3AZAutoScheduleTestCaseBase(L3AZSchedulerBaseTest):
ha = False
if self.max_l3_agents_per_router:
self.config(max_l3_agents_per_router=self.max_l3_agents_per_router)
self.config(min_l3_agents_per_router=self.min_l3_agents_per_router)
ha = True
# create l3 agents

View File

@ -119,19 +119,8 @@ class L3HATestCase(L3HATestFramework):
l3_ext_ha_mode.HANetworkCIDRNotValid,
self.plugin._verify_configuration)
def test_verify_configuration_min_l3_agents_per_router_below_minimum(self):
cfg.CONF.set_override('min_l3_agents_per_router', 0)
self.assertRaises(
l3_ext_ha_mode.HAMinimumAgentsNumberNotValid,
self.plugin._check_num_agents_per_router)
def test_verify_configuration_min_l3_agents_per_router_eq_one(self):
cfg.CONF.set_override('min_l3_agents_per_router', 1)
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)
def test_verify_configuration_max_l3_agents_below_0(self):
cfg.CONF.set_override('max_l3_agents_per_router', -5)
self.assertRaises(
l3_ext_ha_mode.HAMaximumAgentsNumberNotValid,
self.plugin._check_num_agents_per_router)
@ -323,15 +312,6 @@ class L3HATestCase(L3HATestFramework):
ha=True,
distributed=True)
def test_migrate_legacy_router_to_ha_not_enough_agents(self):
router = self._create_router(ha=False, distributed=False)
self.assertFalse(router['ha'])
self.assertFalse(router['distributed'])
helpers.set_agent_admin_state(self.agent2['id'], admin_state_up=False)
self.assertRaises(l3_ext_ha_mode.HANotEnoughAvailableAgents,
self._migrate_router, router['id'], ha=True)
def test_unbind_ha_router(self):
router = self._create_router()
@ -802,13 +782,6 @@ class L3HATestCase(L3HATestFramework):
self.admin_ctx)
self.assertEqual(3, num_ha_candidates)
def test_get_number_of_agents_for_scheduling_not_enough_agents(self):
cfg.CONF.set_override('min_l3_agents_per_router', 3)
helpers.kill_agent(helpers.register_l3_agent(host='l3host_3')['id'])
self.assertRaises(l3_ext_ha_mode.HANotEnoughAvailableAgents,
self.plugin.get_number_of_agents_for_scheduling,
self.admin_ctx)
def test_ha_network_deleted_if_no_ha_router_present_two_tenants(self):
# Create two routers in different tenants.
router1 = self._create_router()

View File

@ -39,7 +39,6 @@ from neutron.db.models import agent as agent_model
from neutron.db.models import l3agent as rb_model
from neutron.db.models import l3ha as l3ha_model
from neutron.extensions import l3
from neutron.extensions import l3_ext_ha_mode as l3_ha
from neutron.extensions import l3agentscheduler as l3agent
from neutron.extensions import portbindings
from neutron import manager
@ -1555,7 +1554,6 @@ class VacantBindingIndexTestCase(L3HATestCaseMixin):
def test_get_vacant_binding_index(self):
helpers.register_l3_agent('host_3')
cfg.CONF.set_override('max_l3_agents_per_router', 3)
cfg.CONF.set_override('min_l3_agents_per_router', 3)
router = self._create_ha_router()
if self.binding_index:
@ -1875,18 +1873,6 @@ class L3HAChanceSchedulerTestCase(L3HATestCaseMixin):
'host_3',
routers_to_auto_schedule)
def test_scheduler_with_ha_enabled_not_enough_agent(self):
r1 = self._create_ha_router()
agents = self.plugin.get_l3_agents_hosting_routers(
self.adminContext, [r1['id']],
admin_state_up=True)
self.assertEqual(2, len(agents))
self._set_l3_agent_admin_state(self.adminContext,
self.agent_id2, False)
self.assertRaises(
l3_ha.HANotEnoughAvailableAgents, self._create_ha_router)
class L3HALeastRoutersSchedulerTestCase(L3HATestCaseMixin):

View File

@ -0,0 +1,12 @@
---
upgrade:
- The neutron.conf:min_l3_agents_per_router option was
deprecated in Newton and removed in Ocata. HA routers
no longer require a minimal number of L3 agents to
be created, although obviously require at least
two L3 agents to provide HA. The rationale for the
removal of the option is the case a router was created
just when an agent was not operational. The creation
of the router will now succeed and when a second agent
resumes operation the router will be scheduled to it
providing HA.