* [PATCH proxmox-datacenter-manager v2 0/2] fix #7731: metric collection: allow 5 minutes for PVE metric requests
@ 2026-11-27 14:03 Jakob Klocker
2026-11-27 14:03 ` [PATCH proxmox-datacenter-manager v2 1/2] connection: allow creating PVE clients with a custom request timeout Jakob Klocker
2026-11-27 14:03 ` [PATCH proxmox-datacenter-manager v2 2/2] fix #7731: metric collection: allow 5 minutes for PVE metric requests Jakob Klocker
0 siblings, 2 replies; 3+ messages in thread
From: Jakob Klocker @ 2026-11-27 14:03 UTC (permalink / raw)
To: pdm-devel
Exporting the full metric history of a large PVE cluster takes minutes
(2m43s on the reporter's 25-node cluster [0][1]), but PDM gives up on a
request to a remote after 60 seconds and repeats it on every other
endpoint, until all of them are marked unreachable. No metrics are ever
collected for such a cluster.
This series uses a separate client with a 5 minute request timeout for
fetching PVE metrics. All other requests keep the regular 60 seconds,
so they still fail over quickly when a node does not answer.
v1 assumed that pveproxy cuts such requests off after 30 seconds,
which isn't the case: pveproxy does not limit this request, the timeout
is PDM's own. With the export handler delayed by 90 seconds on a test
cluster, PDM gave up after 60 seconds with the message from the bug
report, while pveproxy still answered the request in full after 90
seconds.
Testing: with the export handler delayed by 180 seconds, both manual
and regular, timer-driven metric collections now succeed after ~180s.
Changes since v1:
- Drop fetching large clusters node by node, use a longer request
timeout for the metric collection instead.
This fixes the reported issue for now. As a follow-up, the export
endpoint in PVE will fetch the metrics of the other cluster nodes
concurrently, which should shorten such requests. The longer timeout
may still be needed for the initial import of a large cluster's full
metric history.
[0] https://bugzilla.proxmox.com/show_bug.cgi?id=7731
[1] https://forum.proxmox.com/threads/getting-client-timeouts-in-pdm-system-log.184344/#post-858021
proxmox-datacenter-manager:
Jakob Klocker (2):
connection: allow creating PVE clients with a custom request timeout
fix #7731: metric collection: allow 5 minutes for PVE metric requests
server/src/connection.rs | 49 ++++++++++++++++---
.../remote_collection_task.rs | 7 ++-
2 files changed, 47 insertions(+), 9 deletions(-)
Summary over all repositories:
2 files changed, 47 insertions(+), 9 deletions(-)
--
Generated by murpp 0.12.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH proxmox-datacenter-manager v2 1/2] connection: allow creating PVE clients with a custom request timeout
2026-11-27 14:03 [PATCH proxmox-datacenter-manager v2 0/2] fix #7731: metric collection: allow 5 minutes for PVE metric requests Jakob Klocker
@ 2026-11-27 14:03 ` Jakob Klocker
2026-11-27 14:03 ` [PATCH proxmox-datacenter-manager v2 2/2] fix #7731: metric collection: allow 5 minutes for PVE metric requests Jakob Klocker
1 sibling, 0 replies; 3+ messages in thread
From: Jakob Klocker @ 2026-11-27 14:03 UTC (permalink / raw)
To: pdm-devel
Some requests to remotes can legitimately take longer than the regular
request timeout of 60 seconds, for example exporting the full metric
history of a large cluster.
Allow creating PVE clients with a different request timeout. Such
clients are created separately instead of being taken from the
connection cache, so all other requests to the remote keep using the
shared cached client with the regular timeout.
Signed-off-by: Jakob Klocker <j.klocker@proxmox.com>
---
server/src/connection.rs | 49 +++++++++++++++++++++++++++++++++-------
1 file changed, 41 insertions(+), 8 deletions(-)
diff --git a/server/src/connection.rs b/server/src/connection.rs
index 24aab041..4189fc1b 100644
--- a/server/src/connection.rs
+++ b/server/src/connection.rs
@@ -261,6 +261,19 @@ pub trait ClientFactory {
self.make_pve_client(remote)
}
+ /// Create a new API client for PVE remotes whose requests may take up to `timeout`.
+ ///
+ /// The default implementation ignores the `timeout` parameter and forwards to
+ /// `make_pve_client()`.
+ fn make_pve_client_with_timeout(
+ &self,
+ remote: &Remote,
+ timeout: Duration,
+ ) -> Result<Arc<PveClient>, Error> {
+ let _ = timeout;
+ self.make_pve_client(remote)
+ }
+
/// Create a new API client for PVE remotes.
///
/// In case the remote has a user configured (instead of an API token), it will connect and get
@@ -414,6 +427,17 @@ impl ClientFactory for DefaultClientFactory {
}
}
+ fn make_pve_client_with_timeout(
+ &self,
+ remote: &Remote,
+ timeout: Duration,
+ ) -> Result<Arc<PveClient>, Error> {
+ // Not taken from the connection cache: the cached client is shared with all other
+ // requests to this remote, which keep the default timeout.
+ let client = crate::connection::multi_connect(remote)?.with_timeout(timeout);
+ Ok(Arc::new(PveClientImpl(client)))
+ }
+
async fn make_pve_client_and_login(&self, remote: &Remote) -> Result<Arc<PveClient>, Error> {
let client = connect_or_login(remote, None).await?;
Ok(Arc::new(PveClientImpl(client)))
@@ -634,11 +658,12 @@ struct MultiClientEntry {
/// problems: if we cannot reach a node of a cluster, this will attempt to retry a request on
/// another node.
///
-/// The 60-second request timeout applies to each endpoint attempt separately. Until failed
-/// endpoints enter their back-off, one request can take up to one timeout per endpoint, plus one
-/// more when the first endpoint is retried after a connection error. For streamed responses, the
-/// timeout limits each wait for body data rather than the whole transfer. Body errors are returned
-/// to the consumer without failover or retries.
+/// The request timeout applies to each endpoint attempt separately. Until failed endpoints enter
+/// their back-off, one request can take up to one timeout per endpoint, plus one more when the
+/// first endpoint is retried after a connection error. For streamed responses, the timeout limits
+/// each wait for body data rather than the whole transfer. Body errors are returned to the
+/// consumer without failover or retries. The timeout defaults to 60 seconds and can be changed
+/// with `MultiClient::with_timeout`.
///
/// # Possible improvements
///
@@ -646,6 +671,7 @@ struct MultiClientEntry {
pub struct MultiClient {
state: StdMutex<MultiClientState>,
remote: String,
+ timeout: Duration,
}
impl MultiClient {
@@ -653,9 +679,15 @@ impl MultiClient {
Self {
state: StdMutex::new(MultiClientState::new(remote.clone(), entries)),
remote,
+ timeout: REQUEST_TIMEOUT,
}
}
+ fn with_timeout(mut self, timeout: Duration) -> Self {
+ self.timeout = timeout;
+ self
+ }
+
fn for_each_client<F>(&self, func: F)
where
F: Fn(&Arc<Client>),
@@ -936,7 +968,7 @@ macro_rules! try_request {
}
let request = client.$how($method.clone(), $path_and_query, params.as_ref());
- match tokio::time::timeout(REQUEST_TIMEOUT, request).await {
+ match tokio::time::timeout($self.timeout, request).await {
// Connection error: the request never reached the server, so failing over to
// another node is safe for any method. Remember the first endpoint for retry.
Ok(Err(err @ proxmox_client::Error::Connect(_))) => {
@@ -1014,7 +1046,7 @@ macro_rules! try_request {
let path = $path_and_query;
log::warn!("all endpoints failed, retrying {hostname:?} once - {path}");
let request = client.$how($method.clone(), $path_and_query, params.as_ref());
- if let Ok(result) = tokio::time::timeout(REQUEST_TIMEOUT, request).await {
+ if let Ok(result) = tokio::time::timeout($self.timeout, request).await {
if result.is_ok() {
if let Ok(mut cache) = crate::remote_cache::RemoteMappingCache::write() {
cache.mark_host_reachable(
@@ -1082,11 +1114,12 @@ impl HttpApiClient for MultiClient {
where
T: Serialize + 'a,
{
+ let timeout = self.timeout;
let request = try_request! { self, method, path_and_query, params, streaming_request };
Box::pin(async move {
request
.await
- .map(|response| with_body_idle_timeout(response, REQUEST_TIMEOUT))
+ .map(|response| with_body_idle_timeout(response, timeout))
})
}
}
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH proxmox-datacenter-manager v2 2/2] fix #7731: metric collection: allow 5 minutes for PVE metric requests
2026-11-27 14:03 [PATCH proxmox-datacenter-manager v2 0/2] fix #7731: metric collection: allow 5 minutes for PVE metric requests Jakob Klocker
2026-11-27 14:03 ` [PATCH proxmox-datacenter-manager v2 1/2] connection: allow creating PVE clients with a custom request timeout Jakob Klocker
@ 2026-11-27 14:03 ` Jakob Klocker
1 sibling, 0 replies; 3+ messages in thread
From: Jakob Klocker @ 2026-11-27 14:03 UTC (permalink / raw)
To: pdm-devel
Exporting the full metric history of a large PVE cluster can take
minutes: on a 25-node cluster with about 2800 guests, the export took
2m43s. The client's request timeout of 60 seconds cut such requests
off, and the request was repeated on every other endpoint of the remote
until all of its nodes were marked unreachable, so no metrics were ever
collected for such a cluster.
Use a client with a 5 minute timeout for fetching the metrics of PVE
remotes. All other requests keep the shorter timeout, so they still
fail over quickly to the next endpoint when a node does not answer.
Signed-off-by: Jakob Klocker <j.klocker@proxmox.com>
---
server/src/metric_collection/remote_collection_task.rs | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/server/src/metric_collection/remote_collection_task.rs b/server/src/metric_collection/remote_collection_task.rs
index 1e0011cb..b5d102fa 100644
--- a/server/src/metric_collection/remote_collection_task.rs
+++ b/server/src/metric_collection/remote_collection_task.rs
@@ -36,6 +36,9 @@ const METRIC_COLLECTION_STATE_FILE: &str = concat!(
pub const MAX_CONCURRENT_CONNECTIONS: usize = 20;
+/// Timeout for fetching the metrics of a PVE remote.
+const PVE_METRICS_REQUEST_TIMEOUT: Duration = Duration::from_secs(5 * 60);
+
/// Default metric collection interval.
pub const DEFAULT_COLLECTION_INTERVAL: u64 = 600;
/// Minimum metric collection interval.
@@ -315,7 +318,9 @@ impl RemoteMetricCollectionTask {
let res: Result<RrdStoreResult, Error> = async {
match remote.ty {
RemoteType::Pve => {
- let client = app.client_factory().make_pve_client(&remote)?;
+ let client = app
+ .client_factory()
+ .make_pve_client_with_timeout(&remote, PVE_METRICS_REQUEST_TIMEOUT)?;
let metrics = client
.cluster_metrics_export(
Some(true),
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-27 14:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 14:03 [PATCH proxmox-datacenter-manager v2 0/2] fix #7731: metric collection: allow 5 minutes for PVE metric requests Jakob Klocker
2026-11-27 14:03 ` [PATCH proxmox-datacenter-manager v2 1/2] connection: allow creating PVE clients with a custom request timeout Jakob Klocker
2026-11-27 14:03 ` [PATCH proxmox-datacenter-manager v2 2/2] fix #7731: metric collection: allow 5 minutes for PVE metric requests Jakob Klocker
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.