From bc130622aa4e1dc8f89b9f5214900ccb10adee84 Mon Sep 17 00:00:00 2001 From: Peng Lei Date: Sat, 16 Nov 2024 12:42:38 +0800 Subject: [PATCH] Resolve "leaked mount point" --- src/containernet/containernet.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/containernet/containernet.py b/src/containernet/containernet.py index fb252d6..d4a6971 100644 --- a/src/containernet/containernet.py +++ b/src/containernet/containernet.py @@ -53,6 +53,15 @@ def __init__(self, config: NestedConfig, yaml_base_path: str, oasis_workspace: s self.start_time = time.time() self.setUp() + def __check_leaked_mounts(self): + # check whether there are leaked mounts + cmd = "sudo mount | grep -i oasis | wc -l" + result = os.popen(cmd).read() + if int(result) > 0: + logging.warning("Error: there are leaked mounts. %s", result) + cmd = "sudo mount | grep -i 'oasis' | awk -F ' on | type ' '{print $2}' | xargs -I {} sudo umount \"{}\"" + os.system(cmd) + def setUp(self) -> None: logging.info( "########################## Oasis setup " @@ -78,6 +87,7 @@ def tearDown(self) -> None: def stop(self): self.tearDown() + self.__check_leaked_mounts() def start(self): # NestedContainernet, use case file name as the container name.