all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH manager 1/2] fix #7589: rules: allow setting false 'disable' parameter
@ 2026-05-21 14:20 Dominik Rusovac
  2026-05-21 14:20 ` [PATCH manager 2/2] test: rules_cfg: declare explicitly not disabled rules Dominik Rusovac
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Rusovac @ 2026-05-21 14:20 UTC (permalink / raw)
  To: pve-devel

Allow setting 'disabled' parameter of rule to false via API.

Rules used to be excluded if respective 'disable' parameter did not
exist, regardless of its value. Keep a rule's 'disable' parameter and
properly check on its value.

Either of the options to disable a rule, removing 'disable' as well as
setting it to false, should work now.

Signed-off-by: Dominik Rusovac <d.rusovac@proxmox.com>
---

Notes:
    to rule out potential regressions, I modified all tests relating to
    rule_cfgs such that any enabled rule had the 'disabled' parameter
    explicitly set to 0, and verified that all of the tests passed

 src/PVE/API2/HA/Rules.pm  | 4 ----
 src/PVE/CLI/ha_manager.pm | 2 +-
 src/PVE/HA/Rules.pm       | 2 +-
 3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/PVE/API2/HA/Rules.pm b/src/PVE/API2/HA/Rules.pm
index 0b44d51..5f0ce04 100644
--- a/src/PVE/API2/HA/Rules.pm
+++ b/src/PVE/API2/HA/Rules.pm
@@ -273,8 +273,6 @@ __PACKAGE__->register_method({
         my $type = extract_param($param, 'type');
         my $ruleid = extract_param($param, 'rule');
 
-        delete $param->{disable} if !$param->{disable};
-
         my $plugin = PVE::HA::Rules->lookup($type);
 
         my $opts = $plugin->check_config($ruleid, $param, 1, 1);
@@ -325,8 +323,6 @@ __PACKAGE__->register_method({
         my $digest = extract_param($param, 'digest');
         my $delete = extract_param($param, 'delete');
 
-        delete $param->{disable} if !$param->{disable};
-
         if ($delete) {
             $delete = [PVE::Tools::split_list($delete)];
         }
diff --git a/src/PVE/CLI/ha_manager.pm b/src/PVE/CLI/ha_manager.pm
index 6625de6..cc4361f 100644
--- a/src/PVE/CLI/ha_manager.pm
+++ b/src/PVE/CLI/ha_manager.pm
@@ -259,7 +259,7 @@ our $cmddef = {
                     'enabled', 'state', 'rule', 'type', 'resources', 'comment',
                 ];
                 for my $rule (@$data) {
-                    $rule->{enabled} = int(!exists($rule->{disable}));
+                    $rule->{enabled} = int(!$rule->{disable});
                     $rule->{state} = $rule->{errors} ? 'ignored (conflicts)' : 'in use';
                 }
                 PVE::CLIFormatter::print_api_result($data, $schema, $props_to_print, $options);
diff --git a/src/PVE/HA/Rules.pm b/src/PVE/HA/Rules.pm
index 3a14eeb..90625af 100644
--- a/src/PVE/HA/Rules.pm
+++ b/src/PVE/HA/Rules.pm
@@ -563,7 +563,7 @@ sub foreach_rule {
         next if !$rule; # skip invalid rules
         next if defined($sid) && !defined($rule->{resources}->{$sid});
         next if defined($opts{type}) && $rule->{type} ne $opts{type};
-        next if $opts{exclude_disabled_rules} && exists($rule->{disable});
+        next if $opts{exclude_disabled_rules} && $rule->{disable};
 
         $func->($rule, $ruleid);
     }
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-21 14:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-21 14:20 [PATCH manager 1/2] fix #7589: rules: allow setting false 'disable' parameter Dominik Rusovac
2026-05-21 14:20 ` [PATCH manager 2/2] test: rules_cfg: declare explicitly not disabled rules Dominik Rusovac

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal