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 0FFFD70B89 for ; Thu, 30 Sep 2021 13:42:23 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 56C3F1EDA1 for ; Thu, 30 Sep 2021 13:42:22 +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 id B458C1ED1B for ; Thu, 30 Sep 2021 13:42:19 +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 8D67344C52 for ; Thu, 30 Sep 2021 13:42:19 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Thu, 30 Sep 2021 13:42:09 +0200 Message-Id: <20210930114215.240095-7-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210930114215.240095-1-f.ebner@proxmox.com> References: <20210930114215.240095-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.297 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. [prunebackups.pm, plugin.pm] Subject: [pve-devel] [PATCH v2 storage 6/7] prune: mark renamed and protected backups differently 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: Thu, 30 Sep 2021 11:42:23 -0000 While it makes no difference for pruning itself, protected backups are additionally protected against removal. Avoid the potential to confuse the two. Also update the description for the API return value and add an enum constraint. Signed-off-by: Fabian Ebner --- No changes from v1. PVE/API2/Storage/PruneBackups.pm | 5 +++-- PVE/Storage/Plugin.pm | 2 +- test/prune_backups_test.pm | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/PVE/API2/Storage/PruneBackups.pm b/PVE/API2/Storage/PruneBackups.pm index 2509a46..e6ab276 100644 --- a/PVE/API2/Storage/PruneBackups.pm +++ b/PVE/API2/Storage/PruneBackups.pm @@ -61,9 +61,10 @@ __PACKAGE__->register_method ({ type => 'integer', }, 'mark' => { - description => "Whether the backup would be kept or removed. For backups that don't " . - "use the standard naming scheme, it's 'protected'.", + description => "Whether the backup would be kept or removed. Backups that are" . + " protected or don't use the standard naming scheme are not removed.", type => 'string', + enum => ['keep', 'remove', 'protected', 'renamed'], }, type => { description => "One of 'qemu', 'lxc', 'openvz' or 'unknown'.", diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm index 1ebd705..a2145fa 100644 --- a/PVE/Storage/Plugin.pm +++ b/PVE/Storage/Plugin.pm @@ -1322,7 +1322,7 @@ sub prune_backups { push @{$backup_groups->{$group}}, $prune_entry; } else { # ignore backups that don't use the standard naming scheme - $prune_entry->{mark} = 'protected'; + $prune_entry->{mark} = 'renamed'; } $prune_entry->{mark} = 'protected' if $backup->{protected}; diff --git a/test/prune_backups_test.pm b/test/prune_backups_test.pm index 8ad6144..b57d280 100644 --- a/test/prune_backups_test.pm +++ b/test/prune_backups_test.pm @@ -189,7 +189,7 @@ sub generate_expected { 'volid' => "$storeid:backup/vzdump-$vmid-renamed.tar.zst", 'type' => 'unknown', 'ctime' => 1234, - 'mark' => 'protected', + 'mark' => 'renamed', 'vmid' => $vmid, }, ) if !defined($type); @@ -375,7 +375,7 @@ my $tests = [ { 'volid' => "$storeid:backup/vzdump-lxc-novmid.tar.gz", 'ctime' => 1234, - 'mark' => 'protected', + 'mark' => 'renamed', 'type' => 'lxc', }, ], -- 2.30.2