From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 4FA2E1FF179 for ; Wed, 1 Oct 2025 16:02:54 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A6D6F20840; Wed, 1 Oct 2025 16:02:59 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Wed, 1 Oct 2025 16:02:46 +0200 Message-ID: <20251001140253.121445-2-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251001140253.121445-1-f.ebner@proxmox.com> References: <20251001140253.121445-1-f.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1759327354376 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.021 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [resources.pm, config.pm, proxmox.com] Subject: [pve-devel] [PATCH ha-manager 1/1] api: relocate/migrate resource: improve initialization of variables to avoid Perl warning X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" As reported in the community forum [0], the resource relocation endpoint would produce a warning: > Can't use an undefined value as an ARRAY reference In the get_resource_motion_info() function, properly initialize the array references in the $blocking_resources_by_node hash to avoid this. Note that the migration endpoint needs to be adapted to only include 'blocking-resources' in the result if there is at least one entry in the array to be compatible with this change. Align the behavior of both migration and relocation endpoints, so that the migration endpoint correctly handles the initialized, but empty array too. Alternatively, it could've been done the other way with the relocation endpoint also checking for the array reference to be undefined if no entries are to be added to the array, but since $comigrated_resources is also initialized when empty, it seemed cleaner to go with the approach here. [0]: https://forum.proxmox.com/threads/173149/ Signed-off-by: Fiona Ebner --- src/PVE/API2/HA/Resources.pm | 2 +- src/PVE/HA/Config.pm | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PVE/API2/HA/Resources.pm b/src/PVE/API2/HA/Resources.pm index 894fe90..aadddab 100644 --- a/src/PVE/API2/HA/Resources.pm +++ b/src/PVE/API2/HA/Resources.pm @@ -393,7 +393,7 @@ __PACKAGE__->register_method({ my $blocking_resources = $blocking_resources_by_node->{$req_node}; $result->{'comigrated-resources'} = $comigrated_resources if @$comigrated_resources; - $result->{'blocking-resources'} = $blocking_resources if $blocking_resources; + $result->{'blocking-resources'} = $blocking_resources if @$blocking_resources; return $result; }, diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm index 301c62f..b52465f 100644 --- a/src/PVE/HA/Config.pm +++ b/src/PVE/HA/Config.pm @@ -397,6 +397,7 @@ sub get_resource_motion_info { push @$dependent_resources, $_ for sort keys %$together; for my $node (keys %$ns) { + $blocking_resources_by_node->{$node} = []; next if $ns->{$node} ne 'online'; for my $csid (sort keys %$separate) { -- 2.47.3 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel