Dedup VMs across real Proxmox cluster nodes (was listing each VM once per entered host)

This commit is contained in:
2026-07-06 20:02:57 +02:00
parent 7fbac7c18a
commit 0968468978
3 changed files with 35 additions and 2 deletions
+24 -1
View File
@@ -153,7 +153,30 @@ ipcMain.handle('proxmox:login', async (_e, { host, username, password }) => {
return { success: false, error: attempts[0].error };
}
clients = succeeded;
// Several hostnames can point at nodes of the SAME real Proxmox cluster
// (e.g. Stefan's setup) — in that case /cluster/resources returns the
// identical cluster-wide VM list from every one of them, so keeping all
// logged-in clients would just show each VM 3x. Detect real cluster
// membership and keep only one representative client per cluster.
const seenGroups = new Set();
const dedupedClients = [];
await Promise.all(
succeeded.map(async (entry) => {
try {
entry.clusterId = await entry.client.getClusterId();
} catch {
entry.clusterId = null;
}
})
);
for (const entry of succeeded) {
const group = entry.clusterId || `standalone:${entry.host}`;
if (seenGroups.has(group)) continue;
seenGroups.add(group);
dedupedClients.push(entry);
}
clients = dedupedClients;
createWindow('vms.html', 680, 520, true);
if (failed.length > 0) {