Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure TemplateVMs are shut down prior to rebooting #522

Merged
merged 1 commit into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions launcher/sdw_updater_gui/Updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,21 @@ def shutdown_and_start_vms():
"""

sdw_vms_in_order = [
"sys-whonix",
"sd-app",
"sd-proxy",
"sys-whonix",
"sd-whonix",
"sd-app",
"sd-gpg",
"sd-log",
]

# All TemplateVMs minus dom0
sdw_templates = [val for key, val in current_templates.items() if key != "dom0"]

sdlog.info("Ensure TemplateVMs are shut down")
for vm in sdw_templates:
_safely_shutdown_vm(vm)

sdlog.info("Shutting down SDW VMs for updates")
for vm in sdw_vms_in_order:
_safely_shutdown_vm(vm)
Expand Down
32 changes: 26 additions & 6 deletions launcher/tests/test_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,17 +653,27 @@ def test_shutdown_and_start_vms(
call("sys-net"),
call("sys-firewall"),
]
template_vm_calls = [
call("fedora-30"),
call("sd-viewer-buster-template"),
call("sd-app-buster-template"),
call("sd-log-buster-template"),
call("sd-devices-buster-template"),
call("sd-proxy-buster-template"),
call("whonix-gw-15"),
call("securedrop-workstation-buster"),
]
app_vm_calls = [
call("sys-whonix"),
call("sd-app"),
call("sd-proxy"),
call("sys-whonix"),
call("sd-whonix"),
call("sd-app"),
call("sd-gpg"),
call("sd-log"),
]
updater.shutdown_and_start_vms()
mocked_call.assert_has_calls(sys_vm_kill_calls)
mocked_shutdown.assert_has_calls(app_vm_calls)
mocked_shutdown.assert_has_calls(template_vm_calls + app_vm_calls)
app_vm_calls_reversed = list(reversed(app_vm_calls))
mocked_start.assert_has_calls(sys_vm_start_calls + app_vm_calls_reversed)
assert not mocked_error.called
Expand All @@ -690,13 +700,23 @@ def test_shutdown_and_start_vms_sysvm_fail(
call("sys-firewall"),
]
app_vm_calls = [
call("sys-whonix"),
call("sd-app"),
call("sd-proxy"),
call("sys-whonix"),
call("sd-whonix"),
call("sd-app"),
call("sd-gpg"),
call("sd-log"),
]
template_vm_calls = [
call("fedora-30"),
call("sd-viewer-buster-template"),
call("sd-app-buster-template"),
call("sd-log-buster-template"),
call("sd-devices-buster-template"),
call("sd-proxy-buster-template"),
call("whonix-gw-15"),
call("securedrop-workstation-buster"),
]
error_calls = [
call("Error while killing sys-firewall"),
call("Command 'check_call' returned non-zero exit status 1."),
Expand All @@ -707,7 +727,7 @@ def test_shutdown_and_start_vms_sysvm_fail(
]
updater.shutdown_and_start_vms()
mocked_call.assert_has_calls(sys_vm_kill_calls)
mocked_shutdown.assert_has_calls(app_vm_calls)
mocked_shutdown.assert_has_calls(template_vm_calls + app_vm_calls)
app_vm_calls_reversed = list(reversed(app_vm_calls))
mocked_start.assert_has_calls(sys_vm_start_calls + app_vm_calls_reversed)
mocked_error.assert_has_calls(error_calls)
Expand Down