]> 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 10:14:22 +0000 (03:14 -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

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

index aa0f9bc82c339c492ffbd7196444158d80664a9f..1942fc6526265e86be93ff2de5ebd0b5309e5919 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 c9ecbed2cb420ec986ad77c864a5742a6a4c132b..24c0d10564cd6b5de78d55ea67dfefe22e9f775c 100644 (file)
@@ -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()