Skip to content

Commit 4222664

Browse files
committed
Don't fail during execution of namespace terminate
This allows to perform all termination commands, even if some fail making it more likely that we leave a clean state. Signed-off-by: Marek Pikuła <[email protected]>
1 parent a2cf195 commit 4222664

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

scripts/tests/chiptest/linux.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,16 @@ def _run(self, *command: str):
195195
c = c.format(app_link_name=self.app_link_name, tool_link_name=self.tool_link_name, index=self.index)
196196
log.debug("Executing: '%s'", c)
197197
if subprocess.run(c.split()).returncode != 0:
198-
log.error("Failed to execute '%s'", c)
199-
log.error("Are you using --privileged if running in docker?")
200-
sys.exit(1)
198+
# TODO: Properly push stdout/stderr to logger.
199+
raise RuntimeError(f"Failed to execute '{c}'. Are you using --privileged if running in docker?")
201200

202201
def terminate(self):
203-
self._run(*self.COMMANDS_TERMINATE)
202+
"""Execute all down commands in reverse order gracefully omitting errors."""
203+
for cmd in reversed(*self.COMMANDS_TERMINATE):
204+
try:
205+
self._run(cmd)
206+
except Exception as e:
207+
log.warning("Encountered error during namespace termination: %s", e, exc_info=True)
204208

205209

206210
class LinuxNamespacedExecutor(Executor):

0 commit comments

Comments
 (0)