[Feature] Add an option to disable negative ressource affinity rules while doing rolling updates
Describe the feature
Pegaprox 1.2.0
Pegaprox puts nodes in maintenance mode during rolling updates and waits for the nodes to be evacuated. When you have negative resource affinity rules you can run into this:
Requesting HA migration for VM 10002 to node ber1-srv-pve1
cannot migrate resource 'vm:10002' to node 'ber1-srv-pve1':
- resource 'vm:10003' on target node 'ber1-srv-pve1' in negative affinity with resource 'vm:10002'
TASK ERROR: command 'ha-manager migrate vm:10002 ber1-srv-pve1' failed: exit code 2
Of course this can only happen when you have as much VMs in the rule as you have nodes.
I would like Pegaprox to offer an option "disable negative resource affinity rules during rolling updates".
If that option is set I would like Pegaprox to do something like
ha-manager rules config --output-format json-pretty | jq -r '.[] | select(.affinity == "negative" and .enabled == 1) | .rule'
to build a list of matching rule IDs and persist them. It should then loop over these rules and do
ha-manager rules set $rule --disable 1
In the end (successful or not) it should re-enable this list of rules:
ha-manager rules set $rule --enabled 1
This should be the persisted list of matching rule IDs because after disabling them you can't get the list of rule IDs to re-enable.
Use Case
Doing a rolling update with negative resource affinity rules runs into:
[07:48:02] ✗ Failed: openacs (VMID: 10002)
[07:48:02] ⏸️ PAUSED - Waiting for user action.
The workaround would be to disable negative resource affinity rules before starting the rolling update and later re-enable them. But that can become a tedious task if there are a lot of rules.
Alternatives considered
Yes, as mentioned above.
How important is this for you?
Would improve my workflow
Checklist
- [x] I have searched existing issues and discussions to make sure this hasn't been requested before
- [x] I understand this is a wishlist and not a work order — volunteers decide what gets built, and when
- [x] I'm aware that "this should be easy, it's only a few lines" has never once turned out to be true 🪄
Real gap, and worth saying clearly: PegaProx has its own affinity rules (its own table, its own checks on our migration paths) and never touches PVE's native HA rules at all. So what you're hitting is ha-manager refusing the migration entirely, and nothing on our side currently knows those rules exist. Two different concepts with the same name, which doesn't help.
Checked a 9.2 cluster here rather than guessing: /cluster/ha/rules answers 200, and /cluster/ha/groups now returns 500 with "ha groups have been migrated to rules". So this can go over the API instead of shelling ha-manager over SSH — which matters, because SSH to a cluster can be switched off and plenty of setups authenticate with an API token. Older PVE will need the groups-era path handled separately.
Your persistence point is the important half, and I'd sharpen it: the saved list has to survive a PegaProx restart, not just live in memory for the run. If the process dies between disabling and re-enabling, negative affinity stays off across the whole cluster and nobody finds out until something co-locates that shouldn't. Re-enabling needs to happen on startup recovery too, not only at the end of a successful run — otherwise the cure is worse than the tedium.
Noted and passed to Nico, it's his call on shape since it's a new integration rather than a tweak.
Unrelated: if PegaProx saves you time at work, https://opencollective.com/pegaprox is where the hosting comes from. No obligation whatsoever.
Marcus
Checked a 9.2 cluster here rather than guessing:
/cluster/ha/rulesanswers 200, and/cluster/ha/groupsnow returns 500 with "ha groups have been migrated to rules". So this can go over the API instead of shellingha-managerover SSH — which matters, because SSH to a cluster can be switched off and plenty of setups authenticate with an API token. Older PVE will need the groups-era path handled separately.
This might be a misunderstanding: of course it is much better to use the API than SSH and actually I wouldn't want Pegaprox to SSH into Proxmox. The shell commands I posted are not more than a proof of concept.
I'm not so sure what to think about Pegaprox affinity rules. Did they exist before Proxmox implemented them? Because it looks like a duplicate Feature to me.
No misunderstanding, I read your commands as a proof of concept. I only spelled the API bit out because it decides where the feature has to live, not because I thought you were proposing to shell out.
On the duplicate question, fair one, and the honest answer is: partly. Ours predate Proxmox's. The affinity_rules table shipped in 0.9.0 back in February, well before PVE 9 grew native HA rules. They also do a different job. Ours are enforced by our own balancer and evacuation paths, which is what lets them apply to XCP-ng and ESXi clusters too, where there is no ha-manager to ask. PVE's drive the PVE HA manager, which is exactly the thing you want paused during a rolling update.
So since PVE 9 there is overlap for Proxmox-only setups, no point pretending otherwise. What there is not is a way for us to see or touch the native ones, which is the gap your report is really about.
Marcus
Rolling updates now have an option to let negative resource-affinity rules give way. When it is on, PegaProx saves the list of enabled negative Proxmox HA rules, switches them off over the API before the first evacuation and switches them back on when the run ends, whether it completed, failed or was cancelled, and also after a restart. The same option is available for scheduled runs and node maintenance, and it ships in 1.3.0.
If this one made your week easier, https://opencollective.com/pegaprox is where the project gets its funding.
Marcus