From: Lukas Wagner <l.wagner@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [RFC datacenter-manager 8/8] remote task cache: handle PBS tasks correctly
Date: Tue, 11 Nov 2025 11:50:59 +0100 [thread overview]
Message-ID: <20251111105059.148997-9-l.wagner@proxmox.com> (raw)
In-Reply-To: <20251111105059.148997-1-l.wagner@proxmox.com>
The remote task cache assumed in some cases that all UPIDs were PVE
UPIDs; mostly for simplicity, since PBS remotes were not implemented yet
at the time of implementation of the task cache.
The new remote_type and native_upid functions for the RemoteUpid struct
makes it pretty simple to add support for PBS.
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
server/src/remote_tasks/mod.rs | 21 ++++++++++++++++-----
server/src/remote_tasks/task_cache.rs | 19 ++++++++++++-------
2 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/server/src/remote_tasks/mod.rs b/server/src/remote_tasks/mod.rs
index 37e689e0..f39d0b77 100644
--- a/server/src/remote_tasks/mod.rs
+++ b/server/src/remote_tasks/mod.rs
@@ -2,7 +2,7 @@ use std::path::Path;
use anyhow::Error;
-use pdm_api_types::{RemoteUpid, TaskFilters, TaskListItem, TaskStateType};
+use pdm_api_types::{NativeUpid, RemoteUpid, TaskFilters, TaskListItem, TaskStateType};
use pve_api_types::PveUpid;
pub mod task_cache;
@@ -52,10 +52,9 @@ pub async fn get_tasks(
return None;
}
}
- // TODO: Handle PBS tasks
- let pve_upid: Result<PveUpid, Error> = task.upid.upid().parse();
- match pve_upid {
- Ok(pve_upid) => Some(TaskListItem {
+
+ match task.upid.native_upid() {
+ Ok(NativeUpid::PveUpid(pve_upid)) => Some(TaskListItem {
upid: task.upid.to_string(),
node: pve_upid.node,
pid: pve_upid.pid as i64,
@@ -67,6 +66,18 @@ pub async fn get_tasks(
endtime: task.endtime,
status: task.status,
}),
+ Ok(NativeUpid::PbsUpid(pbs_upid)) => Some(TaskListItem {
+ upid: task.upid.to_string(),
+ node: pbs_upid.node,
+ pid: pbs_upid.pid as i64,
+ pstart: pbs_upid.pstart,
+ starttime: pbs_upid.starttime,
+ worker_type: pbs_upid.worker_type,
+ worker_id: pbs_upid.worker_id,
+ user: pbs_upid.auth_id,
+ endtime: task.endtime,
+ status: task.status,
+ }),
Err(err) => {
log::error!("could not parse UPID: {err:#}");
None
diff --git a/server/src/remote_tasks/task_cache.rs b/server/src/remote_tasks/task_cache.rs
index cb3b6687..1eee46a6 100644
--- a/server/src/remote_tasks/task_cache.rs
+++ b/server/src/remote_tasks/task_cache.rs
@@ -15,8 +15,7 @@ use serde::{Deserialize, Serialize};
use proxmox_sys::fs::CreateOptions;
-use pdm_api_types::RemoteUpid;
-use pve_api_types::PveUpid;
+use pdm_api_types::{NativeUpid, RemoteUpid};
/// Filename for the file containing running tasks.
const ACTIVE_FILENAME: &str = "active";
@@ -405,15 +404,21 @@ impl WritableTaskCache {
// Remove this finished task from our set of active tasks.
active_tasks.remove(&task.upid);
- // TODO:: Handle PBS tasks correctly.
- // TODO: This is awkward, maybe overhaul RemoteUpid type to make this easier
- match task.upid.upid().parse::<PveUpid>() {
- Ok(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(task.upid.remote(), node, task.starttime);
+ 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) => {
--
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-11-11 10:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-11 10:50 [pdm-devel] [PATCH/RFC datacenter-manager 0/8] add type field to RemoteUpid Lukas Wagner
2025-11-11 10:50 ` [pdm-devel] [PATCH datacenter-manager 1/8] pdm-api-types: move RemoteUpid to its own module Lukas Wagner
2025-11-11 10:50 ` [pdm-devel] [PATCH datacenter-manager 2/8] pdm-api-types: remote upid: make upid field private Lukas Wagner
2025-11-11 10:50 ` [pdm-devel] [PATCH datacenter-manager 3/8] pdm-api-types: remote upid: add missing doc strings Lukas Wagner
2025-11-11 10:50 ` [pdm-devel] [PATCH datacenter-manager 4/8] pdm-api-types: remote upid: add basic tests for RemoteUpid ser/deserialization Lukas Wagner
2025-11-11 10:50 ` [pdm-devel] [RFC datacenter-manager 5/8] pdm-api-types: remote upid: add type field to RemoteUpid Lukas Wagner
2025-11-12 20:00 ` Thomas Lamprecht
2025-11-11 10:50 ` [pdm-devel] [RFC datacenter-manager 6/8] pdm-api-types: remote upid: allow to get native UPID type Lukas Wagner
2025-11-11 10:50 ` [pdm-devel] [RFC datacenter-manager 7/8] ui: remote tasks: use correct base url for PBS tasks Lukas Wagner
2025-11-11 10:50 ` Lukas Wagner [this message]
2025-11-12 15:50 ` [pdm-devel] [PATCH/RFC datacenter-manager 0/8] add type field to RemoteUpid Shannon Sterz
2025-11-12 20:27 ` [pdm-devel] applied-series: " Thomas Lamprecht
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=20251111105059.148997-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox