From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id C7C391FF142 for ; Fri, 22 May 2026 10:34:50 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9D24F2645; Fri, 22 May 2026 10:34:49 +0200 (CEST) From: Dominik Csapak 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 Message-ID: <20260522083412.1223719-9-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260522083412.1223719-1-d.csapak@proxmox.com> References: <20260522083412.1223719-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.050 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: H6HGT2PBNHED4KO3MEUFEN74JBZR5VFT X-Message-ID-Hash: H6HGT2PBNHED4KO3MEUFEN74JBZR5VFT X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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, + + /// List of remote info + #[serde(default, skip_serializing_if = "Vec::is_empty")] + #[serde(rename = "remote-list")] + pub remote_list: Vec, +} + +#[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, + /// 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