* [PATCH ha-manager] resources: fix type confusion regression for static stats
@ 2026-03-25 15:06 Fiona Ebner
2026-03-26 8:02 ` applied: " Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Fiona Ebner @ 2026-03-25 15:06 UTC (permalink / raw)
To: pve-devel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* applied: [PATCH ha-manager] resources: fix type confusion regression for static stats
2026-03-25 15:06 [PATCH ha-manager] resources: fix type confusion regression for static stats Fiona Ebner
@ 2026-03-26 8:02 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2026-03-26 8:02 UTC (permalink / raw)
To: pve-devel, Fiona Ebner
On Wed, 25 Mar 2026 16:06:18 +0100, Fiona Ebner wrote:
> 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:
>
> [...]
Applied, thanks!
[1/1] resources: fix type confusion regression for static stats
commit: 8328cd271652eb55c42f09df092914ef93e8bcef
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-26 8:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-25 15:06 [PATCH ha-manager] resources: fix type confusion regression for static stats Fiona Ebner
2026-03-26 8:02 ` applied: " Thomas Lamprecht
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.