Schedule net to a DHCP agt on subnet create
Change the DHCP notifier behavior to schedule a network to a DHCP agent when a subnet is created rather than waiting for the first port to be created. This will reduce the possibility to get a VM port created and have it send a DHCP request before the DHCP agent is ready. Before, the network would be scheduled to an agent as a result of the API call to create the VM port, so the DHCP port wouldn't be created until after the VM port. After this patch, the network will have been scheduled to a DHCP agent before the first VM port is created. There is still a possibility that the DHCP agent could be responding so slowly that it doesn't create its port and activate the dnsmasq instance before the VM sends traffic. A proper fix will ensure that the dnsmasq instance is truly ready to serve requests for a new port will require significantly more code for barriers (either on the subnet creation, port creation, or the nova boot process) are too complex to add this late in the cycle. This patch also eliminates the logic in the n1kv plugin that was already doing the same thing. Closes-Bug: #1431105 Change-Id: I1c1caed0fdda6b801375a07f9252a9127058a07e
This commit is contained in:
parent
5c6781a6f7
commit
05f2344814
|
@ -70,8 +70,8 @@ class DhcpAgentNotifyAPI(object):
|
|||
{'network': {'id': network['id']}}, agent['host'])
|
||||
elif not existing_agents:
|
||||
LOG.warn(_LW('Unable to schedule network %s: no agents available; '
|
||||
'will retry on subsequent port creation events.'),
|
||||
network['id'])
|
||||
'will retry on subsequent port and subnet creation '
|
||||
'events.'), network['id'])
|
||||
return new_agents + existing_agents
|
||||
|
||||
def _get_enabled_agents(self, context, network, agents, method, payload):
|
||||
|
@ -126,6 +126,7 @@ class DhcpAgentNotifyAPI(object):
|
|||
|
||||
# schedule the network first, if needed
|
||||
schedule_required = (
|
||||
method == 'subnet_create_end' or
|
||||
method == 'port_create_end' and
|
||||
not self._is_reserved_dhcp_port(payload['port']))
|
||||
if schedule_required:
|
||||
|
|
|
@ -1297,10 +1297,6 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
|||
self).delete_subnet(context, sub['id'])
|
||||
else:
|
||||
LOG.debug("Created subnet: %s", sub['id'])
|
||||
if not q_conf.CONF.network_auto_schedule:
|
||||
# Schedule network to a DHCP agent
|
||||
net = self.get_network(context, sub['network_id'])
|
||||
self.schedule_network(context, net)
|
||||
return sub
|
||||
|
||||
def update_subnet(self, context, id, subnet):
|
||||
|
|
|
@ -139,9 +139,9 @@ class TestDhcpAgentNotifyAPI(base.BaseTestCase):
|
|||
self._test__notify_agents('port_update_end',
|
||||
expected_scheduling=0, expected_casts=1)
|
||||
|
||||
def test__notify_agents_cast_required_wo_scheduling_on_subnet_create(self):
|
||||
def test__notify_agents_cast_required_with_scheduling_subnet_create(self):
|
||||
self._test__notify_agents('subnet_create_end',
|
||||
expected_scheduling=0, expected_casts=1)
|
||||
expected_scheduling=1, expected_casts=1)
|
||||
|
||||
def test__notify_agents_no_action(self):
|
||||
self._test__notify_agents('network_create_end',
|
||||
|
|
|
@ -1285,6 +1285,11 @@ class OvsDhcpAgentNotifierTestCase(test_l3_plugin.L3NatTestCaseMixin,
|
|||
'network_create_end',
|
||||
{'network': {'id': net['network']['id']}},
|
||||
host),
|
||||
mock.call(
|
||||
mock.ANY,
|
||||
'subnet_create_end',
|
||||
subnet,
|
||||
host, 'dhcp_agent'),
|
||||
mock.call(
|
||||
mock.ANY,
|
||||
'port_create_end',
|
||||
|
|
Loading…
Reference in New Issue