[pve-devel] [PATCH ha-manager v2 23/26] api: introduce ha rules api endpoints

Michael Köppl m.koeppl at proxmox.com
Fri Jul 4 16:16:36 CEST 2025


On 6/20/25 16:31, Daniel Kral wrote:
> +my $check_feasibility = sub {
> +    my ($rules) = @_;
> +
> +    $rules = dclone($rules);
> +
> +    # set optional rule parameter's default values
> +    for my $rule (values %{ $rules->{ids} }) {
> +        PVE::HA::Rules->set_rule_defaults($rule);
> +    }
> +
> +    # TODO PVE 10: Remove group migration when HA groups have been fully migrated to location rules
> +    if (!PVE::HA::Config::is_ha_location_enabled()) {
> +        my $groups = PVE::HA::Config::read_group_config();
> +        my $services = PVE::HA::Config::read_and_check_resources_config();
> +
> +        PVE::HA::Rules::Location::delete_location_rules($rules);
> +        PVE::HA::Groups::migrate_groups_to_rules($rules, $groups, $services);
> +    }
> +
> +    return PVE::HA::Rules->check_feasibility($rules);
> +};
> +
> +my $assert_feasibility = sub {
> +    my ($rules, $ruleid) = @_;
> +
> +    my $global_errors = $check_feasibility->($rules);
> +    my $rule_errors = $global_errors->{$ruleid};
> +
> +    return if !$rule_errors;

Consider the following scenario: I have a colocation rule with vm:100
and vm:101 together and a location rule for vm:100 and node1. I would
still be able to add another location rule for vm:101 and node2 because
$global_errors would contain an error for the colocation rule, but
$rule_errors would still be empty as it's strictly speaking not an error
for the location rule I just created and its ID is not contained in
$global_errors.

>From a technical standpoint this makes sense, but from a user's
perspective I found this a bit confusing, as whether or not I received
an error dialog upon creation which also stopped me from creating a
contradictory rule depended on the order in which I create said rules.

I understand that, at the moment, location rules trump colocation rules
in this regard and as long as the colocation rule is disabled and
displays a warning as a result of such a scenario, I don't see a problem
with it. Just wanted to note this as a potential future improvement.




More information about the pve-devel mailing list