[pve-devel] [PATCH manager] get_included_guests: handle non-existing guests
Fabian Ebner
f.ebner at proxmox.com
Mon Oct 19 12:53:00 CEST 2020
If a guest is removed without purge, the ID will remain
in the backup configuration. Avoid using the variable $node
when it is potentially undefined. Instead, skip non-existing
guests and warn the user.
Reported here:
https://forum.proxmox.com/threads/purge-backup-does-not-remove-vm-from-datacenter-backup-list.77609/
Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
PVE/VZDump.pm | 5 +++++
test/vzdump_guest_included_test.pl | 12 +++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index 542228d6..6dbb6a44 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -1217,6 +1217,11 @@ sub get_included_guests {
$vmids = check_vmids(@$vmids);
for my $vmid (@$vmids) {
+ if (!defined($vmlist->{ids}->{$vmid})) {
+ debugmsg('warn', "no guest with ID '$vmid' exists in the cluster!");
+ next;
+ }
+
my $node = $vmlist->{ids}->{$vmid}->{node};
next if (defined $job->{node} && $job->{node} ne $node);
diff --git a/test/vzdump_guest_included_test.pl b/test/vzdump_guest_included_test.pl
index a0f40a55..0494d40e 100755
--- a/test/vzdump_guest_included_test.pl
+++ b/test/vzdump_guest_included_test.pl
@@ -9,7 +9,7 @@ use warnings;
use lib '..';
-use Test::More tests => 9;
+use Test::More tests => 10;
use Test::MockModule;
use PVE::VZDump;
@@ -178,6 +178,16 @@ $addtest->('Test selected VMIDs on other nodes', {
}
});
+$addtest->('Test VMID not present in vmlist', {
+ expected => {
+ node1 => [ 100 ],
+ node2 => [ 201, 212 ],
+ },
+ param => {
+ vmid => '100, 201, 212, 7654',
+ }
+});
+
for my $test (@{$tests}) {
my $testname = $test->{name};
--
2.20.1
More information about the pve-devel
mailing list