mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-05 07:06:00 +00:00
remove backup locks when starting all VMs on boot
If on bootup one of our VMs is locked by an backup we safely can assume that this backup job does not run anymore and that the lock has no reason anymore and just hinders uptime of services. As at this time we (the node) have quorum so we may safely assume that we have a consistent view of the cluster and all our VMs really belong to us. We just need to ensure that we do not run into an automatic backup jobs, so execute our code with VZDumps lock or timeout. Log in the Task and Sys log that we removed the lock, so that an admin easily sees that there may be need for cleaning leftovers from an interrupted backup. Addresses bug #1024 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
b2bb6d7749
commit
1c8dc310b3
@ -1250,6 +1250,7 @@ my $get_filtered_vmlist = sub {
|
||||
|
||||
$res->{$vmid}->{conf} = $conf;
|
||||
$res->{$vmid}->{type} = $d->{type};
|
||||
$res->{$vmid}->{class} = $class;
|
||||
};
|
||||
warn $@ if $@;
|
||||
}
|
||||
@ -1286,6 +1287,26 @@ my $get_start_stop_list = sub {
|
||||
return $resList;
|
||||
};
|
||||
|
||||
my $remove_locks_on_startup = sub {
|
||||
my ($nodename) = @_;
|
||||
|
||||
my $vmlist = &$get_filtered_vmlist($nodename, undef, undef, 1);
|
||||
|
||||
foreach my $vmid (keys %$vmlist) {
|
||||
my $conf = $vmlist->{$vmid}->{conf};
|
||||
my $class = $conf->{class};
|
||||
|
||||
eval {
|
||||
if ($class->has_lock($conf, 'backup')) {
|
||||
$class->remove_lock($vmid, 'backup');
|
||||
my $msg = "removed left over backup lock from '$vmid'!";
|
||||
warn "$msg\n"; # prints to task log
|
||||
syslog('warning', $msg);
|
||||
}
|
||||
}; warn $@ if $@;
|
||||
}
|
||||
};
|
||||
|
||||
__PACKAGE__->register_method ({
|
||||
name => 'startall',
|
||||
path => 'startall',
|
||||
@ -1337,6 +1358,11 @@ __PACKAGE__->register_method ({
|
||||
} while (!PVE::Cluster::check_cfs_quorum(1));
|
||||
print "got quorum\n";
|
||||
}
|
||||
|
||||
eval { # remove backup locks, but avoid running into a scheduled backup job
|
||||
PVE::Tools::lock_file('/var/run/vzdump.lock', 10, $remove_locks_on_startup, $nodename);
|
||||
}; warn $@ if $@;
|
||||
|
||||
my $autostart = $force ? undef : 1;
|
||||
my $startList = &$get_start_stop_list($nodename, $autostart, $param->{vms});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user