]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Don't resync on DHCP agent setup failure
authorKevin Benton <blak111@gmail.com>
Fri, 24 Apr 2015 07:35:31 +0000 (00:35 -0700)
committerKevin Benton <blak111@gmail.com>
Fri, 24 Apr 2015 11:10:02 +0000 (04:10 -0700)
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)

neutron/agent/dhcp/agent.py
neutron/tests/unit/agent/dhcp/test_agent.py

index 214bfdff14de3c55c2335d15866ed52301e02344..c11c1f24ee5fe0bcaf9a4798c040aa2b5c9c5caa 100644 (file)
@@ -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)):
index c618658f7c5659d6c98bf5aaef8ef0a77f51c5b8..5aca05ffca40a0d28ec1ebe56d4c05e9965efe62 100644 (file)
@@ -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()