Make lxc-wait check more resilient

This commit is contained in:
Disassembler 2021-01-09 18:04:54 +01:00
parent d29cb7739e
commit 8c22df2e71
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499

View File

@ -85,7 +85,10 @@ class Container:
try: try:
subprocess.run(['lxc-wait', '-P', config.CONTAINERS_DIR, '-s', awaited_state.value, '-t', '30', self.name], check=True) subprocess.run(['lxc-wait', '-P', config.CONTAINERS_DIR, '-s', awaited_state.value, '-t', '30', self.name], check=True)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
raise InvalidContainerStateError(self.name, self.get_state()) # Sometimes LXC decides to return rc 1 even on successful state change
actual_state = self.get_state()
if actual_state != awaited_state:
raise InvalidContainerStateError(self.name, actual_state)
def mount_rootfs(self): def mount_rootfs(self):
# Prepares container rootfs # Prepares container rootfs