From fe5b2a99d9555d335eb4119f223f4f64340c200f Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Mon, 8 Nov 2021 13:18:12 -0800 Subject: [PATCH] [pytest]: Ignore errors deleting host ifs (#2005) The delete command for host interfaces during virtual server set up can occasionally fail if the interface has been auto-deleted before the command is run. This causes cascading failures for the VS test suite. Ignore such an error if this occurs. 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 059c0576fb9e..0ec6626fe967 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}")