]> git.proxmox.com Git - pve-storage.git/commitdiff
fix #1135: always clean up ZFS snapshots on migration
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Mon, 2 Jan 2017 13:27:04 +0000 (14:27 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 3 Jan 2017 10:45:16 +0000 (11:45 +0100)
otherwise there are situations where snapshots are left
behind for already sent volumes. also include more warnings.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
PVE/Storage.pm

index 71b699c7ce725950a5cb53e3b57e6924a2495ee3..683c920ba1259d45236f41890348aa80b6def1c9 100755 (executable)
@@ -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";