From: Dominik Rusovac <d.rusovac@proxmox.com>
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 [thread overview]
Message-ID: <20260521142045.1131408-1-d.rusovac@proxmox.com> (raw)
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
next reply other threads:[~2026-05-21 14:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 14:20 Dominik Rusovac [this message]
2026-05-21 14:20 ` [PATCH manager 2/2] test: rules_cfg: declare explicitly not disabled rules Dominik Rusovac
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260521142045.1131408-1-d.rusovac@proxmox.com \
--to=d.rusovac@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.