From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH v2 datacenter-manager 7/7] server: add some tracing instrumentation
Date: Wed, 5 Mar 2025 16:01:08 +0100 [thread overview]
Message-ID: <20250305150108.245584-8-w.bumiller@proxmox.com> (raw)
In-Reply-To: <20250305150108.245584-1-w.bumiller@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
next prev parent reply other threads:[~2025-03-05 15:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-05 15:01 [pdm-devel] [PATCH pdm 0/7] multi-remote client and node reachability cache Wolfgang Bumiller
2025-03-05 15:01 ` [pdm-devel] [PATCH v2 datacenter-manager 1/7] server: generic multi-client wrapper Wolfgang Bumiller
2025-03-05 15:01 ` [pdm-devel] [PATCH v2 datacenter-manager 2/7] server: store pve MultiClient for re-use Wolfgang Bumiller
2025-03-05 15:01 ` [pdm-devel] [PATCH v2 datacenter-manager 3/7] server: separate ConnectInfo from client creation Wolfgang Bumiller
2025-03-05 15:01 ` [pdm-devel] [PATCH v2 datacenter-manager 4/7] server: cache pve node reachability and names Wolfgang Bumiller
2025-03-05 15:01 ` [pdm-devel] [PATCH v2 datacenter-manager 5/7] server: don't try to connect to known-unreachable servers Wolfgang Bumiller
2025-03-05 15:01 ` [pdm-devel] [PATCH v2 datacenter-manager 6/7] server: try previously unreachable clients as last resort Wolfgang Bumiller
2025-03-05 15:01 ` Wolfgang Bumiller [this message]
2025-03-16 21:39 ` [pdm-devel] applied-series: [PATCH pdm 0/7] multi-remote client and node reachability cache 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=20250305150108.245584-8-w.bumiller@proxmox.com \
--to=w.bumiller@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.