api proxy: remove old verification scheduling

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
This commit is contained in:
Hannes Laimer 2020-10-20 11:10:11 +02:00 committed by Thomas Lamprecht
parent df0bdf6be7
commit 2ef1b6290f
5 changed files with 1 additions and 156 deletions

View File

@ -75,10 +75,6 @@ pub fn list_datastores(
optional: true, optional: true,
schema: PRUNE_SCHEDULE_SCHEMA, schema: PRUNE_SCHEDULE_SCHEMA,
}, },
"verify-schedule": {
optional: true,
schema: VERIFICATION_SCHEDULE_SCHEMA,
},
"keep-last": { "keep-last": {
optional: true, optional: true,
schema: PRUNE_SCHEMA_KEEP_LAST, schema: PRUNE_SCHEMA_KEEP_LAST,
@ -133,7 +129,6 @@ pub fn create_datastore(param: Value) -> Result<(), Error> {
crate::config::jobstate::create_state_file("prune", &datastore.name)?; crate::config::jobstate::create_state_file("prune", &datastore.name)?;
crate::config::jobstate::create_state_file("garbage_collection", &datastore.name)?; crate::config::jobstate::create_state_file("garbage_collection", &datastore.name)?;
crate::config::jobstate::create_state_file("verify", &datastore.name)?;
Ok(()) Ok(())
} }
@ -179,8 +174,6 @@ pub enum DeletableProperty {
gc_schedule, gc_schedule,
/// Delete the prune job schedule. /// Delete the prune job schedule.
prune_schedule, prune_schedule,
/// Delete the verify schedule property
verify_schedule,
/// Delete the keep-last property /// Delete the keep-last property
keep_last, keep_last,
/// Delete the keep-hourly property /// Delete the keep-hourly property
@ -214,10 +207,6 @@ pub enum DeletableProperty {
optional: true, optional: true,
schema: PRUNE_SCHEDULE_SCHEMA, schema: PRUNE_SCHEDULE_SCHEMA,
}, },
"verify-schedule": {
optional: true,
schema: VERIFICATION_SCHEDULE_SCHEMA,
},
"keep-last": { "keep-last": {
optional: true, optional: true,
schema: PRUNE_SCHEMA_KEEP_LAST, schema: PRUNE_SCHEMA_KEEP_LAST,
@ -266,7 +255,6 @@ pub fn update_datastore(
comment: Option<String>, comment: Option<String>,
gc_schedule: Option<String>, gc_schedule: Option<String>,
prune_schedule: Option<String>, prune_schedule: Option<String>,
verify_schedule: Option<String>,
keep_last: Option<u64>, keep_last: Option<u64>,
keep_hourly: Option<u64>, keep_hourly: Option<u64>,
keep_daily: Option<u64>, keep_daily: Option<u64>,
@ -295,7 +283,6 @@ pub fn update_datastore(
DeletableProperty::comment => { data.comment = None; }, DeletableProperty::comment => { data.comment = None; },
DeletableProperty::gc_schedule => { data.gc_schedule = None; }, DeletableProperty::gc_schedule => { data.gc_schedule = None; },
DeletableProperty::prune_schedule => { data.prune_schedule = None; }, DeletableProperty::prune_schedule => { data.prune_schedule = None; },
DeletableProperty::verify_schedule => { data.verify_schedule = None; },
DeletableProperty::keep_last => { data.keep_last = None; }, DeletableProperty::keep_last => { data.keep_last = None; },
DeletableProperty::keep_hourly => { data.keep_hourly = None; }, DeletableProperty::keep_hourly => { data.keep_hourly = None; },
DeletableProperty::keep_daily => { data.keep_daily = None; }, DeletableProperty::keep_daily => { data.keep_daily = None; },
@ -327,12 +314,6 @@ pub fn update_datastore(
data.prune_schedule = prune_schedule; data.prune_schedule = prune_schedule;
} }
let mut verify_schedule_changed = false;
if verify_schedule.is_some() {
verify_schedule_changed = data.verify_schedule != verify_schedule;
data.verify_schedule = verify_schedule;
}
if keep_last.is_some() { data.keep_last = keep_last; } if keep_last.is_some() { data.keep_last = keep_last; }
if keep_hourly.is_some() { data.keep_hourly = keep_hourly; } if keep_hourly.is_some() { data.keep_hourly = keep_hourly; }
if keep_daily.is_some() { data.keep_daily = keep_daily; } if keep_daily.is_some() { data.keep_daily = keep_daily; }
@ -354,10 +335,6 @@ pub fn update_datastore(
crate::config::jobstate::create_state_file("prune", &name)?; crate::config::jobstate::create_state_file("prune", &name)?;
} }
if verify_schedule_changed {
crate::config::jobstate::create_state_file("verify", &name)?;
}
Ok(()) Ok(())
} }
@ -400,7 +377,6 @@ pub fn delete_datastore(name: String, digest: Option<String>) -> Result<(), Erro
// ignore errors // ignore errors
let _ = crate::config::jobstate::remove_state_file("prune", &name); let _ = crate::config::jobstate::remove_state_file("prune", &name);
let _ = crate::config::jobstate::remove_state_file("garbage_collection", &name); let _ = crate::config::jobstate::remove_state_file("garbage_collection", &name);
let _ = crate::config::jobstate::remove_state_file("verify", &name);
Ok(()) Ok(())
} }

View File

@ -212,7 +212,6 @@ async fn schedule_tasks() -> Result<(), Error> {
schedule_datastore_garbage_collection().await; schedule_datastore_garbage_collection().await;
schedule_datastore_prune().await; schedule_datastore_prune().await;
schedule_datastore_verification().await;
schedule_datastore_sync_jobs().await; schedule_datastore_sync_jobs().await;
schedule_datastore_verify_jobs().await; schedule_datastore_verify_jobs().await;
schedule_task_log_rotate().await; schedule_task_log_rotate().await;
@ -486,121 +485,6 @@ async fn schedule_datastore_prune() {
} }
} }
async fn schedule_datastore_verification() {
use proxmox_backup::backup::{DataStore, verify_all_backups};
use proxmox_backup::server::{WorkerTask};
use proxmox_backup::config::{
jobstate::{self, Job},
datastore::{self, DataStoreConfig}
};
use proxmox_backup::tools::systemd::time::{
parse_calendar_event, compute_next_event};
let config = match datastore::config() {
Err(err) => {
eprintln!("unable to read datastore config - {}", err);
return;
}
Ok((config, _digest)) => config,
};
for (store, (_, store_config)) in config.sections {
let datastore = match DataStore::lookup_datastore(&store) {
Ok(datastore) => datastore,
Err(err) => {
eprintln!("lookup_datastore failed - {}", err);
continue;
}
};
let store_config: DataStoreConfig = match serde_json::from_value(store_config) {
Ok(c) => c,
Err(err) => {
eprintln!("datastore config from_value failed - {}", err);
continue;
}
};
let event_str = match store_config.verify_schedule {
Some(event_str) => event_str,
None => continue,
};
let event = match parse_calendar_event(&event_str) {
Ok(event) => event,
Err(err) => {
eprintln!("unable to parse schedule '{}' - {}", event_str, err);
continue;
}
};
let worker_type = "verify";
let last = match jobstate::last_run_time(worker_type, &store) {
Ok(time) => time,
Err(err) => {
eprintln!("could not get last run time of {} {}: {}", worker_type, store, err);
continue;
}
};
let next = match compute_next_event(&event, last, false) {
Ok(Some(next)) => next,
Ok(None) => continue,
Err(err) => {
eprintln!("compute_next_event for '{}' failed - {}", event_str, err);
continue;
}
};
let now = proxmox::tools::time::epoch_i64();
if next > now { continue; }
let mut job = match Job::new(worker_type, &store) {
Ok(job) => job,
Err(_) => continue, // could not get lock
};
let worker_id = store.clone();
let store2 = store.clone();
if let Err(err) = WorkerTask::new_thread(
worker_type,
Some(worker_id),
Userid::backup_userid().clone(),
false,
move |worker| {
job.start(&worker.upid().to_string())?;
worker.log(format!("starting verification on store {}", store2));
worker.log(format!("task triggered by schedule '{}'", event_str));
let result = try_block!({
let failed_dirs =
verify_all_backups(datastore, worker.clone(), worker.upid())?;
if failed_dirs.len() > 0 {
worker.log("Failed to verify following snapshots:");
for dir in failed_dirs {
worker.log(format!("\t{}", dir));
}
Err(format_err!("verification failed - please check the log for details"))
} else {
Ok(())
}
});
let status = worker.create_state(&result);
if let Err(err) = job.finish(status) {
eprintln!("could not finish job state for {}: {}", worker_type, err);
}
result
},
) {
eprintln!("unable to start verification on store {} - {}", store, err);
}
}
}
async fn schedule_datastore_sync_jobs() { async fn schedule_datastore_sync_jobs() {
use proxmox_backup::{ use proxmox_backup::{

View File

@ -44,10 +44,6 @@ pub const DIR_NAME_SCHEMA: Schema = StringSchema::new("Directory name").schema()
optional: true, optional: true,
schema: PRUNE_SCHEDULE_SCHEMA, schema: PRUNE_SCHEDULE_SCHEMA,
}, },
"verify-schedule": {
optional: true,
schema: VERIFICATION_SCHEDULE_SCHEMA,
},
"keep-last": { "keep-last": {
optional: true, optional: true,
schema: PRUNE_SCHEMA_KEEP_LAST, schema: PRUNE_SCHEMA_KEEP_LAST,
@ -91,8 +87,6 @@ pub struct DataStoreConfig {
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub prune_schedule: Option<String>, pub prune_schedule: Option<String>,
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub verify_schedule: Option<String>,
#[serde(skip_serializing_if="Option::is_none")]
pub keep_last: Option<u64>, pub keep_last: Option<u64>,
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub keep_hourly: Option<u64>, pub keep_hourly: Option<u64>,

View File

@ -12,7 +12,7 @@ Ext.define('pbs-data-store-config', {
extend: 'Ext.data.Model', extend: 'Ext.data.Model',
fields: [ fields: [
'name', 'path', 'comment', 'gc-schedule', 'prune-schedule', 'name', 'path', 'comment', 'gc-schedule', 'prune-schedule',
'verify-schedule', 'keep-last', 'keep-hourly', 'keep-daily', 'keep-last', 'keep-hourly', 'keep-daily',
'keep-weekly', 'keep-monthly', 'keep-yearly', 'keep-weekly', 'keep-monthly', 'keep-yearly',
], ],
proxy: { proxy: {

View File

@ -77,15 +77,6 @@ Ext.define('PBS.DataStoreEdit', {
deleteEmpty: '{!isCreate}', deleteEmpty: '{!isCreate}',
}, },
}, },
{
xtype: 'pbsCalendarEvent',
name: 'verify-schedule',
fieldLabel: gettext("Verify Schedule"),
emptyText: gettext('none'),
cbind: {
deleteEmpty: '{!isCreate}',
},
},
], ],
columnB: [ columnB: [
{ {