Do not try to delete a veth from a nonexistent namespace

Currently, VethFixture cleanup tries to delete veth from their
namespaces even if they don't exist anymore (without crashing the
cleanup). It implies an extra trace if an error is raised which can be
confusing.

This change avoids to try deleting a veth from a nonexistent namespace
in the fixture VethFixture.

Closes-Bug: #1506862
Change-Id: I5d0192998d2f3f8d1a6f783769ae9bfcb4bae7f2
This commit is contained in:
Cedric Brandily 2015-09-08 15:02:57 +00:00
parent dbe420c2b7
commit 72e87f6d87
1 changed files with 8 additions and 7 deletions

View File

@ -409,13 +409,14 @@ class VethFixture(fixtures.Fixture):
def destroy(self):
for port in self.ports:
ip_wrapper = ip_lib.IPWrapper(port.namespace)
try:
ip_wrapper.del_veth(port.name)
break
except RuntimeError:
# NOTE(cbrandily): It seems a veth is automagically deleted
# when a namespace owning a veth endpoint is deleted.
pass
if ip_wrapper.netns.exists(port.namespace):
try:
ip_wrapper.del_veth(port.name)
break
except RuntimeError:
# NOTE(cbrandily): It seems a veth is automagically deleted
# when a namespace owning a veth endpoint is deleted.
pass
@staticmethod
def get_peer_name(name):