From 4094979777102dd36a79d7fe8c809f9e360a946a Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Thu, 2 Mar 2017 02:08:20 -0800 Subject: [PATCH] Drop 'notifies_port_ready' check for DHCP agents Provisioning blocks merged in Newton so for Pike we can safely assume we are not running with Liberty agents that don't notify the server when the port is ready. This also drops a block of logic in the agent that was providing forward compatibility with servers that didn't support the 'dhcp_ready_on_ports' endpoint since servers have been supporting it for so long and we don't normally allow agents to be upgraded first anyway. Related-Bug: #1453350 Change-Id: Ia86547fb4601915d7dd852b6f7a11c120089d6f6 --- neutron/agent/dhcp/agent.py | 10 +--------- neutron/plugins/ml2/plugin.py | 12 +++++------- neutron/tests/unit/agent/dhcp/test_agent.py | 15 --------------- neutron/tests/unit/plugins/ml2/test_plugin.py | 2 +- 4 files changed, 7 insertions(+), 32 deletions(-) diff --git a/neutron/agent/dhcp/agent.py b/neutron/agent/dhcp/agent.py index 57988e71b75..7deb8c5581f 100644 --- a/neutron/agent/dhcp/agent.py +++ b/neutron/agent/dhcp/agent.py @@ -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}, diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index 7ddee09f513..cf2f2f8cf91 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -1041,13 +1041,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) diff --git a/neutron/tests/unit/agent/dhcp/test_agent.py b/neutron/tests/unit/agent/dhcp/test_agent.py index 02c32480041..800c7693c36 100644 --- a/neutron/tests/unit/agent/dhcp/test_agent.py +++ b/neutron/tests/unit/agent/dhcp/test_agent.py @@ -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)) diff --git a/neutron/tests/unit/plugins/ml2/test_plugin.py b/neutron/tests/unit/plugins/ml2/test_plugin.py index e33014b1b2a..be89c4fe7c1 100644 --- a/neutron/tests/unit/plugins/ml2/test_plugin.py +++ b/neutron/tests/unit/plugins/ml2/test_plugin.py @@ -744,7 +744,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',