From: Lukas Wagner <l.wagner@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager v2 08/13] task cache: use separate functions for tracking PVE and PBS tasks
Date: Fri, 17 Oct 2025 14:10:04 +0200 [thread overview]
Message-ID: <20251017121009.212499-9-l.wagner@proxmox.com> (raw)
In-Reply-To: <20251017121009.212499-1-l.wagner@proxmox.com>
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 <l.wagner@proxmox.com>
Reviewed-by: Shannon Sterz <s.sterz@proxmox.com>
Tested-by: Shannon Sterz <s.sterz@proxmox.com>
---
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<RemoteUpid, Error> {
- 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<RemoteUpid, Error> {
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<RemoteUpid, Error> {
+ 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
next prev parent reply other threads:[~2025-10-17 12:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 12:09 [pdm-devel] [PATCH datacenter-manager v2 00/13] add global remote update view Lukas Wagner
2025-10-17 12:09 ` [pdm-devel] [PATCH datacenter-manager v2 01/13] metric collection task: tests: add missing parameter for cluster_metric_export Lukas Wagner
2025-10-21 19:24 ` [pdm-devel] applied: " Thomas Lamprecht
2025-10-17 12:09 ` [pdm-devel] [PATCH datacenter-manager v2 02/13] pdm-api-types: add types for remote upgrade summary Lukas Wagner
2025-10-17 12:09 ` [pdm-devel] [PATCH datacenter-manager v2 03/13] remote updates: add cache for remote update availability Lukas Wagner
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 04/13] api: add API for retrieving/refreshing the remote update summary Lukas Wagner
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 05/13] unprivileged api daemon: tasks: add remote update refresh task Lukas Wagner
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 06/13] pdm-client: add API methods for remote update summaries Lukas Wagner
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 07/13] pbs-client: add bindings for APT-related API calls Lukas Wagner
2025-10-17 12:10 ` Lukas Wagner [this message]
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 09/13] remote updates: add support for PBS remotes Lukas Wagner
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 10/13] api: add APT endpoints " Lukas Wagner
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 11/13] ui: add remote update view Lukas Wagner
2025-10-21 19:18 ` Thomas Lamprecht
2025-10-22 10:22 ` Lukas Wagner
2025-10-23 8:36 ` Thomas Lamprecht
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 12/13] ui: show new remote update view in the 'Remotes' section Lukas Wagner
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 13/13] remote updates: avoid unnecessary clone Lukas Wagner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251017121009.212499-9-l.wagner@proxmox.com \
--to=l.wagner@proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.