Skip to content

Commit

Permalink
[pytest]: Ignore errors deleting host ifs (sonic-net#2005)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
theasianpianist authored Nov 8, 2021
1 parent 70da9af commit fe5b2a9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down

0 comments on commit fe5b2a9

Please sign in to comment.