From 0c0951e8e88bef34884111fdee9ffde310e529e9 Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Thu, 4 Nov 2021 01:27:49 +0000 Subject: [PATCH] [pytest]: Ignore errors deleting host ifs Signed-off-by: Lawrence Lee --- tests/conftest.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 059c0576fb..0ec6626fe9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -187,7 +187,15 @@ def __init__(self, ctn_name: str, pid: int, i: int): # ensure self.pifname is not already an interface in the DVS net namespace rc, _ = subprocess.getstatusoutput(f"nsenter -t {pid} -n ip link show | grep '{self.pifname}@'") if not rc: - ensure_system(f"nsenter -t {pid} -n ip link delete {self.pifname}") + try: + ensure_system(f"nsenter -t {pid} -n ip link delete {self.pifname}") + except RuntimeError as e: + # Occasionally self.pifname will get deleted between us checking for its existence + # and us deleting it ourselves. In this case we can continue normally + if "cannot find device" in str(e).lower(): + pass + else: + raise e ensure_system(f"ip netns exec {self.nsname} ip link set {self.pifname} netns {pid}")