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 723861FF179 for ; Wed, 15 Oct 2025 14:47:36 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 206911B230; Wed, 15 Oct 2025 14:47:56 +0200 (CEST) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Date: Wed, 15 Oct 2025 14:47:07 +0200 Message-ID: <20251015124711.312943-9-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251015124711.312943-1-l.wagner@proxmox.com> References: <20251015124711.312943-1-l.wagner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1760532437667 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.027 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 Subject: [pdm-devel] [PATCH proxmox-datacenter-manager 08/12] task cache: use separate functions for tracking PVE and PBS tasks X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" At the callsite we always know which type of remote it is, so there is no need to deduce the type from the UPID itself. Signed-off-by: Lukas Wagner --- server/src/api/pve/mod.rs | 3 +-- server/src/remote_tasks/mod.rs | 45 ++++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/server/src/api/pve/mod.rs b/server/src/api/pve/mod.rs index 0de82323..a94ab8d0 100644 --- a/server/src/api/pve/mod.rs +++ b/server/src/api/pve/mod.rs @@ -84,8 +84,7 @@ const STATUS_ROUTER: Router = Router::new().get(&API_METHOD_CLUSTER_STATUS); // converts a remote + PveUpid into a RemoteUpid and starts tracking it pub async fn new_remote_upid(remote: String, upid: PveUpid) -> Result { - let remote_upid: RemoteUpid = (remote, upid.to_string()).try_into()?; - remote_tasks::track_running_task(remote_upid.clone()).await?; + let remote_upid = remote_tasks::track_running_pve_task(remote, upid).await?; Ok(remote_upid) } diff --git a/server/src/remote_tasks/mod.rs b/server/src/remote_tasks/mod.rs index b3adebe2..c4939742 100644 --- a/server/src/remote_tasks/mod.rs +++ b/server/src/remote_tasks/mod.rs @@ -126,22 +126,53 @@ pub async fn get_tasks( .await? } -/// Insert a newly created tasks into the list of tracked tasks. +/// Insert a newly created PVE task into the list of tracked tasks. /// /// Any tracked task will be polled with a short interval until the task /// has finished. -pub async fn track_running_task(task: RemoteUpid) -> Result<(), Error> { +/// +/// This function returns the [`RemoteUpid`] of the tracked PVE task. +pub async fn track_running_pve_task(remote: String, upid: PveUpid) -> Result { tokio::task::spawn_blocking(move || { + let remote_upid: RemoteUpid = (remote, upid.to_string()).try_into()?; let cache = get_cache()?.write()?; - // TODO:: Handle PBS tasks correctly. - let pve_upid: pve_api_types::PveUpid = task.upid.parse()?; + let task = TaskCacheItem { - upid: task.clone(), - starttime: pve_upid.starttime, + upid: remote_upid.clone(), + starttime: upid.starttime, status: None, endtime: None, }; - cache.add_tracked_task(task) + cache.add_tracked_task(task)?; + + Ok(remote_upid) + }) + .await? +} + +/// Insert a newly created PBS task into the list of tracked tasks. +/// +/// Any tracked task will be polled with a short interval until the task +/// has finished. +/// +/// This function returns the [`RemoteUpid`] of the tracked PBS task. +pub async fn track_running_pbs_task( + remote: String, + upid: pbs_api_types::UPID, +) -> Result { + tokio::task::spawn_blocking(move || { + let remote_upid: RemoteUpid = (remote, upid.to_string()).try_into()?; + let cache = get_cache()?.write()?; + + let task = TaskCacheItem { + upid: remote_upid.clone(), + starttime: upid.starttime, + status: None, + endtime: None, + }; + cache.add_tracked_task(task)?; + + Ok(remote_upid) }) .await? } -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel