From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH datacenter-manager 2/4] api: remotes: report whether a remote is a cluster in the list
Date: Tue, 1 Dec 2026 16:12:06 +0100 [thread overview]
Message-ID: <20261201151531.3348382-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261201151531.3348382-1-d.csapak@proxmox.com>
so that clients like the UI get it together with the rest of the
remote list, which is polled regularly anyway.
Since `Remote` is the section config type, add a new `ListedRemote`
type that flattens it and adds the optional 'cluster' property, which
is omitted for PVE remotes as long as none of their endpoints
answered. PBS remotes are never clusters.
`ListedRemote` derefs to `Remote`, so that users can access the
config properties directly.
Existing clients that deserialize the list into `Remote` keep working,
since the new property is ignored.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
lib/pdm-api-types/src/remotes.rs | 20 ++++++++++++++++++++
server/src/api/remotes/mod.rs | 18 +++++++++++++-----
server/tests/test_remote_home.rs | 2 +-
3 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/lib/pdm-api-types/src/remotes.rs b/lib/pdm-api-types/src/remotes.rs
index e6b5f47f..d583e608 100644
--- a/lib/pdm-api-types/src/remotes.rs
+++ b/lib/pdm-api-types/src/remotes.rs
@@ -164,6 +164,26 @@ impl Remote {
}
}
+#[api(properties: { remote: { flatten: true, type: Remote } })]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
+#[serde(rename_all = "kebab-case")]
+/// A remote in the list of remotes, with what was last learned about it.
+pub struct ListedRemote {
+ #[serde(flatten)]
+ pub remote: Remote,
+ /// Whether the remote is a cluster. Unknown until one of its endpoints answered.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub cluster: Option<bool>,
+}
+
+impl std::ops::Deref for ListedRemote {
+ type Target = Remote;
+
+ fn deref(&self) -> &Self::Target {
+ &self.remote
+ }
+}
+
#[api]
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
diff --git a/server/src/api/remotes/mod.rs b/server/src/api/remotes/mod.rs
index 7b218f98..bb30b243 100644
--- a/server/src/api/remotes/mod.rs
+++ b/server/src/api/remotes/mod.rs
@@ -23,8 +23,8 @@ use proxmox_time::{epoch_i64, epoch_to_rfc2822};
use pbs_api_types::{Tokenname, Userid};
use pdm_api_types::folders::FOLDER_PATH_SCHEMA;
use pdm_api_types::remotes::{
- CREATE_TOKEN_SCHEMA, DeletableRemoteProperty, REMOTE_ID_SCHEMA, Remote, RemoteType,
- RemoteUpdater, TlsProbeOutcome,
+ CREATE_TOKEN_SCHEMA, DeletableRemoteProperty, ListedRemote, REMOTE_ID_SCHEMA, Remote,
+ RemoteType, RemoteUpdater, TlsProbeOutcome,
};
use pdm_api_types::rrddata::RemoteDatapoint;
use pdm_api_types::{
@@ -33,6 +33,7 @@ use pdm_api_types::{
use pve_api_types::ClusterOptionsTokenPolicy;
use crate::metric_collection::trigger_remote_metric_collection;
+use crate::remote_cache::RemoteMappingCache;
use crate::{connection, pbs_client, remote_error};
use super::pve;
@@ -310,7 +311,7 @@ impl IntoIterator for RemoteIterator {
description: "The list of configured remotes.",
type: Array,
items: {
- type: Remote,
+ type: ListedRemote,
},
},
)]
@@ -319,15 +320,22 @@ pub fn list_remotes(
folder: Option<String>,
rpcenv: &mut dyn RpcEnvironment,
#[state] app: PdmApplication,
-) -> Result<Vec<Remote>, Error> {
+) -> Result<Vec<ListedRemote>, Error> {
let scope = ReadScope::resolve(rpcenv, &app, None, folder.as_deref())?;
let (remotes, digest) = scope.access().remote_config()?;
rpcenv["digest"] = digest.to_hex().into();
+ let cache = RemoteMappingCache::get();
Ok(remotes
.into_iter()
.filter(|(name, _)| scope.lists_remote(name))
- .map(|(_, remote)| visible_config(remote, scope.access()))
+ .map(|(_, remote)| ListedRemote {
+ cluster: match remote.ty {
+ RemoteType::Pve => cache.is_cluster(&remote.id),
+ RemoteType::Pbs => Some(false),
+ },
+ remote: visible_config(remote, scope.access()),
+ })
.collect())
}
diff --git a/server/tests/test_remote_home.rs b/server/tests/test_remote_home.rs
index 0f4a703a..a9f75bf0 100644
--- a/server/tests/test_remote_home.rs
+++ b/server/tests/test_remote_home.rs
@@ -155,7 +155,7 @@ async fn remote_reads_hide_the_token_and_placement_from_non_admins() -> Result<(
set_admin(false);
let env = &mut common::rpcenv_as(MANAGER, app);
for remote in [
- list_remotes(None, env, app.clone())?.pop().unwrap(),
+ list_remotes(None, env, app.clone())?.pop().unwrap().remote,
remote_config("onboard".into(), env, app.clone())?,
] {
assert!(remote.token.is_empty());
--
2.47.3
next prev parent reply other threads:[~2026-12-01 15:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 15:12 [PATCH datacenter-manager 0/4] api/ui: show consistent remote icons Dominik Csapak
2026-12-01 15:12 ` [PATCH datacenter-manager 1/4] server: remote mapping: remember whether a pve remote is a cluster Dominik Csapak
2026-12-01 15:12 ` Dominik Csapak [this message]
2026-12-01 15:12 ` [PATCH datacenter-manager 3/4] pdm-client: return the cluster flag with the remote list Dominik Csapak
2026-12-01 15:12 ` [PATCH datacenter-manager 4/4] ui: use consistent icons for the types of remotes Dominik Csapak
2026-12-01 18:29 ` applied: [PATCH datacenter-manager 0/4] api/ui: show consistent remote icons 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=20261201151531.3348382-3-d.csapak@proxmox.com \
--to=d.csapak@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