]> git.proxmox.com Git - proxmox-backup.git/commitdiff
verify job: support max-depth config
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 11 May 2022 07:43:10 +0000 (09:43 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 12 May 2022 07:33:50 +0000 (09:33 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
pbs-api-types/src/jobs.rs
src/api2/config/verify.rs
src/server/verify_job.rs

index 46ae4fe2af56d62a03b4841ddbe597444a582469..87009b3ab066380aa670cd2493f4ee0445712fd2 100644 (file)
@@ -186,6 +186,10 @@ pub const VERIFICATION_OUTDATED_AFTER_SCHEMA: Schema =
             optional: true,
             schema: BACKUP_NAMESPACE_SCHEMA,
         },
+        "max-depth": {
+            optional: true,
+            schema: crate::NS_MAX_DEPTH_SCHEMA,
+        },
     }
 )]
 #[derive(Serialize, Deserialize, Updater)]
@@ -212,6 +216,10 @@ pub struct VerificationJobConfig {
     #[serde(skip_serializing_if = "Option::is_none", default)]
     /// on which backup namespace to run the verification recursively
     pub ns: Option<BackupNamespace>,
+    #[serde(skip_serializing_if = "Option::is_none", default)]
+    /// how deep the verify should go from the `ns` level downwards. Passing 0 verifies only the
+    /// snapshots on the same level as the passed `ns`, or the datastore root if none.
+    pub max_depth: Option<usize>,
 }
 
 #[api(
index dc188300f3f143529d9f4ec345098d716038647c..b7d1ffd488783c65922c2aaf7cf1eb3421cdff88 100644 (file)
@@ -157,6 +157,8 @@ pub enum DeletableProperty {
     OutdatedAfter,
     /// Delete namespace property, defaulting to root namespace then.
     Ns,
+    /// Delete max-depth property, defaulting to full recursion again
+    MaxDepth,
 }
 
 #[api(
@@ -239,6 +241,9 @@ pub fn update_verification_job(
                 DeletableProperty::Ns => {
                     data.ns = None;
                 }
+                DeletableProperty::MaxDepth => {
+                    data.max_depth = None;
+                }
             }
         }
     }
@@ -278,6 +283,11 @@ pub fn update_verification_job(
             data.ns = Some(ns);
         }
     }
+    if let Some(max_depth) = update.max_depth {
+        if max_depth <= pbs_api_types::MAX_NAMESPACE_DEPTH {
+            data.max_depth = Some(max_depth);
+        }
+    }
 
     config.set_data(&id, "verification", &data)?;
 
index cf3e154f5523893cfd47683025a8ac26fe610164..a861cd314ad4e9b31f94f65ec1a8d0706e79b38c 100644 (file)
@@ -50,7 +50,7 @@ pub fn do_verification_job(
                 &verify_worker,
                 worker.upid(),
                 ns,
-                None,
+                verification_job.max_depth,
                 None,
                 Some(&move |manifest| {
                     verify_filter(ignore_verified_snapshots, outdated_after, manifest)