saved_binding = {'net': binding.network_id,
'agent': binding.dhcp_agent_id}
try:
+ # do not notify agent if it considered dead
+ # so when it is restarted it won't see network delete
+ # notifications on its queue
self.remove_network_from_dhcp_agent(context,
binding.dhcp_agent_id,
- binding.network_id)
+ binding.network_id,
+ notify=False)
except dhcpagentscheduler.NetworkNotHostedByDhcpAgent:
# measures against concurrent operation
LOG.debug("Network %(net)s already removed from DHCP agent "
dhcp_notifier.network_added_to_agent(
context, network_id, agent_db.host)
- def remove_network_from_dhcp_agent(self, context, id, network_id):
+ def remove_network_from_dhcp_agent(self, context, id, network_id,
+ notify=True):
agent = self._get_agent(context, id)
with context.session.begin(subtransactions=True):
try:
self.update_port(context, port['id'], dict(port=port))
query.delete()
+ if not notify:
+ return
dhcp_notifier = self.agent_notifiers.get(constants.AGENT_TYPE_DHCP)
if dhcp_notifier:
dhcp_notifier.network_removed_from_agent(
notifier = mock.MagicMock()
self.agent_notifiers[constants.AGENT_TYPE_DHCP] = notifier
self.remove_networks_from_down_agents()
- rn.assert_called_with(mock.ANY, agents[0].id, self.network_id)
+ rn.assert_called_with(mock.ANY, agents[0].id, self.network_id,
+ notify=False)
sch.assert_called_with(mock.ANY, {'id': self.network_id})
notifier.network_added_to_agent.assert_called_with(
mock.ANY, self.network_id, agents[1].host)
notifier = mock.MagicMock()
self.agent_notifiers[constants.AGENT_TYPE_DHCP] = notifier
self.remove_networks_from_down_agents()
- rn.assert_called_with(mock.ANY, agents[0].id, self.network_id)
+ rn.assert_called_with(mock.ANY, agents[0].id, self.network_id,
+ notify=False)
sch.assert_called_with(mock.ANY, {'id': self.network_id})
self.assertFalse(notifier.network_added_to_agent.called)