From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id ED2DCB869C for ; Fri, 8 Mar 2024 13:48:25 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CF115D3DA for ; Fri, 8 Mar 2024 13:48:25 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 8 Mar 2024 13:48:24 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 8D30B4887B for ; Fri, 8 Mar 2024 13:48:24 +0100 (CET) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 08 Mar 2024 13:48:23 +0100 Message-Id: From: "Gabriel Goller" To: "Max Carrara" , "Proxmox Backup Server development discussion" X-Mailer: aerc 0.17.0-37-g3aa8b6308482-dirty References: <20240125114857.128507-1-g.goller@proxmox.com> <01a44ab2-0759-440a-bcf0-0e2761b7edec@proxmox.com> In-Reply-To: <01a44ab2-0759-440a-bcf0-0e2761b7edec@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL -0.093 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pbs-devel] [PATCH proxmox-backup v2] api: make prune-group a real workertask X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Mar 2024 12:48:26 -0000 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, > > + 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. > > =20 > > - let msg =3D format!("{}/{}/{} {}", group.ty, group.id, timesta= mp, mark,); > > + let msg =3D format!("{}/{}/{} {}", group.ty, group.id, tim= estamp, mark); > > =20 > > - 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) =3D 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 wo= rker 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 dat= astore '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-pro= xy[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: "1= 00", > 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: fa= lse, > 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: "1= 00", > 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: fa= lse, > 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 ' keep' or ' remove' for every snapshot, so the PruneResult is only duplicate information.