[pve-devel] [PATCH manager 1/2] Replication::prepare: track cleaned up volumes

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Jun 8 10:17:44 CEST 2017


Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 PVE/Replication.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/PVE/Replication.pm b/PVE/Replication.pm
index 9aad67d8..181c4d3f 100644
--- a/PVE/Replication.pm
+++ b/PVE/Replication.pm
@@ -186,20 +186,21 @@ sub prepare {
 	PVE::ReplicationState::replication_snapshot_name($jobid, $last_sync);
 
     my $last_snapshots = {};
+    my $cleaned_replicated_volumes = {};
     foreach my $volid (@$volids) {
 	my $list = PVE::Storage::volume_snapshot_list($storecfg, $volid);
-	my $found = 0;
 	foreach my $snap (@$list) {
 	    if ($snap eq $snapname || (defined($parent_snapname) && ($snap eq $parent_snapname))) {
 		$last_snapshots->{$volid}->{$snap} = 1;
 	    } elsif ($snap =~ m/^\Q$prefix\E/) {
 		$logfunc->("delete stale replication snapshot '$snap' on $volid");
 		PVE::Storage::volume_snapshot_delete($storecfg, $volid, $snap);
+		$cleaned_replicated_volumes->{$volid} = 1;
 	    }
 	}
     }
 
-    return $last_snapshots;
+    return wantarray ? ($last_snapshots, $cleaned_replicated_volumes) : $last_snapshots;
 }
 
 sub replicate_volume {
-- 
2.11.0





More information about the pve-devel mailing list