From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id D51DC1FF13F for ; Thu, 21 May 2026 16:21:23 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A10421AECB; Thu, 21 May 2026 16:21:23 +0200 (CEST) From: Dominik Rusovac To: pve-devel@lists.proxmox.com Subject: [PATCH manager 1/2] fix #7589: rules: allow setting false 'disable' parameter Date: Thu, 21 May 2026 16:20:44 +0200 Message-ID: <20260521142045.1131408-1-d.rusovac@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1779373233174 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.321 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 4JEMQLFDV2RKOYFXJW4KWXMYMKT73ACK X-Message-ID-Hash: 4JEMQLFDV2RKOYFXJW4KWXMYMKT73ACK X-MailFrom: d.rusovac@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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