DHCP: Add missing path for marking ports as ready

'refresh_dhcp_helper', which is called after subnet update/create
notifications in the DHCP agent, can end up retrieving ports that
the agent hadn't yet seen. It will then configure those ports but
not notify the server that they are ready.

Unless the port is subsequently updated on the server afterwards to
generate a new port update notification, the DHCP agent won't ever tell
the server that the port has had DHCP provisioned. This led to the
bug this closes. Another patch[1] that removed excessive DHCP ready
notifications uncovered this bug.

This patch just adjusts refresh_dhcp_helper to ensure that all ports
are marked as ready after configuring them all.

1. Ie7686837b18ff251baa315ef95dc511cda475672

Change-Id: I1fed60c1835c2ebed7c050c6fa114f89beec3190
Closes-Bug: #1639806
This commit is contained in:
Kevin Benton 2016-11-08 15:15:26 -08:00
parent 04bee5befc
commit 9f1057bfd9
2 changed files with 6 additions and 0 deletions

View File

@ -320,6 +320,9 @@ class DhcpAgent(manager.Manager):
self.cache.put(network)
elif self.call_driver('restart', network):
self.cache.put(network)
# mark all ports as active in case the sync included
# new ports that we hadn't seen yet.
self.dhcp_ready_ports |= {p.id for p in network.ports}
# Update the metadata proxy after the dhcp driver has been updated
self.update_isolated_metadata_proxy(network)

View File

@ -976,6 +976,9 @@ class TestDhcpAgentEventHandler(base.BaseTestCase):
self.cache.assert_has_calls([mock.call.put(fake_network)])
self.call_driver.assert_called_once_with('reload_allocations',
fake_network)
# ensure all ports flagged as ready
self.assertEqual({p.id for p in fake_network.ports},
self.dhcp.dhcp_ready_ports)
def test_subnet_update_end_restart(self):
new_state = dhcp.NetModel(dict(id=fake_network.id,