dehesselle / virtctl

start/stop libvirt-based VMs with systemd
MIT License
11 stars 1 forks source link

adjust timeouts/logic to avoid killing service/VM #9

Closed dehesselle closed 5 years ago

dehesselle commented 5 years ago

Scenario: forward_port is not successful (and there is already a small loop in place to try multiple times in case VM is slow to start) the first time. If there are multiple calls to forward_port in the post-start actions, they all add up to the delay, leading ultimately to a startup timeout. Timeout leads to killing the VM ungracefully, which we want to avoid at all cost since it can potentially corrupt the VM.

Solution is to adjust the code that the first failure of forward_port skips over consecutive calls to not result in a timeout.

dehesselle commented 5 years ago

I went a different, more generalized route. Using the timeout program, the critical ExecStartPost and ExecStopPre (doesn't officially exist - it's in fact the first ExecStop) commands are now run under its supervision. That means that timeout will kill those commands off before a systemd timeout kills the whole service/process/VM.