From d4bbce2dcf5ae73bfa22e6ce3a9c09b507857fb4 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Fri, 20 Mar 2020 15:20:11 +0100 Subject: [PATCH] Raise InvalidContainerStateError when await_state fails --- usr/lib/python3.8/spoc/container.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/usr/lib/python3.8/spoc/container.py b/usr/lib/python3.8/spoc/container.py index 7a1b684..d63e1e8 100644 --- a/usr/lib/python3.8/spoc/container.py +++ b/usr/lib/python3.8/spoc/container.py @@ -73,7 +73,10 @@ class Container: def await_state(self, awaited_state): # Block execution until the container reaches the desired state or until timeout - subprocess.run(['lxc-wait', '-P', CONTAINERS_DIR, '-s', awaited_state.value, '-t', '30', self.name], check=True) + try: + subprocess.run(['lxc-wait', '-P', CONTAINERS_DIR, '-s', awaited_state.value, '-t', '30', self.name], check=True) + except subprocess.CalledProcessError: + raise InvalidContainerStateError(self.name, self.get_state()) def mount_rootfs(self): # Prepares container rootfs