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 46B8960279 for ; Wed, 14 Oct 2020 14:16:49 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 43E089B15 for ; Wed, 14 Oct 2020 14:16:49 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 id 1A7639AA1 for ; Wed, 14 Oct 2020 14:16:47 +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 D4ACC45D66 for ; Wed, 14 Oct 2020 14:16:46 +0200 (CEST) From: Stefan Reiter To: pbs-devel@lists.proxmox.com Date: Wed, 14 Oct 2020 14:16:30 +0200 Message-Id: <20201014121639.25276-3-s.reiter@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201014121639.25276-1-s.reiter@proxmox.com> References: <20201014121639.25276-1-s.reiter@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.039 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [datastore.rs] Subject: [pbs-devel] [PATCH proxmox-backup 02/11] prune: never fail, just warn about failed removals 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: Wed, 14 Oct 2020 12:16:49 -0000 A removal can fail if the snapshot is already gone (this is fine, our job is done either way) or we couldn't get a lock (also fine, it can't be removed then, just warn the user so he knows what happened and why it wasn't removed) - keep going either way. Signed-off-by: Stefan Reiter --- src/api2/admin/datastore.rs | 74 ++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index 79add173..3bfd807c 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -16,7 +16,6 @@ use proxmox::api::{ use proxmox::api::router::SubdirMap; use proxmox::api::schema::*; use proxmox::tools::fs::{replace_file, CreateOptions}; -use proxmox::try_block; use proxmox::{http_err, identity, list_subdirs_api_method, sortable}; use pxar::accessor::aio::Accessor; @@ -692,53 +691,52 @@ fn prune( // We use a WorkerTask just to have a task log, but run synchrounously let worker = WorkerTask::new("prune", Some(worker_id), Userid::root_userid().clone(), true)?; - let result = try_block! { - if keep_all { - worker.log("No prune selection - keeping all files."); - } else { - worker.log(format!("retention options: {}", prune_options.cli_options_string())); - worker.log(format!("Starting prune on store \"{}\" group \"{}/{}\"", - store, backup_type, backup_id)); - } + if keep_all { + worker.log("No prune selection - keeping all files."); + } else { + worker.log(format!("retention options: {}", prune_options.cli_options_string())); + worker.log(format!("Starting prune on store \"{}\" group \"{}/{}\"", + store, backup_type, backup_id)); + } - for (info, mut keep) in prune_info { - if keep_all { keep = true; } + for (info, mut keep) in prune_info { + if keep_all { keep = true; } - let backup_time = info.backup_dir.backup_time(); - let timestamp = info.backup_dir.backup_time_string(); - let group = info.backup_dir.group(); + let backup_time = info.backup_dir.backup_time(); + let timestamp = info.backup_dir.backup_time_string(); + let group = info.backup_dir.group(); - let msg = format!( - "{}/{}/{} {}", - group.backup_type(), - group.backup_id(), - timestamp, - if keep { "keep" } else { "remove" }, - ); + let msg = format!( + "{}/{}/{} {}", + group.backup_type(), + group.backup_id(), + timestamp, + if keep { "keep" } else { "remove" }, + ); - worker.log(msg); + worker.log(msg); - prune_result.push(json!({ - "backup-type": group.backup_type(), - "backup-id": group.backup_id(), - "backup-time": backup_time, - "keep": keep, - })); + prune_result.push(json!({ + "backup-type": group.backup_type(), + "backup-id": group.backup_id(), + "backup-time": backup_time, + "keep": keep, + })); - if !(dry_run || keep) { - datastore.remove_backup_dir(&info.backup_dir, false)?; + if !(dry_run || keep) { + if let Err(err) = datastore.remove_backup_dir(&info.backup_dir, false) { + worker.warn( + format!( + "failed to remove dir {:?}: {}", + info.backup_dir.relative_path(), err + ) + ); } } + } - Ok(()) - }; - - worker.log_result(&result); - - if let Err(err) = result { - bail!("prune failed - {}", err); - }; + worker.log_result(&Ok(())); Ok(json!(prune_result)) } -- 2.20.1