From afd0afe4f598d42e0c5565eb861220f97579fd56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Mon, 2 Jan 2017 14:27:04 +0100 Subject: [PATCH] fix #1135: always clean up ZFS snapshots on migration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit otherwise there are situations where snapshots are left behind for already sent volumes. also include more warnings. Signed-off-by: Fabian Grünbichler --- PVE/Storage.pm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/PVE/Storage.pm b/PVE/Storage.pm index 71b699c..683c920 100755 --- a/PVE/Storage.pm +++ b/PVE/Storage.pm @@ -586,12 +586,13 @@ sub storage_migrate { eval{ run_command($send); }; - my $err; - if ($err = $@){ - run_command(['zfs', 'destroy', "$zfspath\@__migration__"]); - die $err; - } - run_command($destroy_target); + my $err = $@; + warn "zfs send/receive failed, cleaning up snapshot(s)..\n" if $err; + eval { run_command(['zfs', 'destroy', "$zfspath\@__migration__"]); }; + warn "could not remove source snapshot: $@\n" if $@; + eval { run_command($destroy_target); }; + warn "could not remove target snapshot: $@\n" if $@; + die $err if $err; } else { die "$errstr - target type $tcfg->{type} is not valid\n";