by adding the new memhost field, which is populated for VMs, and
using it if the guest is of type qemu and the field is numerical.

As a result, if the cluster is in a mixed PVE8 / PVE9 situation, for
example during a migration, we will not report any host memory usage, in
numbers or percent, as we don't get the memhost metric from the older
PVE8 hosts.

Fixes: #6068 (Node Search tab incorrect Host memory usage %)
Signed-off-by: Aaron Lauterer <[email protected]>
---
 www/manager6/Utils.js              | 6 ++++++
 www/manager6/data/ResourceStore.js | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index e403db40..57a818f6 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1160,6 +1160,9 @@ Ext.define('PVE.Utils', {
                 return -1;
             }
 
+            if (data.type === 'qemu' && Ext.isNumeric(data.memhost)) {
+                return data.memhost / maxmem;
+            }
             return data.mem / maxmem;
         },
 
@@ -1203,6 +1206,9 @@ Ext.define('PVE.Utils', {
             if (record.data.mem > 1) {
                 // we got no percentage but bytes
                 let mem = record.data.mem;
+                if (record.data.type === 'qemu' && 
Ext.isNumeric(record.data.memhost)) {
+                    mem = record.data.memhost;
+                }
                 if (!record.data.uptime || maxmem === 0 || 
!Ext.isNumeric(mem)) {
                     return '';
                 }
diff --git a/www/manager6/data/ResourceStore.js 
b/www/manager6/data/ResourceStore.js
index 13af3b4e..d1f3fb63 100644
--- a/www/manager6/data/ResourceStore.js
+++ b/www/manager6/data/ResourceStore.js
@@ -167,6 +167,14 @@ Ext.define('PVE.data.ResourceStore', {
                 hidden: true,
                 width: 100,
             },
+            memhost: {
+                header: gettext('Host Memory usage'),
+                type: 'integer',
+                renderer: PVE.Utils.render_mem_usage,
+                sortable: true,
+                hidden: true,
+                width: 100,
+            },
             memuse: {
                 header: gettext('Memory usage') + ' %',
                 type: 'number',
-- 
2.39.5



_______________________________________________
pve-devel mailing list
[email protected]
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to