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 4B7EA1FF136 for ; Mon, 04 May 2026 14:45:50 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2675F20DA5; Mon, 4 May 2026 14:45:50 +0200 (CEST) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager 2/4] lib/api: add new 'remote-list' info to the resource status Date: Mon, 4 May 2026 14:44:53 +0200 Message-ID: <20260504124515.2956574-7-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260504124515.2956574-1-d.csapak@proxmox.com> References: <20260504124515.2956574-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: G6FLYL5ED2IWGNFLABLBQUDCSKCZ24R5 X-Message-ID-Hash: G6FLYL5ED2IWGNFLABLBQUDCSKCZ24R5 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 | 49 +++++++++++++++++++++++++++++++ server/src/api/resources.rs | 38 ++++++++++++++++++++---- 2 files changed, 82 insertions(+), 5 deletions(-) diff --git a/lib/pdm-api-types/src/resource.rs b/lib/pdm-api-types/src/resource.rs index 895d1244..b2af4e7c 100644 --- a/lib/pdm-api-types/src/resource.rs +++ b/lib/pdm-api-types/src/resource.rs @@ -689,6 +689,12 @@ pub struct CpuStatistics { items: { type: FailedRemote, }, + }, + "remote-list": { + type: Array, + items: { + type: RemoteInfo, + }, } } )] @@ -729,6 +735,49 @@ 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 { + #[default] + /// 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, + /// 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, + #[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 04628a81..5dfab1d4 100644 --- a/server/src/api/resources.rs +++ b/server/src/api/resources.rs @@ -13,8 +13,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, @@ -470,16 +470,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 { @@ -516,7 +527,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; @@ -533,6 +550,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.id)); counts.sdn_zones.error += 1; } SdnStatus::Pending => { @@ -586,6 +608,12 @@ pub async fn get_status( } } } + + counts.remote_list.push(RemoteInfo { + name: remote_with_resources.remote_name, + status: remote_status, + messages: remote_messages, + }); } counts.pve_cpu_stats.allocated = Some(pve_cpu_allocated); -- 2.47.3