]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Don't emit confusing error in netns-cleanup
authorAssaf Muller <amuller@redhat.com>
Mon, 7 Dec 2015 22:36:06 +0000 (17:36 -0500)
committerAssaf Muller <amuller@redhat.com>
Tue, 8 Dec 2015 01:17:49 +0000 (20:17 -0500)
If we're trying to delete a dhcp/qrouter device with use_veth
= False (Which is the default for some time), we'll first
try to 'ip link del %s', which will fail and emit a confusing
error, then try 'ovs-vsctl del-port'. There's no need to
log an error in such a case.

The patch attempts to future proof by setting the
set_log_fail_as_error(False) to be as tight as possible, so we
do log errors in case the device is somehow used in the future.

Change-Id: I1954bde3ee9a2e43d7615717134b61c5fa7cfbb1
Closes-Bug: #1463800

neutron/cmd/netns_cleanup.py

index 0c53ded682deb9442a028609db4426b0685a9059..3d59ef99dede2cd069cf8cb22383bed346a77d1b 100644 (file)
@@ -112,9 +112,12 @@ def eligible_for_deletion(conf, namespace, force=False):
 
 
 def unplug_device(conf, device):
+    orig_log_fail_as_error = device.get_log_fail_as_error()
+    device.set_log_fail_as_error(False)
     try:
         device.link.delete()
     except RuntimeError:
+        device.set_log_fail_as_error(orig_log_fail_as_error)
         # Maybe the device is OVS port, so try to delete
         ovs = ovs_lib.BaseOVS()
         bridge_name = ovs.get_bridge_for_iface(device.name)
@@ -123,6 +126,8 @@ def unplug_device(conf, device):
             bridge.delete_port(device.name)
         else:
             LOG.debug('Unable to find bridge for device: %s', device.name)
+    finally:
+        device.set_log_fail_as_error(orig_log_fail_as_error)
 
 
 def destroy_namespace(conf, namespace, force=False):