* [PATCH ha-manager 1/2] api: assert validity of resources param only if defined
2026-03-24 12:49 [PATCH ha-manager 0/2] fix param check for rules updates and Michael Köppl
@ 2026-03-24 12:49 ` Michael Köppl
2026-03-24 12:49 ` [PATCH ha-manager 2/2] format code with perltidy Michael Köppl
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Michael Köppl @ 2026-03-24 12:49 UTC (permalink / raw)
To: pve-devel
The check for the validity of the resources param should only be
performed if the param was even defined, since it is not a required
parameter for updating a rule. Previously, when not setting the
resources field as part of the request, the check in the assert
function would fail due to using undefined as a hash reference, which
would stop users from updating a rule.
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
src/PVE/API2/HA/Rules.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PVE/API2/HA/Rules.pm b/src/PVE/API2/HA/Rules.pm
index f09ab36..0b44d51 100644
--- a/src/PVE/API2/HA/Rules.pm
+++ b/src/PVE/API2/HA/Rules.pm
@@ -343,7 +343,7 @@ __PACKAGE__->register_method({
my $plugin = PVE::HA::Rules->lookup($type);
my $opts = $plugin->check_config($ruleid, $param, 0, 1);
- $assert_valid_resources_param->($opts->{resources});
+ $assert_valid_resources_param->($opts->{resources}) if $opts->{resources};
$assert_valid_nodes_param->($opts->{nodes}) if $opts->{nodes};
my $options = $plugin->private()->{options}->{$type};
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH ha-manager 2/2] format code with perltidy
2026-03-24 12:49 [PATCH ha-manager 0/2] fix param check for rules updates and Michael Köppl
2026-03-24 12:49 ` [PATCH ha-manager 1/2] api: assert validity of resources param only if defined Michael Köppl
@ 2026-03-24 12:49 ` Michael Köppl
2026-03-31 9:50 ` [PATCH ha-manager 0/2] fix param check for rules updates and Daniel Kral
2026-03-31 13:06 ` applied: " Thomas Lamprecht
3 siblings, 0 replies; 5+ messages in thread
From: Michael Köppl @ 2026-03-24 12:49 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
src/PVE/HA/Usage/Static.pm | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/PVE/HA/Usage/Static.pm b/src/PVE/HA/Usage/Static.pm
index 6ff2079..b60f500 100644
--- a/src/PVE/HA/Usage/Static.pm
+++ b/src/PVE/HA/Usage/Static.pm
@@ -33,8 +33,10 @@ sub add_node {
my $stats = $self->{'node-stats'}->{$nodename}
or die "did not get static node usage information for '$nodename'\n";
- die "static node usage information for '$nodename' missing cpu count\n" if !defined($stats->{maxcpu});
- die "static node usage information for '$nodename' missing memory\n" if !defined($stats->{maxmem});
+ die "static node usage information for '$nodename' missing cpu count\n"
+ if !defined($stats->{maxcpu});
+ die "static node usage information for '$nodename' missing memory\n"
+ if !defined($stats->{maxmem});
eval { $self->{scheduler}->add_node($nodename, int($stats->{maxcpu}), int($stats->{maxmem})); };
die "initializing static node usage for '$nodename' failed - $@" if $@;
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH ha-manager 0/2] fix param check for rules updates and
2026-03-24 12:49 [PATCH ha-manager 0/2] fix param check for rules updates and Michael Köppl
2026-03-24 12:49 ` [PATCH ha-manager 1/2] api: assert validity of resources param only if defined Michael Köppl
2026-03-24 12:49 ` [PATCH ha-manager 2/2] format code with perltidy Michael Köppl
@ 2026-03-31 9:50 ` Daniel Kral
2026-03-31 13:06 ` applied: " Thomas Lamprecht
3 siblings, 0 replies; 5+ messages in thread
From: Daniel Kral @ 2026-03-31 9:50 UTC (permalink / raw)
To: Michael Köppl, pve-devel
On Tue Mar 24, 2026 at 1:49 PM CET, Michael Köppl wrote:
> This series fixes the PUT API endpoint for updating a HA rule.
> Previously, it would fail if the resources parameter was not set at all
> as part of the request, even though the param is optional As part of an
> E2E test run, the error showed up as
>
> 500 update HA rules failed: Can't use an undefined value as a HASH
> reference at /usr/share/perl5/PVE/API2/HA/Rules.pm line 48.
>
> In addition, 2/2 fixes wrong formatting introduced by a recent commit.
>
> pve-ha-manager:
>
> Michael Köppl (2):
> api: assert validity of resources param only if defined
> format code with perltidy
>
> src/PVE/API2/HA/Rules.pm | 2 +-
> src/PVE/HA/Usage/Static.pm | 6 ++++--
> 2 files changed, 5 insertions(+), 3 deletions(-)
>
>
> Summary over all repositories:
> 2 files changed, 5 insertions(+), 3 deletions(-)
Yes, seems like I only tested it with (--resources, --nodes) being
- (Some(''), None),
- (Some('...'), None),
- (Some('...'), Some('')), and
- (Some('...'), Some('...')),
but not the (None, _) variant in the end, thanks for spotting and fixing
this!
The reformatting in the second patch was already done by @Thomas on
master, but the series still applies, consider as:
Reviewed-by: Daniel Kral <d.kral@proxmox.com>
Tested-by: Daniel Kral <d.kral@proxmox.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* applied: [PATCH ha-manager 0/2] fix param check for rules updates and
2026-03-24 12:49 [PATCH ha-manager 0/2] fix param check for rules updates and Michael Köppl
` (2 preceding siblings ...)
2026-03-31 9:50 ` [PATCH ha-manager 0/2] fix param check for rules updates and Daniel Kral
@ 2026-03-31 13:06 ` Thomas Lamprecht
3 siblings, 0 replies; 5+ messages in thread
From: Thomas Lamprecht @ 2026-03-31 13:06 UTC (permalink / raw)
To: pve-devel, Michael Köppl
On Tue, 24 Mar 2026 13:49:19 +0100, Michael Köppl wrote:
> This series fixes the PUT API endpoint for updating a HA rule.
> Previously, it would fail if the resources parameter was not set at all
> as part of the request, even though the param is optional As part of an
> E2E test run, the error showed up as
>
> 500 update HA rules failed: Can't use an undefined value as a HASH
> reference at /usr/share/perl5/PVE/API2/HA/Rules.pm line 48.
>
> [...]
Applied, thanks!
[1/2] api: assert validity of resources param only if defined
commit: 9e28141aac5c2b6b2dc7ea2dbdc7b0df95ffae02
[2/2] format code with perltidy
obsolete
^ permalink raw reply [flat|nested] 5+ messages in thread