From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Stefan Hanreich <s.hanreich@proxmox.com>
Cc: pbs-devel@lists.proxmox.com
Subject: Re: [pbs-devel] [PATCH proxmox-backup 1/1] api: ui: add transfer-last parameter to pull and sync-job
Date: Thu, 5 Jan 2023 12:28:18 +0100 [thread overview]
Message-ID: <20230105112818.aawukttclw7f2pcq@casey.proxmox.com> (raw)
In-Reply-To: <20221014103031.169512-1-s.hanreich@proxmox.com>
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 <s.hanreich@proxmox.com>
> ---
> 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<Vec<GroupFilter>>,
> #[serde(flatten)]
> pub limit: RateLimitConfig,
> + #[serde(skip_serializing_if = "Option::is_none")]
> + pub transfer_last: Option<u64>,
`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
prev parent reply other threads:[~2023-01-05 11:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-14 10:30 Stefan Hanreich
2023-01-05 11:28 ` 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=20230105112818.aawukttclw7f2pcq@casey.proxmox.com \
--to=w.bumiller@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
--cc=s.hanreich@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.