client/pull: log snapshots that are skipped because of time

we skip snapshots that are older than the newest snapshot of the group in
the target datastore, log it so the user can know why it is not synced

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-06-07 10:30:17 +02:00 committed by Dietmar Maurer
parent 34ee1f1c76
commit d2354a16cd
1 changed files with 57 additions and 0 deletions

View File

@ -14,6 +14,7 @@ use crate::{
backup::*, backup::*,
client::*, client::*,
server::WorkerTask, server::WorkerTask,
task_log,
tools::{compute_file_csum, ParallelHandler}, tools::{compute_file_csum, ParallelHandler},
}; };
use proxmox::api::error::{HttpError, StatusCode}; use proxmox::api::error::{HttpError, StatusCode};
@ -443,6 +444,51 @@ pub async fn pull_snapshot_from(
Ok(()) Ok(())
} }
struct SkipInfo {
oldest: i64,
newest: i64,
count: u64,
}
impl SkipInfo {
fn update(&mut self, backup_time: i64) {
self.count += 1;
if backup_time < self.oldest {
self.oldest = backup_time;
}
if backup_time > self.newest {
self.newest = backup_time;
}
}
fn affected(&self) -> Result<String, Error> {
match self.count {
0 => Ok(String::new()),
1 => proxmox::tools::time::epoch_to_rfc3339_utc(self.oldest),
_ => {
Ok(format!(
"{} .. {}",
proxmox::tools::time::epoch_to_rfc3339_utc(self.oldest)?,
proxmox::tools::time::epoch_to_rfc3339_utc(self.newest)?,
))
}
}
}
}
impl std::fmt::Display for SkipInfo {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"skipped: {} snapshot(s) ({}) older than the newest local snapshot",
self.count,
self.affected().map_err(|_| std::fmt::Error)?
)
}
}
pub async fn pull_group( pub async fn pull_group(
worker: &WorkerTask, worker: &WorkerTask,
client: &HttpClient, client: &HttpClient,
@ -477,6 +523,12 @@ pub async fn pull_group(
progress.group_snapshots = list.len() as u64; progress.group_snapshots = list.len() as u64;
let mut skip_info = SkipInfo {
oldest: i64::MAX,
newest: i64::MIN,
count: 0,
};
for (pos, item) in list.into_iter().enumerate() { for (pos, item) in list.into_iter().enumerate() {
let snapshot = BackupDir::new(item.backup_type, item.backup_id, item.backup_time)?; let snapshot = BackupDir::new(item.backup_type, item.backup_id, item.backup_time)?;
@ -495,6 +547,7 @@ pub async fn pull_group(
if let Some(last_sync_time) = last_sync { if let Some(last_sync_time) = last_sync {
if last_sync_time > backup_time { if last_sync_time > backup_time {
skip_info.update(backup_time);
continue; continue;
} }
} }
@ -552,6 +605,10 @@ pub async fn pull_group(
} }
} }
if skip_info.count > 0 {
task_log!(worker, "{}", skip_info);
}
Ok(()) Ok(())
} }