VMs with wrong state (RUNNING) after host reboot

Hello,
I have noticed a problem when I perform host reboot:
after rebooting the host, the VMs that previously were RUNNING are still detected as running and only after a while (some minutes) their state get automatically changed to POWEROFF.
This gives me some troubles because I would like to have VMs getting suspended or properly shutdown during host shutdown (since I only have one host) and automatically restarted when the host is up again.
I have checked this post but it does not work since it never happens that the VM has STATE = ACTIVE and LCM_STATE = UNKNOWN . Somebody else reported the same issue but without any solution.
This is what I see on the VM log:

Sun Dec 6 18:54:08 2020 [Z0][VM][I]: New LCM state is RUNNING
Sun Dec 6 18:59:09 2020 [Z0][LCM][I]: VM running but monitor state is POWEROFF
Sun Dec 6 18:59:09 2020 [Z0][VM][I]: New LCM state is SHUTDOWN_POWEROFF
Sun Dec 6 18:59:09 2020 [Z0][VM][I]: New state is POWEROFF
Sun Dec 6 18:59:09 2020 [Z0][VM][I]: New LCM state is LCM_INIT

At 18:54:08 I have started the VM and I have then immediately rebooted the host. One minute later the host was up again but it took 4 minutes to detect the poweroff status. During another attempt it took more than 10 minutes to detect this.
I am running OpenNebula 5.12.0.3-1.ce on Ubuntu 20.04.

Summarizing: I would like to properly shutdown and restart VMs during host reboot but I can’t because of this weird behaviour.

Thank you in advance for your help.

Hello @skarux,

I think that you should get familiar with the monitoring and see is there a room for additional tuning in your use case.

Also, IMHO, when a host reboots because of a hw failure or power outage there is no room to do proper VM shutdown. If you are talking about a planned maintenance procedure the administrator that execute the maintenance could take care of the VMs - migrate them or power-off them (properly)…

Best Regards,
Anton Todorov

Thank you @atodorov_storpool,
I will check the link to try at least gracefully suspending them during planned shutdown.
What I don’t understand is why there is no way to set an automatic restart on failure or something like that, like for example can be done with dockers (ok, I know that containers are not VMs and probably OpenNebula is targeting environments where power failures never happen, but anyway it would be a nice feature to have).

Hello @skarux, I think that OpenNebula is designed to be used with cluster of compute nodes and then you can implement host error hooks for properly starting VMs on another machine. Check this http://docs.opennebula.io/5.12/advanced_components/ha/ftguide.html

Regarding planned shutdown, you should [live]migrate VMs to another compute node, or power off each. You can use “check all” function in Sunstone and power off all. After reboot you just check all and hit start button.