[pve-devel] [PATCH storage 2/2] prune backups: make vmid filtering more robust

Fabian Ebner f.ebner at proxmox.com
Wed Apr 7 12:25:37 CEST 2021


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 at 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






More information about the pve-devel mailing list