public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH storage 2/2] prune backups: make vmid filtering more robust
Date: Wed,  7 Apr 2021 12:25:37 +0200	[thread overview]
Message-ID: <20210407102537.28046-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20210407102537.28046-1-f.ebner@proxmox.com>

by relying on archive_info's vmid first. archive_info is already used to
determine if it's a standard name, and in that case the vmid is certainly set.

Also add asserts to make sure we got what we expected.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---

continuing from previous patch:
...but it really seems that something went wrong with the vmids for the listing,
and making it more robust shouldn't hurt.

 PVE/Storage/Plugin.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index 05f1701..07eb88f 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -1233,9 +1233,9 @@ sub prune_backups {
 
     foreach my $backup (@{$backups}) {
 	my $volid = $backup->{volid};
-	my $backup_vmid = $backup->{vmid};
 	my $archive_info = eval { PVE::Storage::archive_info($volid) } // {};
 	my $backup_type = $archive_info->{type} // 'unknown';
+	my $backup_vmid = $archive_info->{vmid} // $backup->{vmid};
 
 	next if defined($type) && $type ne $backup_type;
 
@@ -1248,6 +1248,9 @@ sub prune_backups {
 	$prune_entry->{vmid} = $backup_vmid if defined($backup_vmid);
 
 	if ($archive_info->{is_std_name}) {
+	    die "internal error - got no vmid\n" if !defined($backup_vmid);
+	    die "internal error - got wrong vmid\n" if defined($vmid) && $backup_vmid ne $vmid;
+
 	    $prune_entry->{ctime} = $archive_info->{ctime};
 	    my $group = "$backup_type/$backup_vmid";
 	    push @{$backup_groups->{$group}}, $prune_entry;
-- 
2.20.1





  reply	other threads:[~2021-04-07 10:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 10:25 [pve-devel] [PATCH storage 1/2] plugin: subdir files: backup: don't match for vmid against the full path Fabian Ebner
2021-04-07 10:25 ` Fabian Ebner [this message]
2021-04-09 10:51   ` [pve-devel] applied: [PATCH storage 2/2] prune backups: make vmid filtering more robust Thomas Lamprecht
2021-04-09  6:59 ` [pve-devel] [PATCH storage 1/2] plugin: subdir files: backup: don't match for vmid against the full path Fabian Ebner
2021-04-09 10:51 ` [pve-devel] applied: " Thomas Lamprecht
2021-04-09 12:52   ` Fabian Ebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210407102537.28046-2-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal