Skip to content

Commit 1e33f09

Browse files
committed
fix(overview): all-clusters overview + cluster-detail now agree on CPU & guest counts
The all-clusters overview and the cluster-detail summary cards disagreed: - CPU: overview used core-weighted cluster CPU (Σ cpu×cores / Σ cores, from datacenter/status); detail used a plain per-node average -> e.g. 6% vs 7.6%. - Guest counts: overview total = running+stopped from the polled guests summary, which drops paused/suspended guests and could transiently render an impossible '16 / 14' (total < running); the detail counted all qemu+lxc -> '16 / 30'. Fixes: - backend datacenter/status: add explicit per-type guest totals (guests.vms.total / guests.containers.total = every guest of that type, any status incl. templates) so the overview denominator equals the detail's allVms.length and can never be < running. (proxmox + xcpng paths) - overview (AllClustersOverview + the cluster-group variant): use the explicit total when present, fall back to running+stopped for older backends. - detail summary cards: read the core-weighted CPU from datacenter/status (same source as the overview), falling back to the per-node average until it loads. Verified live vs the Testi cluster: overview 16/30 == detail 16/30, and both CPU values now derive from a single source. Rebuilt web/index.html.
1 parent daa50fc commit 1e33f09

4 files changed

Lines changed: 39 additions & 9 deletions

File tree

pegaprox/api/vms.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def get_datacenter_status(cluster_id):
134134
return jsonify({
135135
'cluster': {'name': manager.config.name, 'quorate': None, 'standalone': False, 'version': 0, 'cluster_type': 'xcpng'},
136136
'nodes': {'online': nodes_online, 'offline': len(nodes) - nodes_online, 'total': len(nodes)},
137-
'guests': {'vms': {'running': vms_running, 'stopped': vms_stopped}, 'containers': {'running': 0, 'stopped': 0}},
137+
'guests': {'vms': {'running': vms_running, 'stopped': vms_stopped, 'total': len(vms)}, 'containers': {'running': 0, 'stopped': 0, 'total': 0}},
138138
'resources': {
139139
'cpu': {'total': st.get('total_cpu', 0), 'used': 0, 'percent': 0},
140140
'memory': {'total': st.get('total_mem', 0), 'used': st.get('used_mem', 0), 'percent': round(st['used_mem'] / st['total_mem'] * 100, 1) if st.get('total_mem') else 0},
@@ -190,6 +190,11 @@ def get_datacenter_status(cluster_id):
190190
vms_stopped = sum(1 for r in resources_data if r.get('type') == 'qemu' and r.get('status') == 'stopped')
191191
cts_running = sum(1 for r in resources_data if r.get('type') == 'lxc' and r.get('status') == 'running')
192192
cts_stopped = sum(1 for r in resources_data if r.get('type') == 'lxc' and r.get('status') == 'stopped')
193+
# NS #618-followup: explicit per-type totals count EVERY guest (running, stopped,
194+
# paused/suspended, templates) so the all-clusters overview denominator matches
195+
# the cluster-detail 'allVms.length' and can never render total < running.
196+
vms_total = sum(1 for r in resources_data if r.get('type') == 'qemu')
197+
cts_total = sum(1 for r in resources_data if r.get('type') == 'lxc')
193198

194199
# Calculate total resources
195200
total_cpu = sum(r.get('maxcpu', 0) for r in resources_data if r.get('type') == 'node')
@@ -241,8 +246,8 @@ def get_datacenter_status(cluster_id):
241246
'total': nodes_online + nodes_offline
242247
},
243248
'guests': {
244-
'vms': {'running': vms_running, 'stopped': vms_stopped},
245-
'containers': {'running': cts_running, 'stopped': cts_stopped}
249+
'vms': {'running': vms_running, 'stopped': vms_stopped, 'total': vms_total},
250+
'containers': {'running': cts_running, 'stopped': cts_stopped, 'total': cts_total}
246251
},
247252
'resources': {
248253
'cpu': {'total': total_cpu, 'used': used_cpu, 'percent': round(used_cpu / total_cpu * 100, 1) if total_cpu > 0 else 0},

0 commit comments

Comments
 (0)