From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 770131FF09C for ; Mon, 19 Oct 2026 18:04:18 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 9062021509; Mon, 19 Oct 2026 18:04:16 +0200 (CEST) From: Shan Shaji To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup 1/9] refactor: remove local `LogThrottle` in favor of proxmox-log Date: Mon, 19 Oct 2026 18:03:51 +0200 Message-ID: <20261019160359.20851-2-s.shaji@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261019160359.20851-1-s.shaji@proxmox.com> References: <20261019160359.20851-1-s.shaji@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1792425852355 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.424 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: YV2OEUNIBVWAHGOUIVS47M55WB6TE6NO X-Message-ID-Hash: YV2OEUNIBVWAHGOUIVS47M55WB6TE6NO X-MailFrom: s.shaji@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Remove the local implementation of `LogThrottle` and use the version provided by the proxmox-log crate instead. This prepares the utility for re-use in pbs-datastore and updates all existing references accordingly. No functional changes. Signed-off-by: Shan Shaji --- pbs-client/src/lib.rs | 3 --- pbs-client/src/log_throttle.rs | 36 ------------------------------- proxmox-backup-client/src/main.rs | 3 ++- 3 files changed, 2 insertions(+), 40 deletions(-) delete mode 100644 pbs-client/src/log_throttle.rs diff --git a/pbs-client/src/lib.rs b/pbs-client/src/lib.rs index 139f4f4b5..4b8e4e4f4 100644 --- a/pbs-client/src/lib.rs +++ b/pbs-client/src/lib.rs @@ -45,7 +45,4 @@ pub use chunk_stream::{ChunkStream, FixedChunkStream, InjectionData}; mod backup_stats; pub use backup_stats::BackupStats; -mod log_throttle; -pub use log_throttle::LogThrottle; - pub const PROXMOX_BACKUP_TCP_KEEPALIVE_TIME: u32 = 120; diff --git a/pbs-client/src/log_throttle.rs b/pbs-client/src/log_throttle.rs deleted file mode 100644 index cfaa6c494..000000000 --- a/pbs-client/src/log_throttle.rs +++ /dev/null @@ -1,36 +0,0 @@ -use std::time::{Duration, Instant}; - -/// Rate-limits recurring log output, such as progress lines, with an exponential backoff. -/// -/// [`should_log`](Self::should_log) returns `true` at most once per the current interval. Starting -/// from an initial interval, the delay doubles after each hit up to a configured maximum, giving -/// frequent feedback early on while avoiding log spam during long-running operations. -pub struct LogThrottle { - last: Instant, - interval: Duration, - max_interval: Duration, -} - -impl LogThrottle { - /// Creates a throttle with the given initial interval, doubling up to `max_interval` after each - /// hit. The initial interval is capped at `max_interval`. - pub fn new(initial_interval: Duration, max_interval: Duration) -> Self { - Self { - last: Instant::now(), - interval: initial_interval.min(max_interval), - max_interval, - } - } - - /// Returns `true` if the current interval has elapsed since the last hit, advancing the - /// throttle and doubling the interval (capped at the maximum); returns `false` otherwise. - pub fn should_log(&mut self) -> bool { - let now = Instant::now(); - if now.duration_since(self.last) < self.interval { - return false; - } - self.last = now; - self.interval = (self.interval * 2).min(self.max_interval); - true - } -} diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs index 3e7aa7cfd..93f5a1b7a 100644 --- a/proxmox-backup-client/src/main.rs +++ b/proxmox-backup-client/src/main.rs @@ -18,6 +18,7 @@ use pathpatterns::{MatchEntry, MatchType, PatternFlag}; use proxmox_async::blocking::TokioWriterAdapter; use proxmox_human_byte::HumanByte; use proxmox_io::StdChannelWriter; +use proxmox_log::log_throttle::LogThrottle; use proxmox_router::{ApiMethod, RpcEnvironment, cli::*}; use proxmox_schema::api; use proxmox_sys::fs::{CreateOptions, file_get_json, image_size, replace_file}; @@ -51,7 +52,7 @@ use pbs_client::{ BACKUP_SOURCE_SCHEMA, BackupDetectionMode, BackupReader, BackupRepository, BackupRepositoryArgs, BackupSpecificationType, BackupStats, BackupTargetArgs, BackupWriter, BackupWriterOptions, ChunkStream, FixedChunkStream, HttpClient, IndexType, InjectionData, - LogThrottle, PxarBackupStream, RemoteChunkReader, UploadOptions, delete_ticket_info, + PxarBackupStream, RemoteChunkReader, UploadOptions, delete_ticket_info, parse_backup_specification, view_task_result, }; use pbs_datastore::catalog::{BackupCatalogWriter, CatalogReader, CatalogWriter}; -- 2.47.3