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 9D6431FF16F for ; Tue, 14 Oct 2025 10:37:59 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5EA3223B85; Tue, 14 Oct 2025 10:38:17 +0200 (CEST) Message-ID: Date: Tue, 14 Oct 2025 10:37:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta To: Proxmox Datacenter Manager development discussion , Christian Ebner References: <20251013085623.211136-1-c.ebner@proxmox.com> <20251013085623.211136-4-c.ebner@proxmox.com> Content-Language: en-US From: Dominik Csapak In-Reply-To: <20251013085623.211136-4-c.ebner@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1760431026861 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.028 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [resources.rs] Subject: Re: [pdm-devel] [PATCH datacenter-manager 3/7] server: api: collect failed remotes list while getting status X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" comments inline On 10/13/25 10:56 AM, Christian Ebner wrote: > Include name, remote type and error message for failed remotes when > gathering status information, in order to be able to discriminate > errors by remote type for the dashboard. To get the per-remote-type > resources, utilize the now previously exposed remote type filtering > for resources. > > Signed-off-by: Christian Ebner > --- > server/src/api/resources.rs | 105 ++++++++++++++++++++---------------- > 1 file changed, 58 insertions(+), 47 deletions(-) > > diff --git a/server/src/api/resources.rs b/server/src/api/resources.rs > index 029106f..33da5c2 100644 > --- a/server/src/api/resources.rs > +++ b/server/src/api/resources.rs > @@ -9,9 +9,9 @@ use futures::FutureExt; > use pbs_api_types::{DataStoreStatusListItem, NodeStatus}; > use pdm_api_types::remotes::{Remote, RemoteType}; > use pdm_api_types::resource::{ > - PbsDatastoreResource, PbsNodeResource, PveLxcResource, PveNodeResource, PveQemuResource, > - PveSdnResource, PveStorageResource, RemoteResources, Resource, ResourceType, ResourcesStatus, > - SdnStatus, SdnZoneResource, TopEntities, > + FailedRemote, PbsDatastoreResource, PbsNodeResource, PveLxcResource, PveNodeResource, > + PveQemuResource, PveSdnResource, PveStorageResource, RemoteResources, Resource, ResourceType, > + ResourcesStatus, SdnStatus, SdnZoneResource, TopEntities, > }; > use pdm_api_types::subscription::{ > NodeSubscriptionInfo, RemoteSubscriptionState, RemoteSubscriptions, SubscriptionLevel, > @@ -373,55 +373,66 @@ pub async fn get_status( > max_age: u64, > rpcenv: &mut dyn RpcEnvironment, > ) -> Result { > - let remotes = get_resources(max_age, None, None, rpcenv).await?; > let mut counts = ResourcesStatus::default(); > - for remote in remotes { > - if remote.error.is_some() { > - counts.failed_remotes += 1; > - } else { > - counts.remotes += 1; > - } > - for resource in remote.resources { > - match resource { > - Resource::PveStorage(r) => match r.status.as_str() { > - "available" => counts.storages.available += 1, > - _ => counts.storages.unknown += 1, > - }, > - Resource::PveQemu(r) => match r.status.as_str() { > - _ if r.template => counts.qemu.template += 1, > - "running" => counts.qemu.running += 1, > - "stopped" => counts.qemu.stopped += 1, > - _ => counts.qemu.unknown += 1, > - }, > - Resource::PveLxc(r) => match r.status.as_str() { > - _ if r.template => counts.lxc.template += 1, > - "running" => counts.lxc.running += 1, > - "stopped" => counts.lxc.stopped += 1, > - _ => counts.lxc.unknown += 1, > - }, > - Resource::PveNode(r) => match r.status.as_str() { > - "online" => counts.pve_nodes.online += 1, > - "offline" => counts.pve_nodes.offline += 1, > - _ => counts.pve_nodes.unknown += 1, > - }, > - Resource::PveSdn(r) => { > - if let PveSdnResource::Zone(_) = &r { > - match r.status() { > - SdnStatus::Available => { > - counts.sdn_zones.available += 1; > - } > - SdnStatus::Error => { > - counts.sdn_zones.error += 1; > - } > - SdnStatus::Unknown => { > - counts.sdn_zones.unknown += 1; > + for remote_type in [RemoteType::Pve, RemoteType::Pbs] { > + let remote_type_search = > + SearchTerm::new(remote_type.to_string()).category(Some("remote-type")); > + let remote_type_search = remote_type_search.to_string(); > + let remotes = > + get_resources_impl(max_age, Some(remote_type_search), None, Some(rpcenv)).await?; if the `RemoteResources` struct had the complete (or at least more than the name) struct of the remote, we could keep the current structure of just looping over that result instead of manually crafting a search for each type which would also make the patch diff itself a lot smaller i think > + for remote in remotes { > + if let Some(err) = remote.error { > + counts.failed_remotes += 1; > + counts.failed_remotes_list.push(FailedRemote { > + name: remote.remote, > + error: err.to_string(), > + remote_type, > + }); > + } else { > + counts.remotes += 1; > + } > + for resource in remote.resources { > + match resource { > + Resource::PveStorage(r) => match r.status.as_str() { > + "available" => counts.storages.available += 1, > + _ => counts.storages.unknown += 1, > + }, > + Resource::PveQemu(r) => match r.status.as_str() { > + _ if r.template => counts.qemu.template += 1, > + "running" => counts.qemu.running += 1, > + "stopped" => counts.qemu.stopped += 1, > + _ => counts.qemu.unknown += 1, > + }, > + Resource::PveLxc(r) => match r.status.as_str() { > + _ if r.template => counts.lxc.template += 1, > + "running" => counts.lxc.running += 1, > + "stopped" => counts.lxc.stopped += 1, > + _ => counts.lxc.unknown += 1, > + }, > + Resource::PveNode(r) => match r.status.as_str() { > + "online" => counts.pve_nodes.online += 1, > + "offline" => counts.pve_nodes.offline += 1, > + _ => counts.pve_nodes.unknown += 1, > + }, > + Resource::PveSdn(r) => { > + if let PveSdnResource::Zone(_) = &r { > + match r.status() { > + SdnStatus::Available => { > + counts.sdn_zones.available += 1; > + } > + SdnStatus::Error => { > + counts.sdn_zones.error += 1; > + } > + SdnStatus::Unknown => { > + counts.sdn_zones.unknown += 1; > + } > } > } > } > + // FIXME better status for pbs/datastores > + Resource::PbsNode(_) => counts.pbs_nodes.online += 1, > + Resource::PbsDatastore(_) => counts.pbs_datastores.available += 1, > } > - // FIXME better status for pbs/datastores > - Resource::PbsNode(_) => counts.pbs_nodes.online += 1, > - Resource::PbsDatastore(_) => counts.pbs_datastores.available += 1, > } > } > } _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel