added option to configure startupTimeout for vms
should resolve issue #317
Make the default timeout for vm starup an option
Changed to draft, because i have not yet confirmed if this will resolve the issue
While the option is sensible, the default of 90s is already quite high. VMs should boot within a minute. However, performance has degraded sometime in the last year and we're still figuring out the reason.
Yeah, this patchset does feel like treating the symptom not the cause.
In my case the VM has booted, but I can login with ssh.
But it restarts anyways because nextcloud-setup.service can take a long time to finnish when it needs to stuff like reindexing a database.
It seems to me that the deeper issue is that vmrunner does not differentiate between "booted" and "all oneshoot services on startup being completed"
I am using this as test systemds to provoke the unwanted reboot.
# in the guest vm conf
systemd.services."expensive-oneshot" = {
enable = true;
after = ["postgresql.service"];
requires = ["postgresql.service"];
before = ["long-derp.service"];
wantedBy = ["multi-user.target"];
script = ''
#!/usr/bin/env bash
echo running dummy script
for i in {0..200}
do
sleep 1
echo "Number: $i of 200"
done
'';
serviceConfig = {
Type = "oneshot";
};
};
systemd.services."long-derp" = {
enable = true;
wantedBy = ["multi-user.target"];
script = ''
#!/bin/bash
while true :
do
echo "Dont mind me"
sleep 1
done
'';
serviceConfig = {
Type = "simple";
};
};
So i conculude if
I am using this as test systemds to provoke the unwanted reboot.
# in the guest vm conf systemd.services."expensive-oneshot" = { enable = true; after = ["postgresql.service"]; requires = ["postgresql.service"]; before = ["long-derp.service"]; wantedBy = ["multi-user.target"]; script = '' #!/usr/bin/env bash echo running dummy script for i in {0..200} do sleep 1 echo "Number: $i of 200" done ''; serviceConfig = { Type = "oneshot"; }; }; systemd.services."long-derp" = { enable = true; wantedBy = ["multi-user.target"]; script = '' #!/bin/bash while true : do echo "Dont mind me" sleep 1 done ''; serviceConfig = { Type = "simple"; }; };
With the default timeout setting this vm configuration gets stuck in endless rebooting. I assume this is because all services wanted multi-user.target is not reached in time.
But using the new proposed setting, I can give my vms enough time to complete my dummy setup service.
microvm = {
host.startupTimeout = 500;
}
I have tested and confirmed that this solves #317 I will mark this pr as ready for merge.
Do you want me to write some test, or is "trust me bro" good enough?
To speed things up, I added some review comments :)