]> git.proxmox.com Git - pve-guest-common.git/commitdiff
replication: find common base: improve error when no common base snapshot exists
authorFiona Ebner <f.ebner@proxmox.com>
Wed, 13 Dec 2023 14:17:46 +0000 (15:17 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 11 Apr 2024 16:13:44 +0000 (18:13 +0200)
Suggest an alternative solution by removing the problematic volumes
from the replication target rather than the whole job.

This is helpful if there are multiple replicated volumes to avoid the
need to fully re-sync all volumes in many cases.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
src/PVE/Replication.pm

index 05c2632a3b952834acb7a90834bcb15a9f17f6f8..984ea34e6622a0d455834a5ba6014780163a48f0 100644 (file)
@@ -53,6 +53,7 @@ sub find_common_replication_snapshot {
     );
 
     my $base_snapshots = {};
+    my @missing_snapshots = ();
 
     foreach my $volid (@$volumes) {
        my $local_info = $local_snapshots->{$volid};
@@ -91,15 +92,19 @@ sub find_common_replication_snapshot {
                    next;
                }
 
-               # The volume exists on the remote side, so trying a full sync won't work.
-               # Die early with a clean error.
-               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});
+               push @missing_snapshots, $volid if !defined($base_snapshots->{$volid});
            }
        }
     }
 
+    if (scalar(@missing_snapshots) > 0) {
+       # There exist volumes without common base snapshot on the remote side.
+       # Trying to (do a full) sync won't work, so die early with a clean error.
+       my $volume_string = join(',', @missing_snapshots);
+       die "No common base snapshot on volume(s) $volume_string\nPlease remove the problematic " .
+           "volume(s) from the replication target or delete and re-create the whole job $jobid\n";
+    }
+
     return ($base_snapshots, $local_snapshots, $last_sync_snapname);
 }