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

Fix VM (re-)starting + test #38

Merged
merged 1 commit into from
Jan 20, 2025
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
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
Loading