Skip to content

Commit

Permalink
Fix VM (re-)starting + test
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander V. Nikolaev <[email protected]>
  • Loading branch information
avnik committed Jan 17, 2025
1 parent 952d1b9 commit 8765696
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions crates/admin/src/admin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ impl AdminServiceImpl {
};

if status.active_state != "active" {
debug!("Spawning VM {name}");
client
.start_remote(name.to_string())
.await
Expand Down Expand Up @@ -313,6 +314,7 @@ impl AdminServiceImpl {
let vm_name = format_vm_name(&name, vm);
let systemd_agent_name = format_service_name(&name, vm);

self.start_vm(&vm_name).await?;
info!("Starting app {name} on {vm_name} via {systemd_agent_name}");

// Entry unused in "go" code
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/admin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ in
}
// attrsets.optionalAttrs cfg.debug {
"RUST_BACKTRACE" = "1";
"GIVC_LOG" = "debug";
"GIVC_LOG" = "info,givc=debug";
};
};
networking.firewall.allowedTCPPorts = unique (map (addr: strings.toInt addr.port) cfg.addresses);
Expand Down
7 changes: 5 additions & 2 deletions nixos/tests/admin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,20 @@ in
admin = lib.head adminConfig.addresses;
services = [
"[email protected]"
"microvm@foot-vm.service"
"microvm@chromium-vm.service"
"poweroff.target"
"reboot.target"
"sleep.target"
"suspend.target"
];
tls = mkTls "ghaf-host";
};
systemd.services."microvm@foot-vm" = {
systemd.services."microvm@chromium-vm" = {
script = ''
# Do nothing script, simulating microvm service
while true; do sleep 10; done
'';
wantedBy = lib.mkForce [];
};
};
guivm =
Expand Down Expand Up @@ -302,6 +303,7 @@ in
time.sleep(1)
# Ensure, that hostvm's agent registered in admin service. It take ~10 seconds to spin up and register itself
print(hostvm.succeed("${cli} --addr ${admin.addr} --port ${admin.port} --cacert ${nodes.hostvm.givc.host.tls.caCertPath} --cert ${nodes.hostvm.givc.host.tls.certPath} --key ${nodes.hostvm.givc.host.tls.keyPath} ${if tls then "" else "--notls"} --name ${admin.name} test ensure --retry 60 ${expected}"))
hostvm.require_unit_state("microvm@chromium-vm", "inactive") # MicroVM should be down!
with subtest("setup gui vm"):
# Ensure that sway in guiVM finished startup
Expand All @@ -324,6 +326,7 @@ in
with subtest("Clean run"):
print(hostvm.succeed("${cli} --addr ${admin.addr} --port ${admin.port} --cacert ${nodes.hostvm.givc.host.tls.caCertPath} --cert ${nodes.hostvm.givc.host.tls.certPath} --key ${nodes.hostvm.givc.host.tls.keyPath} ${if tls then "" else "--notls"} --name ${admin.name} start --vm chromium-vm foot"))
hostvm.require_unit_state("microvm@chromium-vm", "active") # MicroVM should be up!
time.sleep(10) # Give few seconds to application to spin up
wait_for_window("ghaf@appvm")
Expand Down

0 comments on commit 8765696

Please sign in to comment.