server/prune_job: factor out 'prune_datastore'
we want to use that outside of a prune job Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
9751ef4b36
commit
61f05679d2
@ -1,6 +1,6 @@
|
||||
use anyhow::Error;
|
||||
use std::sync::Arc;
|
||||
|
||||
use proxmox::try_block;
|
||||
use anyhow::Error;
|
||||
|
||||
use pbs_datastore::{task_log, task_warn};
|
||||
|
||||
@ -11,31 +11,14 @@ use crate::{
|
||||
server::WorkerTask,
|
||||
};
|
||||
|
||||
pub fn do_prune_job(
|
||||
mut job: Job,
|
||||
pub fn prune_datastore(
|
||||
worker: Arc<WorkerTask>,
|
||||
prune_options: PruneOptions,
|
||||
store: String,
|
||||
auth_id: &Authid,
|
||||
schedule: Option<String>,
|
||||
) -> Result<String, Error> {
|
||||
let datastore = DataStore::lookup_datastore(&store)?;
|
||||
|
||||
let worker_type = job.jobtype().to_string();
|
||||
let upid_str = WorkerTask::new_thread(
|
||||
&worker_type,
|
||||
Some(job.jobname().to_string()),
|
||||
auth_id.clone(),
|
||||
false,
|
||||
move |worker| {
|
||||
job.start(&worker.upid().to_string())?;
|
||||
|
||||
let result = try_block!({
|
||||
store: &str,
|
||||
datastore: Arc<DataStore>,
|
||||
) -> Result<(), Error> {
|
||||
task_log!(worker, "Starting datastore prune on store \"{}\"", store);
|
||||
|
||||
if let Some(event_str) = schedule {
|
||||
task_log!(worker, "task triggered by schedule '{}'", event_str);
|
||||
}
|
||||
|
||||
task_log!(
|
||||
worker,
|
||||
"retention options: {}",
|
||||
@ -79,8 +62,33 @@ pub fn do_prune_job(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
pub fn do_prune_job(
|
||||
mut job: Job,
|
||||
prune_options: PruneOptions,
|
||||
store: String,
|
||||
auth_id: &Authid,
|
||||
schedule: Option<String>,
|
||||
) -> Result<String, Error> {
|
||||
let datastore = DataStore::lookup_datastore(&store)?;
|
||||
|
||||
let worker_type = job.jobtype().to_string();
|
||||
let upid_str = WorkerTask::new_thread(
|
||||
&worker_type,
|
||||
Some(job.jobname().to_string()),
|
||||
auth_id.clone(),
|
||||
false,
|
||||
move |worker| {
|
||||
job.start(&worker.upid().to_string())?;
|
||||
|
||||
if let Some(event_str) = schedule {
|
||||
task_log!(worker, "task triggered by schedule '{}'", event_str);
|
||||
}
|
||||
|
||||
let result = prune_datastore(worker.clone(), prune_options, &store, datastore);
|
||||
|
||||
let status = worker.create_state(&result);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user