From db9ac7e0110a0c2ef1b65213317ee8b7f1053ddc Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Fri, 24 Apr 2015 00:35:31 -0700 Subject: [PATCH] Don't resync on DHCP agent setup failure There are various cases where the DHCP agent will try to create a DHCP port for a network and there will be a failure. This has primarily been caused by a lack of available IP addresses in the allocation pool. Trying to fix all availability corner cases on the server side will be very difficult due to race conditions between multiple ports being created, the dhcp_agents_per_network parameter, etc. This patch just stops the resync attempt on the agent side if a failure is caused by an IP address generation problem. Future updates to the subnet will cause another attempt so if the tenant does fix the issue they will get DHCP service. Change-Id: I0896730126d6dca13fe9284b4d812cfb081b6218 Closes-Bug: #1447883 --- neutron/agent/dhcp/agent.py | 7 ++++++- neutron/tests/unit/agent/dhcp/test_agent.py | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/neutron/agent/dhcp/agent.py b/neutron/agent/dhcp/agent.py index aa0f9bc82..1942fc652 100644 --- a/neutron/agent/dhcp/agent.py +++ b/neutron/agent/dhcp/agent.py @@ -120,7 +120,12 @@ class DhcpAgent(manager.Manager): 'still exist.'), {'net_id': network.id, 'action': action}) except Exception as e: - self.schedule_resync(e, network.id) + if getattr(e, 'exc_type', '') != 'IpAddressGenerationFailure': + # Don't resync if port could not be created because of an IP + # allocation failure. When the subnet is updated with a new + # allocation pool or a port is deleted to free up an IP, this + # will automatically be retried on the notification + self.schedule_resync(e, network.id) if (isinstance(e, oslo_messaging.RemoteError) and e.exc_type == 'NetworkNotFound' or isinstance(e, exceptions.NetworkNotFound)): diff --git a/neutron/tests/unit/agent/dhcp/test_agent.py b/neutron/tests/unit/agent/dhcp/test_agent.py index c9ecbed2c..24c0d1056 100644 --- a/neutron/tests/unit/agent/dhcp/test_agent.py +++ b/neutron/tests/unit/agent/dhcp/test_agent.py @@ -306,6 +306,11 @@ class TestDhcpAgent(base.BaseTestCase): self.assertEqual(log.call_count, 1) self.assertEqual(expected_sync, schedule_resync.called) + def test_call_driver_ip_address_generation_failure(self): + error = oslo_messaging.RemoteError( + exc_type='IpAddressGenerationFailure') + self._test_call_driver_failure(exc=error, expected_sync=False) + def test_call_driver_failure(self): self._test_call_driver_failure() -- 2.45.2