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 28FAF1FF13F for ; Thu, 12 Mar 2026 14:53:17 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 15FE617489; Thu, 12 Mar 2026 14:53:13 +0100 (CET) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager 19/26] metric collection: clarify naming for remote metric collection Date: Thu, 12 Mar 2026 14:52:20 +0100 Message-ID: <20260312135229.420729-20-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260312135229.420729-1-l.wagner@proxmox.com> References: <20260312135229.420729-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1773323524394 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.047 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 RCVD_IN_MSPIKE_H2 0.001 Average reputation (+2) 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: M7WAZEGPBDV5MQZE6NXUVA3UVXSJTPLJ X-Message-ID-Hash: M7WAZEGPBDV5MQZE6NXUVA3UVXSJTPLJ X-MailFrom: l.wagner@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: Primarily to avoid confusion with the new task that will be added for local metric collection. Signed-off-by: Lukas Wagner --- cli/client/src/metric_collection.rs | 4 ++-- lib/pdm-api-types/src/metric_collection.rs | 2 +- lib/pdm-client/src/lib.rs | 6 +++--- server/src/api/metric_collection.rs | 10 +++++----- server/src/api/remotes.rs | 2 +- server/src/api/rrd_common.rs | 2 +- server/src/metric_collection/mod.rs | 19 +++++++++++-------- ...tion_task.rs => remote_collection_task.rs} | 8 ++++---- server/src/metric_collection/rrd_task.rs | 2 +- server/src/metric_collection/state.rs | 2 +- 10 files changed, 30 insertions(+), 27 deletions(-) rename server/src/metric_collection/{collection_task.rs => remote_collection_task.rs} (99%) diff --git a/cli/client/src/metric_collection.rs b/cli/client/src/metric_collection.rs index e9dbd804..77dcaab5 100644 --- a/cli/client/src/metric_collection.rs +++ b/cli/client/src/metric_collection.rs @@ -34,7 +34,7 @@ pub fn cli() -> CommandLineInterface { /// all. async fn trigger_metric_collection(remote: Option) -> Result<(), Error> { client()? - .trigger_metric_collection(remote.as_deref()) + .trigger_remote_metric_collection(remote.as_deref()) .await?; Ok(()) } @@ -42,7 +42,7 @@ async fn trigger_metric_collection(remote: Option) -> Result<(), Error> #[api] /// Show metric collection status. async fn metric_collection_status() -> Result<(), Error> { - let result = client()?.get_metric_collection_status().await?; + let result = client()?.get_remote_metric_collection_status().await?; let output_format = env().format_args.output_format; if output_format == OutputFormat::Text { diff --git a/lib/pdm-api-types/src/metric_collection.rs b/lib/pdm-api-types/src/metric_collection.rs index 5279c8a4..cda6ac2a 100644 --- a/lib/pdm-api-types/src/metric_collection.rs +++ b/lib/pdm-api-types/src/metric_collection.rs @@ -8,7 +8,7 @@ use proxmox_schema::api; #[derive(Clone, Deserialize, Serialize)] #[serde(rename_all = "kebab-case")] /// Per-remote collection status. -pub struct MetricCollectionStatus { +pub struct RemoteMetricCollectionStatus { /// The remote's name. pub remote: String, /// Any error that occured during the last collection attempt. diff --git a/lib/pdm-client/src/lib.rs b/lib/pdm-client/src/lib.rs index 0fee97a7..7ce9c244 100644 --- a/lib/pdm-client/src/lib.rs +++ b/lib/pdm-client/src/lib.rs @@ -347,7 +347,7 @@ impl PdmClient { } /// Trigger metric collection for a single remote or for all remotes, if no remote is provided. - pub async fn trigger_metric_collection( + pub async fn trigger_remote_metric_collection( &self, remote: Option<&str>, ) -> Result<(), proxmox_client::Error> { @@ -368,9 +368,9 @@ impl PdmClient { } /// Get global metric collection status. - pub async fn get_metric_collection_status( + pub async fn get_remote_metric_collection_status( &self, - ) -> Result, Error> { + ) -> Result, Error> { let path = "/api2/extjs/remotes/metric-collection/status"; Ok(self.0.get(path).await?.expect_json()?.data) } diff --git a/server/src/api/metric_collection.rs b/server/src/api/metric_collection.rs index b4c81c68..5a480b36 100644 --- a/server/src/api/metric_collection.rs +++ b/server/src/api/metric_collection.rs @@ -4,7 +4,7 @@ use proxmox_router::{Router, SubdirMap}; use proxmox_schema::api; use proxmox_sortable_macro::sortable; -use pdm_api_types::{remotes::REMOTE_ID_SCHEMA, MetricCollectionStatus}; +use pdm_api_types::{remotes::REMOTE_ID_SCHEMA, RemoteMetricCollectionStatus}; use crate::metric_collection; @@ -34,7 +34,7 @@ const SUBDIRS: SubdirMap = &sorted!([ )] /// Trigger metric collection for a provided remote or for all remotes if no remote is passed. pub async fn trigger_metric_collection(remote: Option) -> Result<(), Error> { - crate::metric_collection::trigger_metric_collection(remote, false).await?; + crate::metric_collection::trigger_remote_metric_collection(remote, false).await?; Ok(()) } @@ -44,11 +44,11 @@ pub async fn trigger_metric_collection(remote: Option) -> Result<(), Err type: Array, description: "A list of metric collection statuses.", items: { - type: MetricCollectionStatus, + type: RemoteMetricCollectionStatus, } } )] /// Read metric collection status. -fn get_metric_collection_status() -> Result, Error> { - metric_collection::get_status() +fn get_metric_collection_status() -> Result, Error> { + metric_collection::remote_metric_collection_status() } diff --git a/server/src/api/remotes.rs b/server/src/api/remotes.rs index 9700611d..678e0ed2 100644 --- a/server/src/api/remotes.rs +++ b/server/src/api/remotes.rs @@ -324,7 +324,7 @@ pub async fn add_remote(mut entry: Remote, create_token: Option) -> Resu pdm_config::remotes::save_config(remotes)?; - if let Err(e) = metric_collection::trigger_metric_collection(Some(name), false).await { + if let Err(e) = metric_collection::trigger_remote_metric_collection(Some(name), false).await { log::error!("could not trigger metric collection after adding remote: {e}"); } diff --git a/server/src/api/rrd_common.rs b/server/src/api/rrd_common.rs index b5d1a786..8c0fb798 100644 --- a/server/src/api/rrd_common.rs +++ b/server/src/api/rrd_common.rs @@ -74,7 +74,7 @@ pub async fn get_rrd_datapoints( // is super slow or if the metric collection tasks currently busy with collecting other // metrics, we just return the data we already have, not the newest one. let _ = tokio::time::timeout(WAIT_FOR_NEWEST_METRIC_TIMEOUT, async { - metric_collection::trigger_metric_collection(Some(remote), true).await + metric_collection::trigger_remote_metric_collection(Some(remote), true).await }) .await; } diff --git a/server/src/metric_collection/mod.rs b/server/src/metric_collection/mod.rs index 0e6860fc..6bc534f8 100644 --- a/server/src/metric_collection/mod.rs +++ b/server/src/metric_collection/mod.rs @@ -7,16 +7,16 @@ use nix::sys::stat::Mode; use tokio::sync::mpsc::{self, Sender}; use tokio::sync::oneshot; -use pdm_api_types::MetricCollectionStatus; +use pdm_api_types::RemoteMetricCollectionStatus; use pdm_buildcfg::PDM_STATE_DIR_M; -mod collection_task; +mod remote_collection_task; pub mod rrd_cache; mod rrd_task; mod state; pub mod top_entities; -use collection_task::{ControlMsg, MetricCollectionTask}; +use remote_collection_task::{ControlMsg, RemoteMetricCollectionTask}; use rrd_cache::RrdCache; const RRD_CACHE_BASEDIR: &str = concat!(PDM_STATE_DIR_M!(), "/rrdb"); @@ -46,7 +46,7 @@ pub fn start_task() -> Result<(), Error> { tokio::spawn(async move { let metric_collection_task_future = pin!(async move { - match MetricCollectionTask::new(metric_data_tx, trigger_collection_rx) { + match RemoteMetricCollectionTask::new(metric_data_tx, trigger_collection_rx) { Ok(mut task) => task.run().await, Err(err) => log::error!("could not start metric collection task: {err}"), } @@ -76,7 +76,10 @@ pub fn start_task() -> Result<(), Error> { /// /// Has no effect if the tx end of the channel has not been initialized yet. /// Returns an error if the mpsc channel has been closed already. -pub async fn trigger_metric_collection(remote: Option, wait: bool) -> Result<(), Error> { +pub async fn trigger_remote_metric_collection( + remote: Option, + wait: bool, +) -> Result<(), Error> { let (done_sender, done_receiver) = oneshot::channel(); if let Some(sender) = CONTROL_MESSAGE_TX.get() { @@ -93,15 +96,15 @@ pub async fn trigger_metric_collection(remote: Option, wait: bool) -> Re } /// Get each remote's metric collection status. -pub fn get_status() -> Result, Error> { +pub fn remote_metric_collection_status() -> Result, Error> { let (remotes, _) = pdm_config::remotes::config()?; - let state = collection_task::load_state()?; + let state = remote_collection_task::load_state()?; let mut result = Vec::new(); for (remote, _) in remotes.into_iter() { if let Some(status) = state.get_status(&remote) { - result.push(MetricCollectionStatus { + result.push(RemoteMetricCollectionStatus { remote, error: status.error.clone(), last_collection: status.last_collection, diff --git a/server/src/metric_collection/collection_task.rs b/server/src/metric_collection/remote_collection_task.rs similarity index 99% rename from server/src/metric_collection/collection_task.rs rename to server/src/metric_collection/remote_collection_task.rs index cc1a460e..eca0e11d 100644 --- a/server/src/metric_collection/collection_task.rs +++ b/server/src/metric_collection/remote_collection_task.rs @@ -46,13 +46,13 @@ pub(super) enum ControlMsg { /// Task which periodically collects metrics from all remotes and stores /// them in the local metrics database. -pub(super) struct MetricCollectionTask { +pub(super) struct RemoteMetricCollectionTask { state: MetricCollectionState, metric_data_tx: Sender, control_message_rx: Receiver, } -impl MetricCollectionTask { +impl RemoteMetricCollectionTask { /// Create a new metric collection task. pub(super) fn new( metric_data_tx: Sender, @@ -574,7 +574,7 @@ pub(super) mod tests { let (_control_tx, control_rx) = tokio::sync::mpsc::channel(10); - let mut task = MetricCollectionTask { + let mut task = RemoteMetricCollectionTask { state, metric_data_tx: tx, control_message_rx: control_rx, @@ -644,7 +644,7 @@ pub(super) mod tests { let (_control_tx, control_rx) = tokio::sync::mpsc::channel(10); - let mut task = MetricCollectionTask { + let mut task = RemoteMetricCollectionTask { state, metric_data_tx: tx, control_message_rx: control_rx, diff --git a/server/src/metric_collection/rrd_task.rs b/server/src/metric_collection/rrd_task.rs index 48b6de9e..29137858 100644 --- a/server/src/metric_collection/rrd_task.rs +++ b/server/src/metric_collection/rrd_task.rs @@ -200,7 +200,7 @@ mod tests { use pve_api_types::{ClusterMetrics, ClusterMetricsData}; use crate::{ - metric_collection::collection_task::tests::get_create_options, + metric_collection::remote_collection_task::tests::get_create_options, test_support::temp::NamedTempDir, }; diff --git a/server/src/metric_collection/state.rs b/server/src/metric_collection/state.rs index 7f68843e..fd313c48 100644 --- a/server/src/metric_collection/state.rs +++ b/server/src/metric_collection/state.rs @@ -92,7 +92,7 @@ impl MetricCollectionState { #[cfg(test)] mod tests { - use crate::metric_collection::collection_task::tests::get_create_options; + use crate::metric_collection::remote_collection_task::tests::get_create_options; use crate::test_support::temp::NamedTempFile; use super::*; -- 2.47.3