Merge "Dont schedule Network, respecting network_auto_schedule config"

This commit is contained in:
Zuul 2019-11-27 06:05:13 +00:00 committed by Gerrit Code Review
commit f0db43df55
3 changed files with 44 additions and 1 deletions

View File

@ -475,7 +475,7 @@ class DhcpAgentSchedulerDbMixin(dhcpagentscheduler
return {'agents': []}
def schedule_network(self, context, created_network):
if self.network_scheduler:
if self.network_scheduler and cfg.CONF.network_auto_schedule:
return self.network_scheduler.schedule(
self, context, created_network)

View File

@ -1354,6 +1354,35 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
self._list_networks_hosted_by_dhcp_agent(invalid_agentid,
exc.HTTPNotFound.code)
def test_network_no_reschedule(self):
cfg.CONF.set_override('allow_overlapping_ips', True)
cfg.CONF.set_override('network_auto_schedule', False)
with self.subnet() as sb1, self.subnet():
network1_id = sb1['subnet']['network_id']
dhcp_rpc_cb = dhcp_rpc.DhcpRpcCallback()
self._register_agent_states()
hosta_id = self._get_agent_id(constants.AGENT_TYPE_DHCP,
DHCP_HOSTA)
hostc_id = self._get_agent_id(constants.AGENT_TYPE_DHCP,
DHCP_HOSTC)
dhcp_rpc_cb.get_active_networks_info(
self.adminContext, host=DHCP_HOSTA)
dhcp_rpc_cb.get_active_networks_info(
self.adminContext, host=DHCP_HOSTC)
networks = self._list_networks_hosted_by_dhcp_agent(hostc_id)
num_hostc_nets = len(networks['networks'])
networks = self._list_networks_hosted_by_dhcp_agent(hosta_id)
num_hosta_nets = len(networks['networks'])
self.assertEqual(0, num_hosta_nets)
self.assertEqual(0, num_hostc_nets)
# After this patch, network which requires DHCP
# has to be manually mapped
self._add_network_to_dhcp_agent(hosta_id,
network1_id)
networks = self._list_networks_hosted_by_dhcp_agent(hosta_id)
num_hosta_nets = len(networks['networks'])
self.assertEqual(1, num_hosta_nets)
class OvsDhcpAgentNotifierTestCase(test_agent.AgentDBTestMixIn,
AgentSchedulerTestMixIn,

View File

@ -0,0 +1,14 @@
---
fixes:
- |
Neutron currently does not fully respect the network-auto-schedule
configuration option. If the network-auto-schedule option is set to
False, the network -
a) Is still scheduled on the DHCP agent when it is created
b) Is scheduled on a new DHCP agent if the old DHCP mapping is removed
by the user/admin.
It is especially necessary where the Network Backends provide DHCP
directly. This has been fixed now and if the network-auto-schedule
is set to False in the config file, networks would not be automatically
scheduled to the DHCP Agents. If mapping/scheduling is required, it can
be done manually or by setting the network-auto-schedule to True.