From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 7E1481FF138 for ; Mon, 15 Jun 2026 14:58:33 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DAF1114F35; Mon, 15 Jun 2026 14:58:32 +0200 (CEST) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager v2 1/6] pdm-api-types: task-cache: add NativeUpid::node() convenience getter Date: Mon, 15 Jun 2026 14:58:18 +0200 Message-ID: <20260615125823.193288-2-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260615125823.193288-1-l.wagner@proxmox.com> References: <20260615125823.193288-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: 1781528254781 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.053 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 Message-ID-Hash: CAHUVREWCQIWPFKQ4P557XP7YIKESO6J X-Message-ID-Hash: CAHUVREWCQIWPFKQ4P557XP7YIKESO6J 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: Some callers need to get the 'node' property of a UPID, but handle both, PBS and PVE equally, making a distinction at the call site inconvenient. Providing a 'node' getter in NativeUpid simplifies callers a little. Signed-off-by: Lukas Wagner --- Notes: Changes since v1: - Fold in the refactoring that actually uses the 'node()' helper into this commit, as suggested by Dominik. lib/pdm-api-types/src/remote_upid.rs | 10 +++++++++ server/src/remote_tasks/task_cache.rs | 32 ++++++++++----------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/lib/pdm-api-types/src/remote_upid.rs b/lib/pdm-api-types/src/remote_upid.rs index 1e90bef4..194e4a18 100644 --- a/lib/pdm-api-types/src/remote_upid.rs +++ b/lib/pdm-api-types/src/remote_upid.rs @@ -26,6 +26,16 @@ pub enum NativeUpid { PbsUpid(pbs_api_types::UPID), } +impl NativeUpid { + /// Convenience getter to query the 'node' property of a task. + pub fn node(&self) -> &str { + match self { + NativeUpid::PveUpid(upid) => upid.node.as_str(), + NativeUpid::PbsUpid(upid) => upid.node.as_str(), + } + } +} + impl RemoteUpid { /// Create a new remote UPID. pub fn new(remote: String, remote_type: RemoteType, upid: String) -> Self { diff --git a/server/src/remote_tasks/task_cache.rs b/server/src/remote_tasks/task_cache.rs index b8122d6a..412ee770 100644 --- a/server/src/remote_tasks/task_cache.rs +++ b/server/src/remote_tasks/task_cache.rs @@ -15,7 +15,7 @@ use serde::{Deserialize, Serialize}; use proxmox_sys::fs::CreateOptions; -use pdm_api_types::{NativeUpid, RemoteUpid}; +use pdm_api_types::RemoteUpid; /// Filename for the file containing running tasks. const ACTIVE_FILENAME: &str = "active"; @@ -404,27 +404,19 @@ impl WritableTaskCache { // Remove this finished task from our set of active tasks. active_tasks.remove(&task.upid); - match task.upid.native_upid() { - Ok(NativeUpid::PveUpid(upid)) => { - let node = &upid.node; - let remote = task.upid.remote(); - - if node_success_map.node_successful(remote, node) { - state.update_cutoff_timestamp(remote, node, task.starttime); - } - } - Ok(NativeUpid::PbsUpid(upid)) => { - let node = &upid.node; - let remote = task.upid.remote(); - - if node_success_map.node_successful(remote, node) { - state.update_cutoff_timestamp(remote, node, task.starttime); - } - } - Err(error) => { - log::error!("could not parse PVE UPID - not saving to task cache: {error:#}"); + let native_upid = match task.upid.native_upid() { + Ok(native_upid) => native_upid, + Err(err) => { + log::error!("could not parse UPID - not saving to task cache: {err:#}"); continue; } + }; + + let node = native_upid.node(); + let remote = task.upid.remote(); + + if node_success_map.node_successful(remote, node) { + state.update_cutoff_timestamp(remote, node, task.starttime); } serde_json::to_writer(&mut file, &task)?; -- 2.47.3