diff options
author | Kevin Benton <blak111@gmail.com> | 2015-04-24 00:35:31 -0700 |
---|---|---|
committer | Kevin Benton <blak111@gmail.com> | 2015-04-24 04:10:02 -0700 |
commit | d37e566dcadf8a540eb5f84b668847fa192393a1 (patch) | |
tree | 3c2458ae8482f64257c96c127bede88fe159d5a0 | |
parent | 9e113360b9ab55793a1b5d8fc0cb3e428e63c044 (diff) | |
download | neutron-d37e566dcadf8a540eb5f84b668847fa192393a1.tar.gz |
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
(cherry picked from commit db9ac7e0110a0c2ef1b65213317ee8b7f1053ddc)
-rw-r--r-- | neutron/agent/dhcp/agent.py | 7 | ||||
-rw-r--r-- | neutron/tests/unit/agent/dhcp/test_agent.py | 5 |
2 files changed, 11 insertions, 1 deletions
diff --git a/neutron/agent/dhcp/agent.py b/neutron/agent/dhcp/agent.py index 214bfdff14..c11c1f24ee 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 c618658f7c..5aca05ffca 100644 --- a/neutron/tests/unit/agent/dhcp/test_agent.py +++ b/neutron/tests/unit/agent/dhcp/test_agent.py @@ -300,6 +300,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() |