Hello,
With Proxmox 8.x it was possible to add a VM, e.g. with ID "1023", to an HA group via HTTP POST to "cluster/ha/resources"
to the group "mygroup" with the following body:
With Proxmox 9.x this doesn't work because HA groups no longer exist, but rather HA Affinity Rules.
As far as I can see, you first need to register a VM as an HA resource.
This requires an HTTP POST to "cluster/ha/resources" with the following body as an example:
After that, you still need to add the VM to the corresponding HA Affinity Rule.
This requires an HTTP PUT to "cluster/ha/rules/mygroup" with the following body as an example:
That works. The problem is that I have to provide all VMs in "resources" with this PUT.
So you would first need to determine via HTTP GET what's currently in "resources",
add VM 1023, and then do the HTTP PUT.
But that's not atomic:
What if someone has modified the resources of this Affinity Rule after the HTTP GET but before the HTTP PUT?
To clarify this further, here's a scenario:
Additionally, Proxmox itself also modifies the Affinity Rule (e.g., when deleting a VM?).
So even if you had Systems A and B under control (e.g., both systems use their own Affinity Rule instead of sharing one),
you wouldn't find a clean solution with Proxmox itself.
-> With 2 calls "read and then write" it's never clean from my perspective and always leads to problems, as it's not atomic.
What is the API call to simply add a VM to an Affinity Rule?
What I've already tested is making an HTTP POST instead of an HTTP PUT.
But POST doesn't seem to exist ("status code: 501, reason phrase: Method 'POST /cluster/ha/rules/mygroup' not implemented")
I can't imagine that this capability doesn't exist.
Especially with larger or more complex installations, these are basic requirements that such operations must be atomic,
so I can't imagine that this call doesn't exist.
Thanks
Regards
With Proxmox 8.x it was possible to add a VM, e.g. with ID "1023", to an HA group via HTTP POST to "cluster/ha/resources"
to the group "mygroup" with the following body:
{"sid":"vm:1023","group":"mygroup"}
With Proxmox 9.x this doesn't work because HA groups no longer exist, but rather HA Affinity Rules.
As far as I can see, you first need to register a VM as an HA resource.
This requires an HTTP POST to "cluster/ha/resources" with the following body as an example:
{"sid":"vm:1023"}
After that, you still need to add the VM to the corresponding HA Affinity Rule.
This requires an HTTP PUT to "cluster/ha/rules/mygroup" with the following body as an example:
{"resources":"vm:1023","type":"node-affinity"}
That works. The problem is that I have to provide all VMs in "resources" with this PUT.
So you would first need to determine via HTTP GET what's currently in "resources",
add VM 1023, and then do the HTTP PUT.
But that's not atomic:
What if someone has modified the resources of this Affinity Rule after the HTTP GET but before the HTTP PUT?
To clarify this further, here's a scenario:
System A wants to add VM 23 and System B wants to add VM 42.
System A makes an HTTP GET
System B makes an HTTP GET
System A makes an HTTP PUT and adds VM 23 to the list of "resources"
System B makes an HTTP PUT and adds VM 42 to the list of "resources"
-> VM 23 is now not in the Affinity Rule.
Additionally, Proxmox itself also modifies the Affinity Rule (e.g., when deleting a VM?).
So even if you had Systems A and B under control (e.g., both systems use their own Affinity Rule instead of sharing one),
you wouldn't find a clean solution with Proxmox itself.
-> With 2 calls "read and then write" it's never clean from my perspective and always leads to problems, as it's not atomic.
What is the API call to simply add a VM to an Affinity Rule?
What I've already tested is making an HTTP POST instead of an HTTP PUT.
But POST doesn't seem to exist ("status code: 501, reason phrase: Method 'POST /cluster/ha/rules/mygroup' not implemented")
I can't imagine that this capability doesn't exist.
Especially with larger or more complex installations, these are basic requirements that such operations must be atomic,
so I can't imagine that this call doesn't exist.
Thanks
Regards