Shutdown VM on failover to free resources

sne

New Member
Jun 15, 2022
1
0
1
The following scenario:
Node 1 & 2 are a HA cluster.
Node 1 hosts VM 1
Node 2 hosts VM 2 & VM 3
-> Node 1 crashes. VM 1 is handed over to node 2 by HA job.

Is there a way to automatically shutdown VM 3 (low prio) to free resources on Node 2 for the downtime of Node 1 (duration of failover)?
 
There is no built-in mechanism to what you want, simply because most people would not want to do such a thing.
It should be trivial to write a script that checks status of the nodes/vms and shutsdown/starts VM as needed. Put it cron and run every minute.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
  • Like
Reactions: sne
Option 2: using a hook script on VM 1 which would stop VM 3 if the hostname were it is started is node2 and starts VM 3 again when VM 1 is stopped or migrated back to VM 1 :)

Be careful about were you place the hook script, as it will have to be available from any node.
 
Last edited:
Does hook script get executed on VM migration between nodes? The VM is not really stopped/started in that case.
No, but even if there would be such a hook step it wouldn't trigger for HA recovery, as there we need to fence and "steal" the VMs/CTs to recover and freshly start them, which will trigger the pre-start hook where one could cover such semantics (see /usr/share/pve-docs/examples/guest-example-hookscript.pl on a PVE instance).

But, IMO you need more than two nodes for actual sensible HA anyway and if you're that over-commited in resources that you need to sacrifice a bunch of "less" important VMs it can get hairy fast and eats away time from any SLA guarantees one may need/want to uphold (stop isn't exactly zero cost/time).
 
Last edited:
  • Like
Reactions: sne and VictorSTS

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!