From: Cedric Brandily Date: Tue, 8 Sep 2015 15:02:57 +0000 (+0000) Subject: Do not try to delete a veth from a nonexistent namespace X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=72e87f6d87d0da65214a9d21fe603883f1d3c232;p=openstack-build%2Fneutron-build.git 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 --- diff --git a/neutron/tests/common/net_helpers.py b/neutron/tests/common/net_helpers.py index a79c1ff20..8bcaa1f72 100644 --- a/neutron/tests/common/net_helpers.py +++ b/neutron/tests/common/net_helpers.py @@ -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):