Merge "Drop 'notifies_port_ready' check for DHCP agents"

This commit is contained in:
Jenkins 2017-05-26 01:04:49 +00:00 committed by Gerrit Code Review
commit 86776276a3
4 changed files with 7 additions and 32 deletions

View File

@ -227,14 +227,7 @@ class DhcpAgent(manager.Manager):
except oslo_messaging.MessagingTimeout:
LOG.error(_LE("Timeout notifying server of ports ready. "
"Retrying..."))
except Exception as e:
if (isinstance(e, oslo_messaging.RemoteError)
and e.exc_type == 'NoSuchMethod'):
LOG.info(_LI("Server does not support port ready "
"notifications. Waiting for 5 minutes "
"before retrying."))
eventlet.sleep(300)
continue
except Exception:
LOG.exception(_LE("Failure notifying DHCP server of "
"ready DHCP ports. Will retry on next "
"iteration."))
@ -712,7 +705,6 @@ class DhcpAgentWithStateReport(DhcpAgent):
'availability_zone': self.conf.AGENT.availability_zone,
'topic': topics.DHCP_AGENT,
'configurations': {
'notifies_port_ready': True,
'dhcp_driver': self.conf.dhcp_driver,
'dhcp_lease_duration': self.conf.dhcp_lease_duration,
'log_agent_heartbeats': self.conf.AGENT.log_agent_heartbeats},

View File

@ -1076,13 +1076,11 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
def _setup_dhcp_agent_provisioning_component(self, context, port):
subnet_ids = [f['subnet_id'] for f in port['fixed_ips']]
if (db.is_dhcp_active_on_any_subnet(context, subnet_ids) and
any(self.get_configuration_dict(a).get('notifies_port_ready')
for a in self.get_dhcp_agents_hosting_networks(
context, [port['network_id']]))):
# at least one of the agents will tell us when the dhcp config
# is ready so we setup a provisioning component to prevent the
# port from going ACTIVE until a dhcp_ready_on_port
# notification is received.
len(self.get_dhcp_agents_hosting_networks(context,
[port['network_id']]))):
# the agents will tell us when the dhcp config is ready so we setup
# a provisioning component to prevent the port from going ACTIVE
# until a dhcp_ready_on_port notification is received.
provisioning_blocks.add_provisioning_component(
context, port['id'], resources.PORT,
provisioning_blocks.DHCP_ENTITY)

View File

@ -435,21 +435,6 @@ class TestDhcpAgent(base.BaseTestCase):
dhcp._dhcp_ready_ports_loop()
self.assertFalse(lex.called)
def test__dhcp_ready_ports_disables_on_incompatible_server(self):
dhcp = dhcp_agent.DhcpAgent(HOSTNAME)
dhcp.agent_state = dict(configurations=dict(notifies_port_ready=True))
dhcp.dhcp_ready_ports = set(range(4))
side_effect = oslo_messaging.RemoteError(exc_type='NoSuchMethod')
with mock.patch.object(dhcp.plugin_rpc, 'dhcp_ready_on_ports',
side_effect=side_effect):
with mock.patch.object(dhcp_agent.eventlet, 'sleep',
side_effect=[None, RuntimeError]) as sleep:
with testtools.ExpectedException(RuntimeError):
dhcp._dhcp_ready_ports_loop()
# should have slept for 5 minutes
sleep.assert_called_with(300)
def test__dhcp_ready_ports_loop(self):
dhcp = dhcp_agent.DhcpAgent(HOSTNAME)
dhcp.dhcp_ready_ports = set(range(4))

View File

@ -818,7 +818,7 @@ class TestMl2PortsV2(test_plugin.TestPortsV2, Ml2PluginV2TestCase):
mock_gbl.assert_called_once_with(mock.ANY, port_id, mock.ANY)
def _add_fake_dhcp_agent(self):
agent = mock.Mock(configurations='{"notifies_port_ready": true}')
agent = mock.Mock()
plugin = directory.get_plugin()
self.get_dhcp_mock = mock.patch.object(
plugin, 'get_dhcp_agents_hosting_networks',