all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Lukas Sichert <l.sichert@proxmox.com>
To: pdm-devel@lists.proxmox.com
Cc: Lukas Sichert <l.sichert@proxmox.com>
Subject: [PATCH datacenter-manager 4/4] fix #7135: ui: correct calculations for shared storages
Date: Mon,  2 Mar 2026 14:45:37 +0100	[thread overview]
Message-ID: <20260302134537.108696-5-l.sichert@proxmox.com> (raw)
In-Reply-To: <20260302134537.108696-1-l.sichert@proxmox.com>

Currently the storage calculation for a cluster in the
datacenter-manager is incorrect when a shared storage is involved. Each
node reports the shared storage separately, causing it to be counted
multiple times in the total capacity.

To be able to handle shared storages correctly, introduce a `shared`
field to PveStorageResource and parse it from the API-Resonse. After
that use the field and the storage name to only count the shared storage
once. This also aligns pdm storage calculation with the one in the
pve-frontend.

Signed-off-by: Lukas Sichert <l.sichert@proxmox.com>
---
 cli/client/src/resources.rs       | 1 +
 lib/pdm-api-types/src/resource.rs | 2 ++
 server/src/api/resources.rs       | 1 +
 server/src/views/tests.rs         | 1 +
 ui/src/pve/remote_overview.rs     | 9 +++++++--
 5 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/cli/client/src/resources.rs b/cli/client/src/resources.rs
index 9b91a4b..74763bf 100644
--- a/cli/client/src/resources.rs
+++ b/cli/client/src/resources.rs
@@ -85,6 +85,7 @@ impl fmt::Display for PrintResource<resource::PveStorageResource> {
             disk,
             maxdisk,
             id: _,
+            shared: _,
             ref storage,
             ref node,
             ref status,
diff --git a/lib/pdm-api-types/src/resource.rs b/lib/pdm-api-types/src/resource.rs
index 93f8bd2..b68777c 100644
--- a/lib/pdm-api-types/src/resource.rs
+++ b/lib/pdm-api-types/src/resource.rs
@@ -355,6 +355,8 @@ pub struct PveStorageResource {
     pub node: String,
     /// Storage status
     pub status: String,
+    /// shared flag
+    pub shared: bool,
 }
 
 #[api]
diff --git a/server/src/api/resources.rs b/server/src/api/resources.rs
index 5d5fe2c..a966109 100644
--- a/server/src/api/resources.rs
+++ b/server/src/api/resources.rs
@@ -1135,6 +1135,7 @@ pub(super) fn map_pve_storage(
             storage: resource.storage.unwrap_or_default(),
             node: resource.node.unwrap_or_default(),
             status: resource.status.unwrap_or_default(),
+            shared: resource.shared.unwrap_or_default(),
         }),
         _ => None,
     }
diff --git a/server/src/views/tests.rs b/server/src/views/tests.rs
index 9f49620..b8c63b4 100644
--- a/server/src/views/tests.rs
+++ b/server/src/views/tests.rs
@@ -14,6 +14,7 @@ fn make_storage_resource(remote: &str, node: &str, storage_name: &str) -> Resour
         storage: storage_name.into(),
         node: node.into(),
         status: "available".into(),
+        shared: false,
     })
 }
 
diff --git a/ui/src/pve/remote_overview.rs b/ui/src/pve/remote_overview.rs
index e452131..5b63539 100644
--- a/ui/src/pve/remote_overview.rs
+++ b/ui/src/pve/remote_overview.rs
@@ -1,3 +1,4 @@
+use std::collections::HashSet;
 use std::rc::Rc;
 
 use proxmox_yew_comp::{Status, StatusRow};
@@ -72,12 +73,16 @@ impl RemotePanelComp {
         let mut nodes = 0;
         let mut cpu_usage = 0.0;
         let mut level = None;
+        let mut seen_shared_storages: HashSet<String> = HashSet::new();
 
         for res in ctx.props().resources.iter() {
             match res {
                 PveResource::Storage(store) => {
-                    storage += store.disk;
-                    max_storage += store.maxdisk;
+                    let storage_name = store.storage.clone();
+                    if seen_shared_storages.insert(storage_name) {
+                        storage += store.disk;
+                        max_storage += store.maxdisk;
+                    }
                 }
                 PveResource::Qemu(qemu) => {
                     guests += 1;
-- 
2.47.3




      parent reply	other threads:[~2026-03-02 13:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-02 13:45 [PATCH api-types/manager/datacenter-manager 0/4] fix #7315: datacenter-manager: fix wrong calculation of total storage Lukas Sichert
2026-03-02 13:45 ` [PATCH proxmox 1/4] fix #7315: generate: add support for new certificate variant Lukas Sichert
2026-03-02 13:45 ` SPAM: [PATCH proxmox 2/4] fix #7315: run make refresh Lukas Sichert
2026-03-02 13:45 ` [PATCH manager 3/4] fix #7315: types: add missing storage flag to json schema Lukas Sichert
2026-03-02 13:51   ` Dominik Rusovac
2026-03-02 13:45 ` Lukas Sichert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260302134537.108696-5-l.sichert@proxmox.com \
    --to=l.sichert@proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal