[pve-devel] [PATCH ha-manager v5 06/23] config: delete services from rules if services are deleted from config

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Jul 31 07:03:17 CEST 2025


Am 30.07.25 um 20:00 schrieb Daniel Kral:

> diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm
> index 012ae16d..2e520aab 100644
> --- a/src/PVE/HA/Config.pm
> +++ b/src/PVE/HA/Config.pm
> @@ -360,6 +360,25 @@ sub delete_service_from_config {
>          "delete resource failed",
>      );
>  
> +    PVE::HA::Config::lock_ha_domain(
> +        sub {

this is racy though? To be more robust it should happen with the same domain
lock callback as the the service deletion. And the more I think about this
the more I'm sure that this needs to be at least opt-out, and it would be 
nice to have some rationale for why this is done.


> +            my $rules = read_rules_config();
> +
> +            return if !defined($rules->{ids});
> +
> +            for my $ruleid (keys %{ $rules->{ids} }) {
> +                my $rule_resources = $rules->{ids}->{$ruleid}->{resources} // {};
> +
> +                delete $rule_resources->{$sid};
> +
> +                delete $rules->{ids}->{$ruleid} if !%$rule_resources;
> +            }
> +
> +            write_rules_config($rules);
> +        },
> +        "delete resource from rules failed",
> +    );
> +
>      return !!$res;
>  }
>  





More information about the pve-devel mailing list