all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH datacenter-manager v3 3/6] lib/api: add new 'remote-list' info to the resource status
Date: Fri, 22 May 2026 10:34:04 +0200	[thread overview]
Message-ID: <20260522083412.1223719-9-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260522083412.1223719-1-d.csapak@proxmox.com>

this will be used to show more status information for each remote
on the views. Put it there since we have many infos to aggregate a
status and we have to iterate over the remotes anyway here.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 lib/pdm-api-types/src/resource.rs | 51 +++++++++++++++++++++++++++++++
 server/src/api/resources.rs       | 39 ++++++++++++++++++++---
 2 files changed, 85 insertions(+), 5 deletions(-)

diff --git a/lib/pdm-api-types/src/resource.rs b/lib/pdm-api-types/src/resource.rs
index 99a86364..120dcc03 100644
--- a/lib/pdm-api-types/src/resource.rs
+++ b/lib/pdm-api-types/src/resource.rs
@@ -701,6 +701,12 @@ pub struct CpuStatistics {
             items: {
                 type: FailedRemote,
             },
+        },
+        "remote-list": {
+            type: Array,
+            items: {
+                type: RemoteInfo,
+            },
         }
     }
 )]
@@ -741,6 +747,51 @@ pub struct ResourcesStatus {
     /// List of the failed remotes including type and error
     #[serde(default, skip_serializing_if = "Vec::is_empty")]
     pub failed_remotes_list: Vec<FailedRemote>,
+
+    /// List of remote info
+    #[serde(default, skip_serializing_if = "Vec::is_empty")]
+    #[serde(rename = "remote-list")]
+    pub remote_list: Vec<RemoteInfo>,
+}
+
+#[api]
+#[derive(Clone, PartialEq, Serialize, Deserialize, Default)]
+/// Basic remote status
+pub enum RemoteStatus {
+    /// Remote is healthy and reachable
+    Good,
+    /// Remote has at least one (non-fatal) issue
+    Warning,
+    /// Remote can't be reached or has a fatal error
+    Error,
+    #[default]
+    /// Unknown status of a remote
+    Unknown,
+}
+
+#[api(
+    properties: {
+        messages: {
+            type: Array,
+            items: {
+                description: "A warning or error message",
+                type: String,
+            },
+        },
+    },
+)]
+#[derive(Clone, PartialEq, Serialize, Deserialize, Default)]
+/// Basic information about a remote
+pub struct RemoteInfo {
+    /// The name of the remote
+    pub name: String,
+    /// The type of remote
+    pub ty: RemoteType,
+    #[serde(default, skip_serializing_if = "Vec::is_empty")]
+    /// The error or warning messages when the state is not good.
+    pub messages: Vec<String>,
+    /// The overall status of the remote
+    pub status: RemoteStatus,
 }
 
 #[api]
diff --git a/server/src/api/resources.rs b/server/src/api/resources.rs
index 9ec1ce89..e21fa90d 100644
--- a/server/src/api/resources.rs
+++ b/server/src/api/resources.rs
@@ -12,8 +12,8 @@ use pdm_api_types::remotes::{Remote, RemoteType};
 use pdm_api_types::resource::{
     FailedRemote, NetworkFabricResource, NetworkZoneResource, PbsDatastoreResource,
     PbsNodeResource, PveLxcResource, PveNetworkResource, PveNodeResource, PveQemuResource,
-    PveStorageResource, RemoteResources, Resource, ResourceType, ResourcesStatus, SdnStatus,
-    TopEntities, PBS_DATASTORE_HIGH_USAGE_THRESHOLD,
+    PveStorageResource, RemoteInfo, RemoteResources, RemoteStatus, Resource, ResourceType,
+    ResourcesStatus, SdnStatus, TopEntities, PBS_DATASTORE_HIGH_USAGE_THRESHOLD,
 };
 use pdm_api_types::subscription::{
     NodeSubscriptionInfo, RemoteSubscriptionState, RemoteSubscriptions, SubscriptionLevel,
@@ -497,16 +497,27 @@ pub async fn get_status(
     let mut counts = ResourcesStatus::default();
     let mut pve_cpu_allocated = 0.0;
     for remote_with_resources in remotes_with_resources {
-        if let Some(err) = remote_with_resources.error {
+        if let Some(err) = &remote_with_resources.error {
             counts.failed_remotes += 1;
             counts.failed_remotes_list.push(FailedRemote {
-                name: remote_with_resources.remote_name,
+                name: remote_with_resources.remote_name.clone(),
                 error: err.to_string(),
                 remote_type: remote_with_resources.remote.ty,
             });
         } else {
             counts.remotes += 1;
         }
+
+        let mut remote_status = if remote_with_resources.error.is_some() {
+            RemoteStatus::Error
+        } else {
+            RemoteStatus::Good
+        };
+        let mut remote_messages = match remote_with_resources.error {
+            Some(error) => vec![error],
+            None => Vec::new(),
+        };
+
         let mut seen_storages = HashSet::new();
         for resource in remote_with_resources.resources {
             match resource {
@@ -543,7 +554,13 @@ pub async fn get_status(
                 Resource::PveNode(r) => {
                     match r.status.as_str() {
                         "online" => counts.pve_nodes.online += 1,
-                        "offline" => counts.pve_nodes.offline += 1,
+                        "offline" => {
+                            if remote_status == RemoteStatus::Good {
+                                remote_status = RemoteStatus::Warning;
+                            }
+                            remote_messages.push(format!("Node '{}' is offline", r.node));
+                            counts.pve_nodes.offline += 1
+                        }
                         _ => counts.pve_nodes.unknown += 1,
                     }
                     counts.pve_cpu_stats.used += r.cpu * r.maxcpu;
@@ -560,6 +577,11 @@ pub async fn get_status(
                                 counts.sdn_zones.available += 1;
                             }
                             SdnStatus::Error => {
+                                if remote_status == RemoteStatus::Good {
+                                    remote_status = RemoteStatus::Warning;
+                                }
+                                remote_messages
+                                    .push(format!("SDN zone '{}' has an error", zone.network));
                                 counts.sdn_zones.error += 1;
                             }
                             SdnStatus::Pending => {
@@ -613,6 +635,13 @@ pub async fn get_status(
                 }
             }
         }
+
+        counts.remote_list.push(RemoteInfo {
+            name: remote_with_resources.remote_name,
+            ty: remote_with_resources.remote.ty,
+            status: remote_status,
+            messages: remote_messages,
+        });
     }
 
     counts.pve_cpu_stats.allocated = Some(pve_cpu_allocated);
-- 
2.47.3





  parent reply	other threads:[~2026-05-22  8:34 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-22  8:33 [PATCH datacenter-manager/proxmox-geojson-data/yew-widget-toolkit/yew-widget-toolkit-assets v3 00/11] add a new map widget for custom views Dominik Csapak
2026-05-22  8:33 ` [PATCH yew-widget-toolkit v3 1/3] js-helper: add client-to-svg-coordinate conversion helper Dominik Csapak
2026-05-22  8:33 ` [PATCH yew-widget-toolkit v3 2/3] widget: charts: add interactive Map with zoom/pan and clustering Dominik Csapak
2026-05-22 13:30   ` Shannon Sterz
2026-05-22  8:33 ` [PATCH yew-widget-toolkit v3 3/3] widget: charts: add WorldMap with GeoJSON rendering Dominik Csapak
2026-05-22  8:34 ` [PATCH yew-widget-toolkit-assets v3 1/1] charts: add necessary classes for Map Dominik Csapak
2026-05-22  8:34 ` [PATCH proxmox-geojson-data v3 1/1] initial commit Dominik Csapak
2026-05-22 13:30   ` Shannon Sterz
2026-05-22  8:34 ` [PATCH datacenter-manager v3 1/6] server: pbs client: add node_config method Dominik Csapak
2026-05-22  8:34 ` [PATCH datacenter-manager v3 2/6] lib/api: add 'location-info' api call with cached information Dominik Csapak
2026-05-22 13:30   ` Shannon Sterz
2026-05-22  8:34 ` Dominik Csapak [this message]
2026-05-22  8:34 ` [PATCH datacenter-manager v3 4/6] server: serve geojson worldmap Dominik Csapak
2026-05-22  8:34 ` [PATCH datacenter-manager v3 5/6] ui: views: refactor required api call info into struct Dominik Csapak
2026-05-22  8:34 ` [PATCH datacenter-manager v3 6/6] ui: views: add map component Dominik Csapak
2026-05-22 13:30   ` Shannon Sterz
2026-05-22  9:38 ` [PATCH datacenter-manager/proxmox-geojson-data/yew-widget-toolkit/yew-widget-toolkit-assets v3 00/11] add a new map widget for custom views Thomas Lamprecht
2026-05-22 13:33 ` Shannon Sterz
2026-05-24  2:31 ` applied: " Thomas Lamprecht

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=20260522083412.1223719-9-d.csapak@proxmox.com \
    --to=d.csapak@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