From: Dietmar Maurer <dietmar@proxmox.com>
To: Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>,
Dominik Csapak <d.csapak@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup v2 4/5] api2/tape/backup: include a summary on notification e-mails
Date: Fri, 19 Mar 2021 07:07:29 +0100 (CET) [thread overview]
Message-ID: <1789734810.421.1616134050079@webmail.proxmox.com> (raw)
In-Reply-To: <20210318120108.26423-5-d.csapak@proxmox.com>
comments inline
> On 03/18/2021 1:01 PM Dominik Csapak <d.csapak@proxmox.com> wrote:
>
>
> for now only contains the list of included snapshots (if any),
> as well as the backup duration
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> src/api2/tape/backup.rs | 32 +++++++++++++++++++++++++------
> src/api2/types/tape/mod.rs | 9 +++++++++
> src/server/email_notifications.rs | 13 +++++++++++++
> 3 files changed, 48 insertions(+), 6 deletions(-)
>
> diff --git a/src/api2/tape/backup.rs b/src/api2/tape/backup.rs
> index 690b6855..0d42c31a 100644
> --- a/src/api2/tape/backup.rs
> +++ b/src/api2/tape/backup.rs
> @@ -51,6 +51,7 @@ use crate::{
> JOB_ID_SCHEMA,
> MediaPoolConfig,
> Userid,
> + TapeBackupJobSummary,
> },
> server::WorkerTask,
> task::TaskState,
> @@ -198,13 +199,16 @@ pub fn do_tape_backup_job(
> let notify_user = setup.notify_user.as_ref().unwrap_or_else(|| &Userid::root_userid());
> let email = lookup_user_email(notify_user);
>
> - let job_result = backup_worker(
> + let (job_result, summary) = match backup_worker(
> &worker,
> datastore,
> &pool_config,
> &setup,
> email.clone(),
> - );
> + ) {
> + Ok(summary) => (Ok(()), summary),
> + Err(err) => (Err(err), Default::default()),
> + };
>
> let status = worker.create_state(&job_result);
>
> @@ -214,6 +218,7 @@ pub fn do_tape_backup_job(
> Some(job.jobname()),
> &setup,
> &job_result,
> + summary,
> ) {
> eprintln!("send tape backup notification failed: {}", err);
> }
> @@ -340,13 +345,17 @@ pub fn backup(
> move |worker| {
> let _drive_lock = drive_lock; // keep lock guard
> set_tape_device_state(&setup.drive, &worker.upid().to_string())?;
> - let job_result = backup_worker(
> +
> + let (job_result, summary) = match backup_worker(
> &worker,
> datastore,
> &pool_config,
> &setup,
> email.clone(),
> - );
> + ) {
> + Ok(summary) => (Ok(()), summary),
> + Err(err) => (Err(err), Default::default()),
> + };
>
> if let Some(email) = email {
> if let Err(err) = crate::server::send_tape_backup_status(
> @@ -354,6 +363,7 @@ pub fn backup(
> None,
> &setup,
> &job_result,
> + summary,
> ) {
> eprintln!("send tape backup notification failed: {}", err);
> }
> @@ -374,9 +384,11 @@ fn backup_worker(
> pool_config: &MediaPoolConfig,
> setup: &TapeBackupJobSetup,
> email: Option<String>,
> -) -> Result<(), Error> {
> +) -> Result<TapeBackupJobSummary, Error> {
>
> let status_path = Path::new(TAPE_STATUS_DIR);
> + let start = std::time::Instant::now();
> + let mut summary: TapeBackupJobSummary = Default::default();
>
> let _lock = MediaPool::lock(status_path, &pool_config.name)?;
>
> @@ -422,8 +434,11 @@ fn backup_worker(
> task_log!(worker, "skip snapshot {}", info.backup_dir);
> continue;
> }
> + let snapshot_name = info.backup_dir.to_string();
> if !backup_snapshot(worker, &mut pool_writer, datastore.clone(), info.backup_dir)? {
> errors = true;
> + } else {
> + summary.snapshot_list.push(snapshot_name);
> }
> progress.done_snapshots = 1;
> task_log!(
> @@ -439,8 +454,11 @@ fn backup_worker(
> task_log!(worker, "skip snapshot {}", info.backup_dir);
> continue;
> }
> + let snapshot_name = info.backup_dir.to_string();
> if !backup_snapshot(worker, &mut pool_writer, datastore.clone(), info.backup_dir)? {
> errors = true;
> + } else {
> + summary.snapshot_list.push(snapshot_name);
> }
> progress.done_snapshots = snapshot_number as u64 + 1;
> task_log!(
> @@ -464,7 +482,9 @@ fn backup_worker(
> bail!("Tape backup finished with some errors. Please check the task log.");
> }
>
> - Ok(())
> + summary.duration = start.elapsed();
> +
> + Ok(summary)
> }
>
> // Try to update the the media online status
> diff --git a/src/api2/types/tape/mod.rs b/src/api2/types/tape/mod.rs
> index 68b2cf12..44c2236b 100644
> --- a/src/api2/types/tape/mod.rs
> +++ b/src/api2/types/tape/mod.rs
> @@ -20,3 +20,12 @@ pub use media_location::*;
>
> mod media;
> pub use media::*;
> +
> +/// Summary of a successful Tape Job
> +#[derive(Default)]
> +pub struct TapeBackupJobSummary {
> + /// The list of snaphots backed up
> + pub snapshot_list: Vec<String>,
> + /// The total time of the backup job
> + pub duration: std::time::Duration,
> +}
This is not an API type, and is not use in the API at all!
Please can you define this type somewhere else?
next prev parent reply other threads:[~2021-03-19 6:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-18 12:01 [pbs-devel] [PATCH proxmox-backup v2 0/5] improve tape backup and notifications Dominik Csapak
2021-03-18 12:01 ` [pbs-devel] [PATCH proxmox-backup v2 1/5] tools/systemd/time: implement some Traits for TimeSpan Dominik Csapak
2021-03-18 12:01 ` [pbs-devel] [PATCH proxmox-backup v2 2/5] server/email_notifications: do not panic on template registration Dominik Csapak
2021-03-18 12:01 ` [pbs-devel] [PATCH proxmox-backup v2 3/5] server/email_notifications: do not double html escape Dominik Csapak
2021-03-18 12:01 ` [pbs-devel] [PATCH proxmox-backup v2 4/5] api2/tape/backup: include a summary on notification e-mails Dominik Csapak
2021-03-19 6:07 ` Dietmar Maurer [this message]
2021-03-18 12:01 ` [pbs-devel] [PATCH proxmox-backup v2 5/5] api2/tape/backup: wait indefinitely for lock in scheduled backup jobs Dominik Csapak
2021-03-19 6:09 ` [pbs-devel] [PATCH proxmox-backup v2 0/5] improve tape backup and notifications Dietmar Maurer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1789734810.421.1616134050079@webmail.proxmox.com \
--to=dietmar@proxmox.com \
--cc=d.csapak@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox