verify job: support max-depth config

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-05-11 09:43:10 +02:00
parent 59229bd7f1
commit 0b1edf297b
3 changed files with 19 additions and 1 deletions

View 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(

View 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)?;

View 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)