mirror of
git://git.proxmox.com/git/pve-guest-common.git
synced 2025-03-11 16:58:18 +03:00
replication: snapshot cleanup: only attempt to remove snapshots that exist
Since commit a6f5b35 ("replication: prepare: include volumes without snapshots in the result"), attempts would be made to remove previous replication snapshots from volumes on which they didn't exist. This was noticed by Thomas since the output of a replication test in pve-manager changed. The issue is not completely new, i.e. there was no check that the (previous) replication snapshot acutally exists before attempting removal during the cleanup phase. Fix the issue by adding such a check. The $replicate_snapshots hash is only used for this, so the change there is fine. Fixes: a6f5b35 ("replication: prepare: include volumes without snapshots in the result") Reported-by: Thomas Lamprecht <t.lamprecht@proxmox.com> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
bfc998e0f0
commit
45c3553562
@ -336,7 +336,7 @@ sub replicate {
|
||||
foreach my $volid (@$sorted_volids) {
|
||||
$logfunc->("create snapshot '${sync_snapname}' on $volid");
|
||||
PVE::Storage::volume_snapshot($storecfg, $volid, $sync_snapname);
|
||||
$replicate_snapshots->{$volid} = 1;
|
||||
$replicate_snapshots->{$volid}->{$sync_snapname} = 1;
|
||||
}
|
||||
};
|
||||
my $err = $@;
|
||||
@ -350,6 +350,7 @@ sub replicate {
|
||||
my $cleanup_local_snapshots = sub {
|
||||
my ($volid_hash, $snapname) = @_;
|
||||
foreach my $volid (sort keys %$volid_hash) {
|
||||
next if !$volid_hash->{$volid}->{$snapname};
|
||||
$logfunc->("delete previous replication snapshot '$snapname' on $volid");
|
||||
eval { PVE::Storage::volume_snapshot_delete($storecfg, $volid, $snapname); };
|
||||
warn $@ if $@;
|
||||
|
Loading…
x
Reference in New Issue
Block a user