From 8faa5f076bc8c7906d8d987931b7c817acfcbe8b Mon Sep 17 00:00:00 2001 From: armando-migliaccio Date: Thu, 21 Nov 2013 13:07:28 -0800 Subject: [PATCH] Handle IPAddressGenerationFailure during get_dhcp_port If a network/subnet is deleted while the dhcp agent is trying to get/create a dhcp port for that network, the exception will be raised because no IP Allocation Range is available. However, this particular failure mode causes just noise, because the dhcp agent can cope with it without problems. A follow-up patch will deal with the other exception traces during create_dhcp_port Partial-bug: #1253344 Change-Id: I7fe35455ce905daa22ff96367e120864a7d3fb92 --- neutron/db/dhcp_rpc_base.py | 3 ++- neutron/tests/unit/test_db_rpc_base.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/neutron/db/dhcp_rpc_base.py b/neutron/db/dhcp_rpc_base.py index bf7a3d07ef3..93fe58a5a81 100644 --- a/neutron/db/dhcp_rpc_base.py +++ b/neutron/db/dhcp_rpc_base.py @@ -168,7 +168,8 @@ class DhcpRpcCallbackMixin(object): retval = plugin.create_port(context, dict(port=port_dict)) except (db_exc.DBError, n_exc.NetworkNotFound, - n_exc.SubnetNotFound) as e: + n_exc.SubnetNotFound, + n_exc.IpAddressGenerationFailure) as e: LOG.warn(_("Port for network %(net_id)s could not be created: " "%(reason)s") % {"net_id": network_id, 'reason': e}) return diff --git a/neutron/tests/unit/test_db_rpc_base.py b/neutron/tests/unit/test_db_rpc_base.py index e9f4a78be1a..617169c56bc 100644 --- a/neutron/tests/unit/test_db_rpc_base.py +++ b/neutron/tests/unit/test_db_rpc_base.py @@ -138,6 +138,10 @@ class TestDhcpRpcCallackMixin(base.BaseTestCase): self._test_get_dhcp_port_with_failures( raise_create_port=n_exc.SubnetNotFound(subnet_id='b')) + def test_get_dhcp_port_catch_ip_generation_failure_on_create_port(self): + self._test_get_dhcp_port_with_failures( + raise_create_port=n_exc.IpAddressGenerationFailure(net_id='a')) + def _test_get_dhcp_port_create_new(self, update_port=None): self.plugin.get_network.return_value = dict(tenant_id='tenantid') create_spec = dict(tenant_id='tenantid', device_id='devid',