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
This commit is contained in:
Kevin Benton 2017-03-02 02:08:20 -08:00 committed by Kevin Benton
parent 2448df8651
commit 4094979777
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

@ -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)

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

@ -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',