mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-10-29 12:57:01 +00:00
backup: include IDs for non-existent guests
Like this, there will be a backup task (within the big worker task) for such IDs, which will then visibly (i.e. also visible in the notification mail) fail with, e.g.: unable to find VM '123' In get_included_guests, the key '' was chosen for the orphaned IDs, because it cannot possibly denote a nodename. Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
d51f5a1e8d
commit
7f87414894
@ -74,6 +74,10 @@ __PACKAGE__->register_method ({
|
|||||||
|
|
||||||
my $local_vmids = delete $vmids_per_node->{$nodename} // [];
|
my $local_vmids = delete $vmids_per_node->{$nodename} // [];
|
||||||
|
|
||||||
|
# include IDs for deleted guests, and visibly fail later
|
||||||
|
my $orphaned_vmids = delete $vmids_per_node->{''} // [];
|
||||||
|
push @{$local_vmids}, @{$orphaned_vmids};
|
||||||
|
|
||||||
my $skiplist = [ map { @$_ } values $vmids_per_node->%* ];
|
my $skiplist = [ map { @$_ } values $vmids_per_node->%* ];
|
||||||
|
|
||||||
if($param->{stop}){
|
if($param->{stop}){
|
||||||
|
|||||||
@ -1074,9 +1074,12 @@ sub exec_backup {
|
|||||||
|
|
||||||
my $vmlist = PVE::Cluster::get_vmlist();
|
my $vmlist = PVE::Cluster::get_vmlist();
|
||||||
foreach my $vmid (@{$opts->{vmids}}) {
|
foreach my $vmid (@{$opts->{vmids}}) {
|
||||||
|
my $plugin;
|
||||||
|
if (defined($vmlist->{ids}->{$vmid})) {
|
||||||
my $guest_type = $vmlist->{ids}->{$vmid}->{type};
|
my $guest_type = $vmlist->{ids}->{$vmid}->{type};
|
||||||
my $plugin = $vzdump_plugins->{$guest_type};
|
$plugin = $vzdump_plugins->{$guest_type};
|
||||||
next if !$rpcenv->check($authuser, "/vms/$vmid", [ 'VM.Backup' ], $opts->{all});
|
next if !$rpcenv->check($authuser, "/vms/$vmid", [ 'VM.Backup' ], $opts->{all});
|
||||||
|
}
|
||||||
push @$tasklist, {
|
push @$tasklist, {
|
||||||
mode => $opts->{mode},
|
mode => $opts->{mode},
|
||||||
plugin => $plugin,
|
plugin => $plugin,
|
||||||
@ -1218,10 +1221,14 @@ sub get_included_guests {
|
|||||||
$vmids = check_vmids(@$vmids);
|
$vmids = check_vmids(@$vmids);
|
||||||
|
|
||||||
for my $vmid (@$vmids) {
|
for my $vmid (@$vmids) {
|
||||||
|
if (defined($vmlist->{ids}->{$vmid})) {
|
||||||
my $node = $vmlist->{ids}->{$vmid}->{node};
|
my $node = $vmlist->{ids}->{$vmid}->{node};
|
||||||
next if (defined $job->{node} && $job->{node} ne $node);
|
next if (defined $job->{node} && $job->{node} ne $node);
|
||||||
|
|
||||||
push @{$vmids_per_node->{$node}}, $vmid;
|
push @{$vmids_per_node->{$node}}, $vmid;
|
||||||
|
} else {
|
||||||
|
push @{$vmids_per_node->{''}}, $vmid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $vmids_per_node;
|
return $vmids_per_node;
|
||||||
|
|||||||
@ -5,7 +5,7 @@ use warnings;
|
|||||||
|
|
||||||
use lib '..';
|
use lib '..';
|
||||||
|
|
||||||
use Test::More tests => 9;
|
use Test::More tests => 10;
|
||||||
use Test::MockModule;
|
use Test::MockModule;
|
||||||
|
|
||||||
use PVE::VZDump;
|
use PVE::VZDump;
|
||||||
@ -174,6 +174,17 @@ $addtest->('Test selected VMIDs on other nodes', {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$addtest->('Test VMID not present in vmlist', {
|
||||||
|
expected => {
|
||||||
|
node1 => [ 100 ],
|
||||||
|
node2 => [ 201, 212 ],
|
||||||
|
'' => [ 7654 ],
|
||||||
|
},
|
||||||
|
param => {
|
||||||
|
vmid => '100, 201, 212, 7654',
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
for my $test (@{$tests}) {
|
for my $test (@{$tests}) {
|
||||||
my $testname = $test->{name};
|
my $testname = $test->{name};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user