Skip to content

Commit

Permalink
Mac: Final stability improvements for really shutting down the mac ma…
Browse files Browse the repository at this point in the history
…chines. Closes #570.
  • Loading branch information
adamdoupe committed Sep 26, 2024
1 parent 6f2f042 commit f6b3d0d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions dojo_plugin/utils/mac_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,16 @@ def remove(self, force=True):
# Kill the VM

# first try to shutdown the VM
timeout_hit = False
try:
self.exec_run("/sbin/shutdown -h now", "0", timeout_seconds=10)
except subprocess.TimeoutExpired:
# if that didn't work, kill it
if force:
command = f'{MAC_GUEST_CONTROL_FILE} kill-vm {self.id}'
exitcode, output = self.client._ssh_exec(command)
if b'Error' in output:
raise Exception(f'Error removing container: {output}')
timeout_hit = True

if force or timeout_hit:
command = f'{MAC_GUEST_CONTROL_FILE} kill-vm {self.id}'
exitcode, output = self.client._ssh_exec(command, exception_on_fail=False)

def wait(self, condition='removed'):
# Wait until the VM is removed
Expand Down

0 comments on commit f6b3d0d

Please sign in to comment.