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 E04A09379B for ; Thu, 5 Jan 2023 12:28:50 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C2553204D for ; Thu, 5 Jan 2023 12:28:20 +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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 5 Jan 2023 12:28:20 +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 CF4BC42CCD for ; Thu, 5 Jan 2023 12:28:19 +0100 (CET) Date: Thu, 5 Jan 2023 12:28:18 +0100 From: Wolfgang Bumiller To: Stefan Hanreich Cc: pbs-devel@lists.proxmox.com Message-ID: <20230105112818.aawukttclw7f2pcq@casey.proxmox.com> References: <20221014103031.169512-1-s.hanreich@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221014103031.169512-1-s.hanreich@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.216 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [pull.rs, jobs.rs, sync.rs, proxmox-backup-manager.rs] Subject: Re: [pbs-devel] [PATCH proxmox-backup 1/1] api: ui: add transfer-last parameter to pull and sync-job 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: Thu, 05 Jan 2023 11:28:50 -0000 needs a rebase + some comments inline On Fri, Oct 14, 2022 at 12:30:31PM +0200, Stefan Hanreich wrote: > partially fixes #3701 > > Specifying this parameter limits the amount of backups that get > synced via the pull command or sync job. The parameter specifies how many > of the N latest backups should get pulled/synced. All other backups will > get skipped during the pull/sync-job. > > Additionally added a field in the sync job UI to configure this value. > > Signed-off-by: Stefan Hanreich > --- > pbs-api-types/src/jobs.rs | 12 ++++++++++++ > src/api2/config/sync.rs | 9 +++++++++ > src/api2/pull.rs | 10 +++++++++- > src/bin/proxmox-backup-manager.rs | 13 +++++++++++-- > src/server/pull.rs | 16 ++++++++++++++-- > www/config/SyncView.js | 9 ++++++++- > www/window/SyncJobEdit.js | 13 +++++++++++++ > 7 files changed, 76 insertions(+), 6 deletions(-) > > diff --git a/pbs-api-types/src/jobs.rs b/pbs-api-types/src/jobs.rs > index 7f029af7..4ac84372 100644 > --- a/pbs-api-types/src/jobs.rs > +++ b/pbs-api-types/src/jobs.rs > @@ -433,6 +433,12 @@ pub const GROUP_FILTER_SCHEMA: Schema = StringSchema::new( > pub const GROUP_FILTER_LIST_SCHEMA: Schema = > ArraySchema::new("List of group filters.", &GROUP_FILTER_SCHEMA).schema(); > > +pub const TRANSFER_LAST_SCHEMA: Schema = IntegerSchema::new( > + "The maximum amount of snapshots to be transferred (per group)." > +) > + .minimum(1) > + .schema(); > + > #[api( > properties: { > id: { > @@ -482,6 +488,10 @@ pub const GROUP_FILTER_LIST_SCHEMA: Schema = > schema: GROUP_FILTER_LIST_SCHEMA, > optional: true, > }, > + "transfer-last": { > + schema: TRANSFER_LAST_SCHEMA, > + optional: true, > + }, > } > )] > #[derive(Serialize, Deserialize, Clone, Updater)] > @@ -511,6 +521,8 @@ pub struct SyncJobConfig { > pub group_filter: Option>, > #[serde(flatten)] > pub limit: RateLimitConfig, > + #[serde(skip_serializing_if = "Option::is_none")] > + pub transfer_last: Option, `usize` might need less casting and be good enough unless we worry about having 4mio snapshots in a group on a 32-bit system? > } > > impl SyncJobConfig { (...) > diff --git a/src/server/pull.rs b/src/server/pull.rs > index 77caf327..9be82669 100644 > --- a/src/server/pull.rs > +++ b/src/server/pull.rs > @@ -647,6 +651,8 @@ async fn pull_group( > count: 0, > }; > > + let transfer_amount = params.transfer_last.unwrap_or(list.len() as u64); > + > for (pos, item) in list.into_iter().enumerate() { > let snapshot = item.backup; > > @@ -669,6 +675,12 @@ async fn pull_group( > } > } > > + let i = pos as u64; Please don't rename `pos` to a single letter somewhere in the middle all the way to the end. Keep it named `pos`. > + if progress.group_snapshots - i > transfer_amount { I find the connection between `group_snapshots` and `list.len()` to be non-obvious at this point, particularly because its name (with the `progres.` prefix) sounds more like a counter while it's actually `i` that is doing the counting (and "done_snapshots") and think if pos < (list.len() - transfer_amount) would be much easier to grasp? > + skip_info.update(snapshot.time); > + continue; > + } > + > // get updated auth_info (new tickets) > let auth_info = client.login().await?; > > @@ -697,7 +709,7 @@ async fn pull_group( > > let result = pull_snapshot_from(worker, reader, &snapshot, downloaded_chunks.clone()).await; > > - progress.done_snapshots = pos as u64 + 1; > + progress.done_snapshots = i + 1; :-S > task_log!(worker, "percentage done: {}", progress); > > result?; // stop on error