Don't emit confusing error in netns-cleanup

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
This commit is contained in:
Assaf Muller 2015-12-07 17:36:06 -05:00
parent c58b8d5eaa
commit cfc9578148

View 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):