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 B2C5C90D9E for ; Fri, 23 Sep 2022 12:34:28 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 94266240A9 for ; Fri, 23 Sep 2022 12:33:58 +0200 (CEST) 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, 23 Sep 2022 12:33:57 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A7F1144500 for ; Fri, 23 Sep 2022 12:33:57 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pve-devel@lists.proxmox.com Date: Fri, 23 Sep 2022 12:33:51 +0200 Message-Id: <20220923103352.569770-1-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.147 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 Subject: [pve-devel] [PATCH proxmox-offline-mirror 1/2] fix #4259: mirror: add ignore-errors option X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Sep 2022 10:34:28 -0000 to make fetching errors from broken repositories non-fatal. Signed-off-by: Fabian Grünbichler --- based on top of "extend/add commands" series from 20220921081242.1139249-1-f.gruenbichler@proxmox.com src/bin/proxmox-offline-mirror.rs | 2 ++ src/bin/proxmox_offline_mirror_cmds/config.rs | 3 +++ src/config.rs | 8 ++++++++ src/mirror.rs | 19 ++++++++++++++++--- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/bin/proxmox-offline-mirror.rs b/src/bin/proxmox-offline-mirror.rs index 0a6e77e..222b561 100644 --- a/src/bin/proxmox-offline-mirror.rs +++ b/src/bin/proxmox-offline-mirror.rs @@ -386,6 +386,7 @@ fn action_add_mirror(config: &SectionConfigData) -> Result, Er sync, base_dir: base_dir.clone(), use_subscription: None, + ignore_errors: false, }); } } @@ -399,6 +400,7 @@ fn action_add_mirror(config: &SectionConfigData) -> Result, Er sync, base_dir, use_subscription, + ignore_errors: false, }; configs.push(main_config); diff --git a/src/bin/proxmox_offline_mirror_cmds/config.rs b/src/bin/proxmox_offline_mirror_cmds/config.rs index b48a708..5ebf6d5 100644 --- a/src/bin/proxmox_offline_mirror_cmds/config.rs +++ b/src/bin/proxmox_offline_mirror_cmds/config.rs @@ -262,6 +262,9 @@ pub fn update_mirror( if let Some(verify) = update.verify { data.verify = verify } + if let Some(ignore_errors) = update.ignore_errors { + data.ignore_errors = ignore_errors + } config.set_data(&id, "mirror", &data)?; proxmox_offline_mirror::config::save_config(&config_file, &config)?; diff --git a/src/config.rs b/src/config.rs index 6c2f3e8..cb9a22b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -41,6 +41,11 @@ use crate::types::{ sync: { type: bool, }, + "ignore-errors": { + type: bool, + optional: true, + default: false, + }, } )] #[derive(Clone, Debug, Serialize, Deserialize, Updater)] @@ -65,6 +70,9 @@ pub struct MirrorConfig { /// Use subscription key to access (required for Proxmox Enterprise repositories). #[serde(skip_serializing_if = "Option::is_none")] pub use_subscription: Option, + /// Whether to downgrade download errors to warnings + #[serde(default)] + pub ignore_errors: bool, } #[api( diff --git a/src/mirror.rs b/src/mirror.rs index 5bf9219..e655847 100644 --- a/src/mirror.rs +++ b/src/mirror.rs @@ -46,6 +46,7 @@ struct ParsedMirrorConfig { pub sync: bool, pub auth: Option, pub client: Client, + pub ignore_errors: bool, } impl TryInto for MirrorConfig { @@ -74,6 +75,7 @@ impl TryInto for MirrorConfig { sync: self.sync, auth: None, client, + ignore_errors: self.ignore_errors, }) } } @@ -691,7 +693,7 @@ pub fn create_snapshot( let mut full_path = PathBuf::from(prefix); full_path.push(&package.file); - let res = fetch_plain_file( + match fetch_plain_file( &config, &url, &full_path, @@ -699,8 +701,19 @@ pub fn create_snapshot( &package.checksums, false, dry_run, - )?; - fetch_progress.update(&res); + ) { + Ok(res) => fetch_progress.update(&res), + Err(err) if config.ignore_errors => { + let msg = format!( + "{}: failed to fetch package '{}' - {}", + basename, package.file, err, + ); + eprintln!("{msg}"); + } + res => { + res?; + } + } } if fetch_progress.file_count() % (max(total_files / 100, 1)) == 0 { -- 2.30.2