Reused VMID vs. API current status

lubr

New Member
May 13, 2024
11
1
3
Hi,

the thing about reusing/uniqueness of VMID have been discussed several times here. But I have found strange behavior related to API. Imagine following scenario:
1) create VM having VMID = 100 and call /api2/json/nodes/<NODE>/qemu/100/status/current => data as object are returned
2) remove VM with VMID = 100
3) create VM having VMID = 100 again and call /api2/json/nodes/<NODE>/qemu/100/status/current => data are null

But in Proxmox GUI everything seems working fine. No issues there, it is related to API only.

All on all, it seems I have to maintain a list of already used VMIDs to avoid this behavior which is ok when I am using API only to create new VM (so I can generate and pass clean VMID). Problem raises once someone (eg. Proxmox admin) will create VM inside Proxmox GUI/outside API which recommends him available VMID no matter it was used already in the past. Then the process must be automatized outside Proxmox GUI via API, such VM cloned, new clean VMID assigned and the old VM deleted. But this can happen during admin's VM setup under his hands which is not so cool.

Are there any reasons current status is not working in API on re-used VMID? Or is it a bug?
 
Hi,
1) create VM having VMID = 100 and call /api2/json/nodes/<NODE>/qemu/100/status/current => data as object are returned
2) remove VM with VMID = 100
3) create VM having VMID = 100 again and call /api2/json/nodes/<NODE>/qemu/100/status/current => data are null
What version are you using pveversion -v?

I Cannot reproduce the issue here:
Code:
root@pve8a1 ~ # qm create 9945678 && pvesh get /nodes/pve8a1/qemu/9945678/status/current
┌───────────┬───────────────┐
│ key       │ value         │
╞═══════════╪═══════════════╡
│ cpus      │ 1             │
├───────────┼───────────────┤
│ ha        │ {"managed":0} │
├───────────┼───────────────┤
│ maxdisk   │ 0.00 B        │
├───────────┼───────────────┤
│ maxmem    │ 512.00 MiB    │
├───────────┼───────────────┤
│ name      │ VM 9945678    │
├───────────┼───────────────┤
│ qmpstatus │ stopped       │
├───────────┼───────────────┤
│ status    │ stopped       │
├───────────┼───────────────┤
│ uptime    │ 0s            │
├───────────┼───────────────┤
│ vmid      │ 9945678       │
└───────────┴───────────────┘
root@pve8a1 ~ # qm destroy 9945678
root@pve8a1 ~ # qm create 9945678 && pvesh get /nodes/pve8a1/qemu/9945678/status/current
┌───────────┬───────────────┐
│ key       │ value         │
╞═══════════╪═══════════════╡
│ cpus      │ 1             │
├───────────┼───────────────┤
│ ha        │ {"managed":0} │
├───────────┼───────────────┤
│ maxdisk   │ 0.00 B        │
├───────────┼───────────────┤
│ maxmem    │ 512.00 MiB    │
├───────────┼───────────────┤
│ name      │ VM 9945678    │
├───────────┼───────────────┤
│ qmpstatus │ stopped       │
├───────────┼───────────────┤
│ status    │ stopped       │
├───────────┼───────────────┤
│ uptime    │ 0s            │
├───────────┼───────────────┤
│ vmid      │ 9945678       │
└───────────┴───────────────┘

Please share the exact sequence of commands/API calls to trigger the issue. Did you wait for the creation task to finish before querying the status?

But in Proxmox GUI everything seems working fine. No issues there, it is related to API only.
The UI uses the API, you can check in your browser's developer tools to see the relevant requests.
 
Hi. Thank you for forcing me to check API calls precisely. I had badly synced local DB with the same VMIDs for different nodes and that empty "current status" was not filled due to trying to get this status on non-existing VM being in different node in the past. My mistake, apologizes.
 
  • Like
Reactions: fiona

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!