detect if VM/CT migration is running

freebeerz

Renowned Member
Aug 5, 2015
16
2
68
Hi,

Is there a way to detect if a VM or CT migration is running, using the CLI or API?

I'm writing an ansible playbook to do rolling updates for a proxmox cluster, the idea is to loop through each node in sequence:

- move a node to maintenance
- wait for VM/CT evictions to another node
- update the node
- reboot
- wait for cluster full quorum votes
- wait for final migration of any VM/CT back to the node
- loop to next node

I'm missing the bit to detect running migrations...

Thanks!
 
Last edited:
Hi,

Is there a way to detect if a VM or CT migration is running, using the CLI or API?
you can look at the currently running tasks in the cluster, via the /cluster/tasks endpoint.

From there you will receive a list of tasks, which you can filter by their type key, which will be qmigrate or vzmigrate for VM and CT migrations, respectively. Currently running tasks (= active migrations) additionally have a pid key.

E.g. a simple example using pvesh and jq:
Code:
pvesh get /cluster/tasks --output-format json | jq '.[] | select(.pid != null) | select(.type == "qmigrate" or .type == "vzmigrate")'
 
  • Like
Reactions: freebeerz and fba