Skip to content

Commit fe5b2a9

Browse files
[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 <[email protected]>
1 parent 70da9af commit fe5b2a9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tests/conftest.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,15 @@ def __init__(self, ctn_name: str, pid: int, i: int):
187187
# ensure self.pifname is not already an interface in the DVS net namespace
188188
rc, _ = subprocess.getstatusoutput(f"nsenter -t {pid} -n ip link show | grep '{self.pifname}@'")
189189
if not rc:
190-
ensure_system(f"nsenter -t {pid} -n ip link delete {self.pifname}")
190+
try:
191+
ensure_system(f"nsenter -t {pid} -n ip link delete {self.pifname}")
192+
except RuntimeError as e:
193+
# Occasionally self.pifname will get deleted between us checking for its existence
194+
# and us deleting it ourselves. In this case we can continue normally
195+
if "cannot find device" in str(e).lower():
196+
pass
197+
else:
198+
raise e
191199

192200
ensure_system(f"ip netns exec {self.nsname} ip link set {self.pifname} netns {pid}")
193201

0 commit comments

Comments
 (0)