[pve-devel] [PATCH ha-manager v5 06/23] config: delete services from rules if services are deleted from config
Daniel Kral
d.kral at proxmox.com
Thu Jul 31 10:15:19 CEST 2025
On Thu Jul 31, 2025 at 6:59 AM CEST, Thomas Lamprecht wrote:
> Am 30.07.25 um 20:00 schrieb Daniel Kral:
>> Remove HA resources from rules, where these HA resources are used, if
>> they are removed by delete_service_from_config(...), which is called by
>> the HA resources' delete API endpoint and possibly external callers,
>> e.g. if the HA resource is removed externally.
>>
>> If all of the rules' HA resources have been removed, the rule itself
>> must be removed as it would result in an erroneous rules config, which
>> would become user-visible at the next read and parse of the rules
>> config.
>
> Do we the same for groups? Would be worth mentioning for such a case
> where we add new infra to replace existing one.
>
> And FWIW (definitively not a blocker), optionally keeping rules would be
> nice too, albeit since we got the "ignore" request-state for resources
> this probably doesn't really matter that much anymore, as one doesn't
> have to remove a service from HA anymore if one wants to temporarily
> control the resource directly.
Indeed for HA groups we do it the "other way" around: The HA group can
only be deleted if no HA resource references them anymore in their
config, but HA resources can be removed freely without interfering with
the HA groups.
This doesn't work as nicely for HA rules anymore, because now the nodes
and the HA resources are referenced in the HA rules config instead of
having that relationship encoded in the HA resource config and HA group
config.
This slightly changes things, as now rules do not make much sense if
there are no HA resources left in them (albeit fields like the comment,
... could still hold valuable information). I thought of it similarily
as we delete ACLs if a user/group is removed, even though that's
different because every ACL is only "owned" by one user/group.
AFAICT it shouldn't be a severe problem if a unmanaged/non-existant is
left in the HA rules config as for node affinity rules it doesn't matter
at all and for resource affinity rules it will just set the
unmanaged/non-existant ha resource's node as undef, which means that it
won't put any constraints on the other ha resources that are part of the
resource affinity rule.
Still, with your other reply in mind, it would make sense to disallow
removing a HA resource either if it's the last one in a HA rule or if
it's referenced in any HA rule. The error message would point the user
so they know that they should remove the HA resource from any HA rule
referencing them. If that's good, I'll send a follow-up patch doing just
that.
AFAICS a `--purge` option or something similar can always be added later
too if it helps the user experience.
More information about the pve-devel
mailing list