From: Fiona Ebner <f.ebner@proxmox.com>
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 [thread overview]
Message-ID: <20260325150624.467936-1-f.ebner@proxmox.com> (raw)
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 <f.ebner@proxmox.com>
---
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
next reply other threads:[~2026-03-25 15:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-25 15:06 Fiona Ebner [this message]
2026-03-26 8:02 ` applied: " Thomas Lamprecht
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=20260325150624.467936-1-f.ebner@proxmox.com \
--to=f.ebner@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox