From: "Gabriel Goller" <g.goller@proxmox.com>
To: "Max Carrara" <m.carrara@proxmox.com>,
"Proxmox Backup Server development discussion"
<pbs-devel@lists.proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup v2] api: make prune-group a real workertask
Date: Fri, 08 Mar 2024 13:48:23 +0100 [thread overview]
Message-ID: <CZODPI6LGVP2.36ZUONUSR24R5@proxmox.com> (raw)
In-Reply-To: <01a44ab2-0759-440a-bcf0-0e2761b7edec@proxmox.com>
Thanks for the review!
A v2 will be on the mailing list shortly!
> > @@ -960,6 +966,7 @@ pub fn prune(
> > keep_options: KeepOptions,
> > store: String,
> > ns: Option<BackupNamespace>,
> > + use_task: bool,
>
> Mmh, the number of arguments of this function makes clippy complain
> - would it make sense to use `_param` below and decode the parameter
> instead?
>
> That being said, perhaps we should find a more general solution for
> handling that many arguments at once (the arg-struct thing), as I've
> noticed that this is a recurring pattern at this point.
>
> That's not too relevant for this series otherwise though - if extracting
> the `bool` from `Value` (below) is too awkward, I guess it's fine to
> just disable the lint here (for now).
Removed the `use_task` parameter and extracted it from the `param` one.
> >
> > - let msg = format!("{}/{}/{} {}", group.ty, group.id, timestamp, mark,);
> > + let msg = format!("{}/{}/{} {}", group.ty, group.id, timestamp, mark);
> >
> > - task_log!(worker, "{}", msg);
> > + task_log!(worker, "{}", msg);
>
> While you're touching that code, would be nice to inline variables
> to be formatted into the format strings:
>
> task_log!(worker, "{msg}");
Done!
> > - if !(dry_run || keep) {
> > - if let Err(err) = info.backup_dir.destroy(false) {
> > - task_warn!(
> > - worker,
> > - "failed to remove dir {:?}: {}",
> > - info.backup_dir.relative_path(),
> > - err,
> > - );
> > + if !(dry_run || keep) {
>
> Early exit on `dry_run` is above, so this condition should just be
> `!keep`.
>
Didn't write this code, but I think it's ok, so I went ahead and made
the change.
> One last thing: Since the *complete* result is logged above (where the worker is spawned),
> maybe we should reconsider what we log here exactly? For the record, this is what
> the output looks like with the patch applied:
>
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: retention options: --keep-last 1
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: Starting prune on datastore 'test-pool', root namespace group "vm/100"
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: vm/100/2023-11-28T13:07:05Z remove
> Mar 07 10:22:29 pbs-dev proxmox-backup-[5636]: pbs-dev proxmox-backup-proxy[5636]: removing backup snapshot "/mnt/datastore/test-pool/vm/100/2023-11-28T13:07:05Z"
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: vm/100/2023-12-04T08:57:22Z keep
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: [
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: PruneResult {
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: backup_type: Vm,
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: backup_id: "100",
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: backup_time: 1701176825,
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: keep: false,
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: protected: false,
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: ns: None,
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: },
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: PruneResult {
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: backup_type: Vm,
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: backup_id: "100",
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: backup_time: 1701680242,
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: keep: true,
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: protected: false,
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: ns: None,
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: },
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: ]
> Mar 07 10:22:29 pbs-dev proxmox-backup-proxy[5636]: TASK OK
>
> Perhaps it's better to log whether `result` is `Err` or `Ok` instead?
Yes, I decided to remove this log-statement altogether... We already
print a '<snapshot-name> keep' or '<snapshot-name> remove' for every
snapshot, so the PruneResult is only duplicate information.
prev parent reply other threads:[~2024-03-08 12:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-25 11:48 Gabriel Goller
2024-03-07 13:54 ` Max Carrara
2024-03-08 12:48 ` Gabriel Goller [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=CZODPI6LGVP2.36ZUONUSR24R5@proxmox.com \
--to=g.goller@proxmox.com \
--cc=m.carrara@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.