* [PATCH manager 0/2] ui: fix memory usage percentage above 100% and its sorting
@ 2026-09-25 5:32 Michal Fox
2026-09-25 5:32 ` [PATCH manager 1/2] fix #6874: ui: node selectors: sort memory usage by percentage Michal Fox
2026-09-25 5:32 ` [PATCH manager 2/2] fix #7224: ui: utils: show memory usage above 100% correctly Michal Fox
0 siblings, 2 replies; 3+ messages in thread
From: Michal Fox @ 2026-09-25 5:32 UTC (permalink / raw)
To: pve-devel
the percentage renderer took any value above 1 as bytes, so a VM above
100% showed up as 0.0 % (#7224). as Fabian suggested in the bug, the two
node selectors now calculate the percentage first, which also fixes
sorting by memory in the migration dialog (#6874), and the fallback is
gone.
tested with the built pvemanagerlib.js in a browser and the numbers from
the #7224 report: 103.5 % instead of 0.0 %, and nodes with different
total memory now sort by usage
Michal Fox (2):
fix #6874: ui: node selectors: sort memory usage by percentage
fix #7224: ui: utils: show memory usage above 100% correctly
www/manager6/Utils.js | 10 ----------
www/manager6/form/NodeSelector.js | 16 ++++++++++++++--
www/manager6/ha/NodePrioritySelector.js | 14 ++++++++++++--
3 files changed, 26 insertions(+), 14 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH manager 1/2] fix #6874: ui: node selectors: sort memory usage by percentage
2026-09-25 5:32 [PATCH manager 0/2] ui: fix memory usage percentage above 100% and its sorting Michal Fox
@ 2026-09-25 5:32 ` Michal Fox
2026-09-25 5:32 ` [PATCH manager 2/2] fix #7224: ui: utils: show memory usage above 100% correctly Michal Fox
1 sibling, 0 replies; 3+ messages in thread
From: Michal Fox @ 2026-09-25 5:32 UTC (permalink / raw)
To: pve-devel
The memory usage column of the node selector, used e.g. in the
migration dialog, and of the HA node priority selector shows a
percentage, but uses the raw 'mem' bytes as data index. Sorting by that
column thus sorts by used bytes, which does not match the displayed
values as soon as the nodes have a different amount of memory.
Add a calculated 'memuse' field, like the resource store already has,
and use it for the column. This also makes the percentage renderer
receive a ratio here, like everywhere else, which allows dropping its
bytes fallback in a follow-up.
Signed-off-by: Michal Fox <me@dualfroz.com>
---
www/manager6/form/NodeSelector.js | 16 ++++++++++++++--
www/manager6/ha/NodePrioritySelector.js | 14 ++++++++++++--
2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/www/manager6/form/NodeSelector.js b/www/manager6/form/NodeSelector.js
index 37d3ee5b..73d173bb 100644
--- a/www/manager6/form/NodeSelector.js
+++ b/www/manager6/form/NodeSelector.js
@@ -16,7 +16,19 @@ Ext.define('PVE.form.NodeSelector', {
valueField: 'node',
displayField: 'node',
store: {
- fields: ['node', 'cpu', 'maxcpu', 'mem', 'maxmem', 'uptime'],
+ fields: [
+ 'node',
+ 'cpu',
+ 'maxcpu',
+ 'mem',
+ 'maxmem',
+ 'uptime',
+ {
+ name: 'memuse',
+ type: 'number',
+ calculate: PVE.Utils.calculate_mem_usage,
+ },
+ ],
proxy: {
type: 'proxmox',
url: '/api2/json/nodes',
@@ -47,7 +59,7 @@ Ext.define('PVE.form.NodeSelector', {
renderer: PVE.Utils.render_mem_usage_percent,
sortable: true,
width: 100,
- dataIndex: 'mem',
+ dataIndex: 'memuse',
},
{
header: gettext('CPU usage'),
diff --git a/www/manager6/ha/NodePrioritySelector.js b/www/manager6/ha/NodePrioritySelector.js
index 635374fd..9e26b2e0 100644
--- a/www/manager6/ha/NodePrioritySelector.js
+++ b/www/manager6/ha/NodePrioritySelector.js
@@ -23,7 +23,17 @@ Ext.define('PVE.forms.NodePrioritySelector', {
store: {
autoLoad: true,
- fields: ['node', 'cpu', 'mem', 'priority'],
+ fields: [
+ 'node',
+ 'cpu',
+ 'mem',
+ 'priority',
+ {
+ name: 'memuse',
+ type: 'number',
+ calculate: PVE.Utils.calculate_mem_usage,
+ },
+ ],
proxy: {
type: 'proxmox',
url: '/api2/json/nodes',
@@ -47,7 +57,7 @@ Ext.define('PVE.forms.NodePrioritySelector', {
renderer: PVE.Utils.render_mem_usage_percent,
sortable: true,
width: 150,
- dataIndex: 'mem',
+ dataIndex: 'memuse',
},
{
header: gettext('CPU usage'),
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH manager 2/2] fix #7224: ui: utils: show memory usage above 100% correctly
2026-09-25 5:32 [PATCH manager 0/2] ui: fix memory usage percentage above 100% and its sorting Michal Fox
2026-09-25 5:32 ` [PATCH manager 1/2] fix #6874: ui: node selectors: sort memory usage by percentage Michal Fox
@ 2026-09-25 5:32 ` Michal Fox
1 sibling, 0 replies; 3+ messages in thread
From: Michal Fox @ 2026-09-25 5:32 UTC (permalink / raw)
To: pve-devel
render_mem_usage_percent() treated any value above 1 as a byte count
and recalculated the percentage from 'mem' and 'maxmem'. But the memory
usage ratio of a guest can legitimately exceed 1, for example when the
reported usage is the host-side memory of the QEMU process, which
includes its own overhead. In the reported case, 'mem' was 2222472192
with a 'maxmem' of 2147483648, so the ratio of about 1.035 got taken as
bytes and the search and resource grids showed 0.0 % instead of 103.5 %.
All users of the renderer now pass the usage as a ratio, so drop the
bytes fallback and always render the value as percentage.
Signed-off-by: Michal Fox <me@dualfroz.com>
---
www/manager6/Utils.js | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 8b99371d..91dfd6ee 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1207,16 +1207,6 @@ Ext.define('PVE.Utils', {
if (!Ext.isNumeric(value) || value === -1) {
return '';
}
- if (value > 1) {
- // we got no percentage but bytes
- let mem = value;
- let maxmem = record.data.maxmem;
- if (!record.data.uptime || maxmem === 0 || !Ext.isNumeric(mem)) {
- return '';
- }
-
- return ((mem * 100) / maxmem).toFixed(1) + ' %';
- }
return (value * 100).toFixed(1) + ' %';
},
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-28 7:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-25 5:32 [PATCH manager 0/2] ui: fix memory usage percentage above 100% and its sorting Michal Fox
2026-09-25 5:32 ` [PATCH manager 1/2] fix #6874: ui: node selectors: sort memory usage by percentage Michal Fox
2026-09-25 5:32 ` [PATCH manager 2/2] fix #7224: ui: utils: show memory usage above 100% correctly Michal Fox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox