With this patch we can restore the state of a state less job.
It may happen that there are more replication snapshots,
because no job state is known can not delete any snapshot.
Existing multiple replication-snapshot happens
when a node fails in middel of a replication
and then the VM is moved to another node.
That's why we have to test if we have a common base on both nodes.
Given this, we take this as a replica state.
After we have a state again, the rest of the snapshots can be deleted on the
next run.
---
PVE/Replication.pm | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/PVE/Replication.pm b/PVE/Replication.pm
index bae04ef..d2f9ade 100644
--- a/PVE/Replication.pm
+++ b/PVE/Replication.pm
@@ -54,6 +54,16 @@ sub find_common_replication_snapshot {
($last_snapshots->{$volid}->{$parent_snapname} &&
$remote_snapshots->{$volid}->{$parent_snapname})) {
$base_snapshots->{$volid} = $parent_snapname;
+ } elsif ($last_sync == 0) {
+ foreach my $remote_snap (sort {$b cmp $a} keys
%{$remote_snapshots->{$volid}}) {
+ if (defined($last_snapshots->{$volid}->{$remote_snap})) {
+ $base_snapshots->{$volid} = $remote_snap;
+ last;
+ }
+ }
+ die "No common base to restore the job state\n".
+ "please delete jobid: $jobid and create the job again\n"
+ if !defined($base_snapshots->{$volid});
}
}
}
--
2.11.0
_______________________________________________
pve-devel mailing list
[email protected]
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel