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 51B291FF13B for ; Wed, 25 Mar 2026 16:06:43 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5AD981DFB9; Wed, 25 Mar 2026 16:07:02 +0100 (CET) From: Fiona Ebner To: pve-devel@lists.proxmox.com Subject: [PATCH ha-manager] resources: fix type confusion regression for static stats Date: Wed, 25 Mar 2026 16:06:18 +0100 Message-ID: <20260325150624.467936-1-f.ebner@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: 1774451139820 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.003 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 Message-ID-Hash: 6BAXTQWAZN2HMGNYFU3R6YZ6QMUJ34VO X-Message-ID-Hash: 6BAXTQWAZN2HMGNYFU3R6YZ6QMUJ34VO X-MailFrom: f.ebner@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: Adding a container with an explicit number of 'cores' in the configuration would fail with an error like: > unable to add service 'ct:105' usage to node 'pve9a2' > - error: invalid type: string "4", expected f64 Commit a299f1a ("move static service stats repository to PVE::HA::Usage::Static") accidentally broke this by removing the following hunk without adding new type coercions: > - my $service_stats = { > - maxcpu => $stats->{maxcpu} + 0.0, # containers allow non-integer cpulimit > - maxmem => int($stats->{maxmem}), > - }; Fixes: a299f1a ("move static service stats repository to PVE::HA::Usage::Static") Signed-off-by: Fiona Ebner --- src/PVE/HA/Resources/PVECT.pm | 6 ++++-- src/PVE/HA/Resources/PVEVM.pm | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/PVE/HA/Resources/PVECT.pm b/src/PVE/HA/Resources/PVECT.pm index 79bb7c8..0943d5e 100644 --- a/src/PVE/HA/Resources/PVECT.pm +++ b/src/PVE/HA/Resources/PVECT.pm @@ -162,9 +162,11 @@ sub remove_locks { sub get_static_stats_from_config { my ($class, $conf) = @_; + # Ensure types are compatible with what Rust expects: f64 for maxcpu and usize for maxmem. + # Note that there might be a non-integer 'cpulimit'. return { - maxcpu => PVE::LXC::Config->get_derived_property($conf, 'max-cpu'), - maxmem => PVE::LXC::Config->get_derived_property($conf, 'max-memory'), + maxcpu => 0.0 + PVE::LXC::Config->get_derived_property($conf, 'max-cpu'), + maxmem => int(PVE::LXC::Config->get_derived_property($conf, 'max-memory')), }; } diff --git a/src/PVE/HA/Resources/PVEVM.pm b/src/PVE/HA/Resources/PVEVM.pm index 5a0ac34..1621c15 100644 --- a/src/PVE/HA/Resources/PVEVM.pm +++ b/src/PVE/HA/Resources/PVEVM.pm @@ -183,9 +183,10 @@ sub remove_locks { sub get_static_stats_from_config { my ($class, $conf) = @_; + # Ensure types are compatible with what Rust expects: f64 for maxcpu and usize for maxmem. return { - maxcpu => PVE::QemuConfig->get_derived_property($conf, 'max-cpu'), - maxmem => PVE::QemuConfig->get_derived_property($conf, 'max-memory'), + maxcpu => 0.0 + PVE::QemuConfig->get_derived_property($conf, 'max-cpu'), + maxmem => int(PVE::QemuConfig->get_derived_property($conf, 'max-memory')), }; } -- 2.47.3