From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pdm-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id D92251FF195 for <inbox@lore.proxmox.com>; Wed, 5 Mar 2025 16:01:49 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BC39618F13; Wed, 5 Mar 2025 16:01:45 +0100 (CET) From: Wolfgang Bumiller <w.bumiller@proxmox.com> To: pdm-devel@lists.proxmox.com Date: Wed, 5 Mar 2025 16:01:08 +0100 Message-Id: <20250305150108.245584-8-w.bumiller@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250305150108.245584-1-w.bumiller@proxmox.com> References: <20250305150108.245584-1-w.bumiller@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.082 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 Subject: [pdm-devel] [PATCH v2 datacenter-manager 7/7] server: add some tracing instrumentation X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion <pdm-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pdm-devel>, <mailto:pdm-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pdm-devel/> List-Post: <mailto:pdm-devel@lists.proxmox.com> List-Help: <mailto:pdm-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel>, <mailto:pdm-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox Datacenter Manager development discussion <pdm-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" <pdm-devel-bounces@lists.proxmox.com> For debugging the client usage. To see messages, set PROXMOX_DEBUG=trace and use, for instance: # journalctl -f SPAN_NAME=remote_node_caching Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com> Reviewed-by: Lukas Wagner <l.wagner@proxmox.com> --- No changes since v1. .../tasks/remote_node_mapping.rs | 14 ++++++++------ server/src/connection.rs | 10 ++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/server/src/bin/proxmox-datacenter-api/tasks/remote_node_mapping.rs b/server/src/bin/proxmox-datacenter-api/tasks/remote_node_mapping.rs index 5912365..f678d4c 100644 --- a/server/src/bin/proxmox-datacenter-api/tasks/remote_node_mapping.rs +++ b/server/src/bin/proxmox-datacenter-api/tasks/remote_node_mapping.rs @@ -68,6 +68,7 @@ impl CachingTask { } /// A single iteration of the caching task. + #[tracing::instrument(skip_all, name = "remote_node_caching")] async fn run_once(&mut self) { let (config, digest) = match pdm_config::remotes::config() { Ok(cd) => cd, @@ -82,21 +83,19 @@ impl CachingTask { .as_ref() .is_none_or(|d| digest != *d) { - tracing::debug!("new config - updating remote node name cache"); + log::trace!("new config - updating remote node name cache"); self.last_config_digest = Some(digest); // the config got updated - abort the current name-fetching task, we'll // spawn a new one if let Some(name_task) = self.current_name_task.take() { - tracing::debug!("aborting query task"); + log::trace!("aborting query task"); name_task.abort(); } if let Err(err) = self.config_update(&config) { log::error!("error updating remote node cache: {err:?}"); } - //} else { - // tracing::debug!("no change to the config"); } if self @@ -104,7 +103,7 @@ impl CachingTask { .as_ref() .is_none_or(|task| task.is_finished()) { - log::debug!("name task finished, starting reachability query task"); + log::trace!("name task finished, starting reachability query task"); self.current_name_task = Some(spawn_aborted_on_shutdown(Self::query_node_names(config))); } @@ -168,8 +167,10 @@ impl CachingTask { } } + #[tracing::instrument(skip_all)] async fn query_node_names(config: SectionConfigData<Remote>) { for (_name, remote) in &config { + log::trace!("update remote {:?}", remote.id); if let Err(err) = Self::query_node_names_for_remote(remote).await { log::error!("error updating node name cache - {err:?}"); } @@ -184,7 +185,7 @@ impl CachingTask { // now add new nodes for node in &remote.nodes { - tracing::debug!("querying remote {:?} node {:?}", remote.id, node.hostname); + log::debug!("querying remote {:?} node {:?}", remote.id, node.hostname); // if the host is new, we need to query its name let query_result = match query_node_name(remote, &node.hostname).await { @@ -215,6 +216,7 @@ impl CachingTask { /// Calls `/cluster/status` directly on a specific node to find its name. async fn query_node_name(remote: &Remote, hostname: &str) -> Result<String, Error> { + log::trace!("querying node name {hostname:?} for remote {:?}", remote.id); let client = server::connection::make_pve_client_with_endpoint(remote, Some(hostname))?; let node_status_list = client.cluster_status().await?; for node in node_status_list { diff --git a/server/src/connection.rs b/server/src/connection.rs index 3092ab3..b4ba347 100644 --- a/server/src/connection.rs +++ b/server/src/connection.rs @@ -603,6 +603,7 @@ struct TryClient { impl TryClient { fn reachable(entry: &MultiClientEntry) -> Self { + log::trace!("trying reachable client for host {:?}", entry.hostname); Self { client: Arc::clone(&entry.client), hostname: entry.hostname.clone(), @@ -611,6 +612,10 @@ impl TryClient { } fn unreachable(entry: &MultiClientEntry) -> Self { + log::trace!( + "trying previouslsy unreachable client for host {:?}", + entry.hostname + ); Self { client: Arc::clone(&entry.client), hostname: entry.hostname.clone(), @@ -637,6 +642,8 @@ impl MultiClient { let mut try_unreachable = None::<std::vec::IntoIter<_>>; std::iter::from_fn(move || { + let _enter = tracing::span!(tracing::Level::TRACE, "multi_client_iterator").entered(); + let mut state = state.lock().unwrap(); if let Some(ref mut try_unreachable) = try_unreachable { @@ -650,6 +657,7 @@ impl MultiClient { // first attempt, just use the current client and remember the starting index let (client, index) = state.get(); start_current = Some((index, index)); + log::trace!("trying reachable client {index}"); Some(TryClient::reachable(client)) } Some((start, current)) => { @@ -674,9 +682,11 @@ impl MultiClient { // remember all the clients we skipped: let mut at = current + 1; while at != new_current { + log::trace!("(remembering unreachable client {at})"); unreachable_clients.push(at); at = at.wrapping_add(1); } + log::trace!("trying reachable client {new_current}"); Some(TryClient::reachable(client)) } } -- 2.39.5 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel