]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Do not try to delete a veth from a nonexistent namespace
authorCedric Brandily <zzelle@gmail.com>
Tue, 8 Sep 2015 15:02:57 +0000 (15:02 +0000)
committerCedric Brandily <zzelle@gmail.com>
Fri, 16 Oct 2015 13:26:25 +0000 (13:26 +0000)
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

neutron/tests/common/net_helpers.py

index a79c1ff20b0f4d92dcc8cc1c76ad7729a24ba257..8bcaa1f72db8530e68006e5041b87b8b3ae9d2d3 100644 (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):