all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Dominik Csapak <d.csapak@proxmox.com>
Cc: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] applied: [PATCH proxmox-backup] api: tape/backup: improve behaviour for vanishing snapshots
Date: Thu, 30 Jun 2022 10:22:18 +0200	[thread overview]
Message-ID: <20220630082218.oae2otbrmcnqlaek@casey.proxmox.com> (raw)
In-Reply-To: <20220629121544.3277589-1-d.csapak@proxmox.com>

applied, thanks

On Wed, Jun 29, 2022 at 02:15:44PM +0200, Dominik Csapak wrote:
> when snapshots vanish during tape backup, we skip them. Until now,
> we also warned with the error and failed the task at the end.
> 
> Since deleting snapshots during tape backup does not really interfere
> with it, don't fail the whole task, and only add a log line that it
> was skipped.
> 
> To differentiate from different errors (e.g. permission problems),
> introduce a 'SnapshotBackupResult' which is returned by 'backup_snapshot'.
> 
> Also remove the 'pub' there since we don't want to leak the
> SnapshotBackupResult type and it's not used anywhere outside this file.
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> We could also do a 'task_warn' here, then the task ends a 'Warning' state
> instead of OK. Still better than failing the task though.
> 
>  src/api2/tape/backup.rs | 39 ++++++++++++++++++++++++++-------------
>  1 file changed, 26 insertions(+), 13 deletions(-)
> 
> diff --git a/src/api2/tape/backup.rs b/src/api2/tape/backup.rs
> index 5a4008e2..8f7ee5cb 100644
> --- a/src/api2/tape/backup.rs
> +++ b/src/api2/tape/backup.rs
> @@ -376,6 +376,12 @@ pub fn backup(
>      Ok(upid_str.into())
>  }
>  
> +enum SnapshotBackupResult {
> +    Success,
> +    Error,
> +    Ignored,
> +}
> +
>  fn backup_worker(
>      worker: &WorkerTask,
>      datastore: Arc<DataStore>,
> @@ -489,10 +495,11 @@ fn backup_worker(
>  
>                  need_catalog = true;
>  
> -                if !backup_snapshot(worker, &mut pool_writer, datastore.clone(), info.backup_dir)? {
> -                    errors = true;
> -                } else {
> -                    summary.snapshot_list.push(rel_path);
> +                match backup_snapshot(worker, &mut pool_writer, datastore.clone(), info.backup_dir)?
> +                {
> +                    SnapshotBackupResult::Success => summary.snapshot_list.push(rel_path),
> +                    SnapshotBackupResult::Error => errors = true,
> +                    SnapshotBackupResult::Ignored => {}
>                  }
>                  progress.done_snapshots = 1;
>                  task_log!(worker, "percentage done: {}", progress);
> @@ -514,10 +521,11 @@ fn backup_worker(
>  
>                  need_catalog = true;
>  
> -                if !backup_snapshot(worker, &mut pool_writer, datastore.clone(), info.backup_dir)? {
> -                    errors = true;
> -                } else {
> -                    summary.snapshot_list.push(rel_path);
> +                match backup_snapshot(worker, &mut pool_writer, datastore.clone(), info.backup_dir)?
> +                {
> +                    SnapshotBackupResult::Success => summary.snapshot_list.push(rel_path),
> +                    SnapshotBackupResult::Error => errors = true,
> +                    SnapshotBackupResult::Ignored => {}
>                  }
>                  progress.done_snapshots = snapshot_number as u64 + 1;
>                  task_log!(worker, "percentage done: {}", progress);
> @@ -579,26 +587,31 @@ fn update_media_online_status(drive: &str) -> Result<Option<String>, Error> {
>      }
>  }
>  
> -pub fn backup_snapshot(
> +fn backup_snapshot(
>      worker: &WorkerTask,
>      pool_writer: &mut PoolWriter,
>      datastore: Arc<DataStore>,
>      snapshot: BackupDir,
> -) -> Result<bool, Error> {
> +) -> Result<SnapshotBackupResult, Error> {
>      let snapshot_path = snapshot.relative_path();
>      task_log!(worker, "backup snapshot {:?}", snapshot_path);
>  
>      let snapshot_reader = match snapshot.locked_reader() {
>          Ok(reader) => reader,
>          Err(err) => {
> -            // ignore missing snapshots and continue
> +            if !snapshot.full_path().exists() {
> +                // we got an error and the dir does not exist,
> +                // it probably just vanished, so continue
> +                task_log!(worker, "snapshot {:?} vanished, skipping", snapshot_path);
> +                return Ok(SnapshotBackupResult::Ignored);
> +            }
>              task_warn!(
>                  worker,
>                  "failed opening snapshot {:?}: {}",
>                  snapshot_path,
>                  err
>              );
> -            return Ok(false);
> +            return Ok(SnapshotBackupResult::Error);
>          }
>      };
>  
> @@ -666,5 +679,5 @@ pub fn backup_snapshot(
>          snapshot_path
>      );
>  
> -    Ok(true)
> +    Ok(SnapshotBackupResult::Success)
>  }
> -- 
> 2.30.2




      reply	other threads:[~2022-06-30  8:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-29 12:15 [pbs-devel] " Dominik Csapak
2022-06-30  8:22 ` Wolfgang Bumiller [this message]

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=20220630082218.oae2otbrmcnqlaek@casey.proxmox.com \
    --to=w.bumiller@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal