Hook behaviour during VM migration

tomsiewert

Active Member
Nov 5, 2016
7
0
41
21
Germany
Hi,

I've been looking into using Hooks in my setup to announce the VM IP addresses via BGP but unfortunately, the documentation is lacking of important information such as the behaviour during a migration.
I added my hook script to one VM, started a migration and noticed that the hook already gets executed before the VM has been migrated properly. In my case it was not directly an issue, but it could get an issue if multipath-installation (ECMP) is enabled on the router.
Besides that, after the migration has been completed the pre-stop/post-stop phases were not executed on the source host which causes that the route does not get removed.
Is this an expected behaviour and if yes, is there any "opt-in feature" to run the *stop hook after a migration on the source host?

Cheers,
Tom
 
Hi,
yes, the pre-start hook will be executed when the VM instance on the target is started (needs to happen before the RAM+state can be migrated) and AFAIK the stop hooks are not executed for technical reasons, because the config file is already on the other node. There is an open feature request to add specialized migration hooks: https://bugzilla.proxmox.com/show_bug.cgi?id=1996
 
This makes sense. However, the post-start hook gets executed during the migration too which seems not to be correct.
If pre-start is called, it's only consistent that post-start is called too. It's a newly started instance (even if it will take over the state from the source instance). If you need to special-case it, you can e.g. look if the config file is not on the current node to detect if the hook got called as part of the migration.

We can't change this behavior (at least not until a major release), because people might already be relying on it ;) But we could introduce new hooks which is what the feature request is about.
 

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!