[pbs-devel] [RFC PATCH proxmox-backup 2/3] api: datastore: add upload_statistic to snapshot listing

Dominik Csapak d.csapak at proxmox.com
Tue Aug 1 11:29:53 CEST 2023


Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
instead we could make a seperate api call that return just detailed info
about a single snapshot on demand
 pbs-api-types/src/datastore.rs |  3 +++
 src/api2/admin/datastore.rs    | 22 +++++++++++++++++-----
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs
index 41db680c..39e3c09a 100644
--- a/pbs-api-types/src/datastore.rs
+++ b/pbs-api-types/src/datastore.rs
@@ -1138,6 +1138,9 @@ pub struct SnapshotListItem {
     /// Protection from prunes
     #[serde(default)]
     pub protected: bool,
+    /// Upload statistics
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub upload_statistic: Option<UploadStatistic>,
 }
 
 #[api(
diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
index a95031e7..f5b47cf4 100644
--- a/src/api2/admin/datastore.rs
+++ b/src/api2/admin/datastore.rs
@@ -35,11 +35,11 @@ use pbs_api_types::{
     print_ns_and_snapshot, print_store_and_ns, Authid, BackupContent, BackupNamespace, BackupType,
     Counts, CryptMode, DataStoreListItem, DataStoreStatus, GarbageCollectionStatus, GroupListItem,
     KeepOptions, Operation, PruneJobOptions, RRDMode, RRDTimeFrame, SnapshotListItem,
-    SnapshotVerifyState, BACKUP_ARCHIVE_NAME_SCHEMA, BACKUP_ID_SCHEMA, BACKUP_NAMESPACE_SCHEMA,
-    BACKUP_TIME_SCHEMA, BACKUP_TYPE_SCHEMA, DATASTORE_SCHEMA, IGNORE_VERIFIED_BACKUPS_SCHEMA,
-    MAX_NAMESPACE_DEPTH, NS_MAX_DEPTH_SCHEMA, PRIV_DATASTORE_AUDIT, PRIV_DATASTORE_BACKUP,
-    PRIV_DATASTORE_MODIFY, PRIV_DATASTORE_PRUNE, PRIV_DATASTORE_READ, PRIV_DATASTORE_VERIFY,
-    UPID_SCHEMA, VERIFICATION_OUTDATED_AFTER_SCHEMA,
+    SnapshotVerifyState, UploadStatistic, BACKUP_ARCHIVE_NAME_SCHEMA, BACKUP_ID_SCHEMA,
+    BACKUP_NAMESPACE_SCHEMA, BACKUP_TIME_SCHEMA, BACKUP_TYPE_SCHEMA, DATASTORE_SCHEMA,
+    IGNORE_VERIFIED_BACKUPS_SCHEMA, MAX_NAMESPACE_DEPTH, NS_MAX_DEPTH_SCHEMA, PRIV_DATASTORE_AUDIT,
+    PRIV_DATASTORE_BACKUP, PRIV_DATASTORE_MODIFY, PRIV_DATASTORE_PRUNE, PRIV_DATASTORE_READ,
+    PRIV_DATASTORE_VERIFY, UPID_SCHEMA, VERIFICATION_OUTDATED_AFTER_SCHEMA,
 };
 use pbs_client::pxar::{create_tar, create_zip};
 use pbs_config::CachedUserInfo;
@@ -532,6 +532,16 @@ unsafe fn list_snapshots_blocking(
 
                 let size = Some(files.iter().map(|x| x.size.unwrap_or(0)).sum());
 
+                let upload_statistic = manifest.unprotected["chunk_upload_stats"].clone();
+                let upload_statistic: Option<UploadStatistic> =
+                    match serde_json::from_value(upload_statistic) {
+                        Ok(stats) => stats,
+                        Err(err) => {
+                            log::warn!("error parsing chunk_upload_stats: {err}");
+                            None
+                        }
+                    };
+
                 SnapshotListItem {
                     backup,
                     comment,
@@ -541,6 +551,7 @@ unsafe fn list_snapshots_blocking(
                     size,
                     owner,
                     protected,
+                    upload_statistic,
                 }
             }
             Err(err) => {
@@ -564,6 +575,7 @@ unsafe fn list_snapshots_blocking(
                     size: None,
                     owner,
                     protected,
+                    upload_statistic: None,
                 }
             }
         }
-- 
2.30.2






More information about the pbs-devel mailing list