Skip to content

Conversation

@GlennWSo
Copy link
Contributor

should resolve issue #317

Make the default timeout for vm starup an option

@GlennWSo GlennWSo marked this pull request as draft April 24, 2025 08:05
@GlennWSo
Copy link
Contributor Author

Changed to draft, because i have not yet confirmed if this will resolve the issue

@astro
Copy link
Member

astro commented Apr 24, 2025

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.

@GlennWSo
Copy link
Contributor Author

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"

@GlennWSo
Copy link
Contributor Author

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";
    };
  };

@GlennWSo
Copy link
Contributor Author

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?

@GlennWSo GlennWSo marked this pull request as ready for review April 25, 2025 09:33
@SuperSandro2000 SuperSandro2000 changed the title added option to configure startupTimeout for vms Add option to configure startupTimeout for vms Jul 17, 2025
@SuperSandro2000 SuperSandro2000 changed the title Add option to configure startupTimeout for vms Add option to configure TimeoutSec for vms Jul 17, 2025
@SuperSandro2000
Copy link
Member

To speed things up, I added some review comments :)

@SuperSandro2000 SuperSandro2000 merged commit 80bddbd into microvm-nix:main Jul 20, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants