public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Erik Fastermann <e.fastermann@proxmox.com>
To: pbs-devel@lists.proxmox.com
Cc: Erik Fastermann <e.fastermann@proxmox.com>
Subject: [PATCH proxmox-backup 5/5] report: list the accessible s3 buckets
Date: Wed,  9 Sep 2026 13:12:28 +0200	[thread overview]
Message-ID: <20260909111228.217535-6-e.fastermann@proxmox.com> (raw)
In-Reply-To: <20260909111228.217535-1-e.fastermann@proxmox.com>

This shows whether the configured credentials still work, whether the
endpoint is reachable and which buckets are reported.

Implemented as a report function rather than as a command to set a
timeout and query the endpoints concurrently.

Signed-off-by: Erik Fastermann <e.fastermann@proxmox.com>
---
 src/server/report.rs | 78 +++++++++++++++++++++++++++++++++++++-------
 1 file changed, 67 insertions(+), 11 deletions(-)

diff --git a/src/server/report.rs b/src/server/report.rs
index b123c1fa9..a454b52bc 100644
--- a/src/server/report.rs
+++ b/src/server/report.rs
@@ -1,5 +1,14 @@
+use std::fmt::Write;
+use std::time::Duration;
+
+use futures::future::join_all;
+
 use proxmox_system_report::{FileGroup, FunctionMapping, StaticArgsCommandSpec};
 
+use crate::api2::config::s3::list_buckets;
+
+const S3_LIST_BUCKETS_TIMEOUT: Duration = Duration::from_secs(5);
+
 fn project_files() -> Vec<FileGroup> {
     vec![
         ("Datastores", vec!["/etc/proxmox-backup/datastore.cfg"]),
@@ -53,19 +62,66 @@ fn project_commands() -> Vec<StaticArgsCommandSpec> {
     ]
 }
 
-fn project_function_calls() -> Vec<FunctionMapping> {
-    vec![("Datastores", || {
-        let config = match pbs_config::datastore::config() {
-            Ok((config, _digest)) => config,
-            _ => return String::from("could not read datastore config"),
+fn s3_buckets() -> String {
+    let config = match pbs_config::s3::config() {
+        Ok((config, _digest)) => config,
+        Err(err) => return format!("*error*: could not read s3 config: {err:#}"),
+    };
+    if config.order.is_empty() {
+        return String::from("*note*: no s3 endpoints configured");
+    }
+
+    let listings = proxmox_async::runtime::block_on(async {
+        join_all(
+            config
+                .order
+                .iter()
+                .map(|id| tokio::time::timeout(S3_LIST_BUCKETS_TIMEOUT, list_buckets(id.clone()))),
+        )
+        .await
+    });
+
+    let mut out = String::new();
+
+    for (id, listing) in config.order.iter().zip(listings) {
+        writeln!(out, "\n###### {id}").unwrap();
+
+        match listing {
+            Ok(Ok(buckets)) if buckets.is_empty() => {
+                writeln!(out, "*note*: endpoint reported no buckets").unwrap()
+            }
+            Ok(Ok(buckets)) => buckets
+                .into_iter()
+                .for_each(|bucket| writeln!(out, "- {}", bucket.name).unwrap()),
+            Ok(Err(err)) => writeln!(out, "*error*: {err:#}").unwrap(),
+            Err(_timeout) => writeln!(
+                out,
+                "*error*: timed out after {} seconds",
+                S3_LIST_BUCKETS_TIMEOUT.as_secs(),
+            )
+            .unwrap(),
         };
+    }
+
+    out
+}
 
-        let mut list = Vec::new();
-        for store in config.sections.keys() {
-            list.push(store.as_str());
-        }
-        format!("```\n{}\n```", list.join(", "))
-    })]
+fn project_function_calls() -> Vec<FunctionMapping> {
+    vec![
+        ("Datastores", || {
+            let config = match pbs_config::datastore::config() {
+                Ok((config, _digest)) => config,
+                _ => return String::from("could not read datastore config"),
+            };
+
+            let mut list = Vec::new();
+            for store in config.sections.keys() {
+                list.push(store.as_str());
+            }
+            format!("```\n{}\n```", list.join(", "))
+        }),
+        ("S3 Buckets", s3_buckets),
+    ]
 }
 
 pub fn generate_report() -> String {
-- 
2.47.3




      parent reply	other threads:[~2026-09-09 11:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09 11:12 [PATCH proxmox-backup 0/5] report: cover the s3 configuration Erik Fastermann
2026-09-09 11:12 ` [PATCH proxmox-backup 1/5] report: rename mislabeled datastore file group Erik Fastermann
2026-09-09 11:12 ` [PATCH proxmox-backup 2/5] report: do not include remote passwords Erik Fastermann
2026-09-09 11:12 ` [PATCH proxmox-backup 3/5] report: include the s3 endpoint configuration Erik Fastermann
2026-09-09 11:12 ` [PATCH proxmox-backup 4/5] api: s3: drop unused rpcenv parameter from bucket listing Erik Fastermann
2026-09-09 11:12 ` Erik Fastermann [this message]

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=20260909111228.217535-6-e.fastermann@proxmox.com \
    --to=e.fastermann@proxmox.com \
    --cc=pbs-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal