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 997071FF13F for ; Thu, 12 Mar 2026 14:53:42 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3B7E317B57; Thu, 12 Mar 2026 14:53:29 +0100 (CET) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager 22/26] api: fix /nodes/localhost/rrddata endpoint Date: Thu, 12 Mar 2026 14:52:23 +0100 Message-ID: <20260312135229.420729-23-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: 1773323524844 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.003 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 POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes 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: GMTEMSZNYYGP5A6DE3YLIZF2VWOAHZ5N X-Message-ID-Hash: GMTEMSZNYYGP5A6DE3YLIZF2VWOAHZ5N 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: We didn't use this existing endpoint so far, which is why this mistake was not discovered yet. First, there was a typo in the API handler path, and second the `node` parameter was missing from the handler itself. Signed-off-by: Lukas Wagner --- lib/pdm-client/src/lib.rs | 2 +- server/src/api/nodes/mod.rs | 2 +- server/src/api/nodes/rrddata.rs | 18 ++++++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/pdm-client/src/lib.rs b/lib/pdm-client/src/lib.rs index 7ce9c244..2d98146b 100644 --- a/lib/pdm-client/src/lib.rs +++ b/lib/pdm-client/src/lib.rs @@ -380,7 +380,7 @@ impl PdmClient { &self, mode: RrdMode, timeframe: RrdTimeframe, - ) -> Result { + ) -> Result, Error> { let path = ApiPathBuilder::new("/api2/extjs/nodes/localhost/rrddata") .arg("cf", mode) .arg("timeframe", timeframe) diff --git a/server/src/api/nodes/mod.rs b/server/src/api/nodes/mod.rs index bd1396bc..7903d63a 100644 --- a/server/src/api/nodes/mod.rs +++ b/server/src/api/nodes/mod.rs @@ -48,7 +48,7 @@ pub const SUBDIRS: SubdirMap = &sorted!([ ("journal", &journal::ROUTER), ("network", &network::ROUTER), ("report", &report::ROUTER), - ("rrdata", &rrddata::ROUTER), + ("rrddata", &rrddata::ROUTER), ("sdn", &sdn::ROUTER), ("subscription", &subscription::ROUTER), ("status", &status::ROUTER), diff --git a/server/src/api/nodes/rrddata.rs b/server/src/api/nodes/rrddata.rs index 75900965..4c2302c8 100644 --- a/server/src/api/nodes/rrddata.rs +++ b/server/src/api/nodes/rrddata.rs @@ -1,10 +1,11 @@ use anyhow::Error; use proxmox_rrd_api_types::{RrdMode, RrdTimeframe}; -use proxmox_router::Router; +use proxmox_router::{http_bail, Router}; use proxmox_schema::api; use pdm_api_types::rrddata::PdmNodeDatapoint; +use pdm_api_types::NODE_SCHEMA; use crate::api::rrd_common::{self, DataPoint}; @@ -36,6 +37,9 @@ impl DataPoint for PdmNodeDatapoint { cf: { type: RrdMode, }, + node: { + schema: NODE_SCHEMA, + }, }, }, returns: { @@ -47,7 +51,17 @@ impl DataPoint for PdmNodeDatapoint { } )] /// Read RRD data for this PDM node. -fn get_node_rrddata(timeframe: RrdTimeframe, cf: RrdMode) -> Result, Error> { +fn get_node_rrddata( + node: String, + timeframe: RrdTimeframe, + cf: RrdMode, +) -> Result, Error> { + if node != "localhost" { + http_bail!( + BAD_REQUEST, + "PDM only supports `localhost` as a `node` parameter" + ); + } let base = "nodes/localhost"; rrd_common::create_datapoints_from_rrd(base, timeframe, cf) } -- 2.47.3