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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id BFECB68AB1 for ; Fri, 10 Sep 2021 11:37:52 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AC45E121D7 for ; Fri, 10 Sep 2021 11:37: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 37D62121CE for ; Fri, 10 Sep 2021 11:37:22 +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 048944469E for ; Fri, 10 Sep 2021 11:37:22 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Fri, 10 Sep 2021 11:37:18 +0200 Message-Id: <20210910093718.132663-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.364 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. [plugin.pm] Subject: [pve-devel] [PATCH storage] fix prune-backups validation (again) 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, 10 Sep 2021 09:37:52 -0000 Commit a000e26ce7d30ba2b938402164a9a15e66dd123e caused a test failure in pve-manager, because now 'keep-all=0' is not thrown out upon validation anymore. Fix the issue the commit addressed differently, by simply creating a copy of the (shallow) hash first, and using the logic from before the commit. Reported-by: Thomas Lamprecht Signed-off-by: Fabian Ebner --- PVE/Storage/Plugin.pm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm index 870091d..417d1fd 100644 --- a/PVE/Storage/Plugin.pm +++ b/PVE/Storage/Plugin.pm @@ -93,16 +93,17 @@ PVE::JSONSchema::register_format('prune-backups', $prune_backups_format, \&valid sub validate_prune_backups { my ($prune_backups) = @_; - my @positive_opts = - grep { $_ ne 'keep-all' && $prune_backups->{$_} > 0 } keys $prune_backups->%*; + my $res = { $prune_backups->%* }; - if (scalar(@positive_opts) == 0) { - $prune_backups = { 'keep-all' => 1 }; - } elsif ($prune_backups->{'keep-all'}) { + my $keep_all = delete $res->{'keep-all'}; + + if (scalar(grep { $_ > 0 } values %{$res}) == 0) { + $res = { 'keep-all' => 1 }; + } elsif ($keep_all) { die "keep-all cannot be set together with other options.\n"; } - return $prune_backups; + return $res; } register_standard_option('prune-backups', { description => "The retention options with shorter intervals are processed first " . -- 2.30.2