public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH guest-common 1/2] replication: prepare: include volumes without snapshots in the result
@ 2023-01-20 10:18 Fiona Ebner
  2023-01-20 10:18 ` [pve-devel] [PATCH guest-common 2/2] replication: find common base: improve error when no common base snapshot exists Fiona Ebner
  0 siblings, 1 reply; 2+ messages in thread
From: Fiona Ebner @ 2023-01-20 10:18 UTC (permalink / raw)
  To: pve-devel

Note that PVE::Storage::volume_snapshot_info() will fail when a volume
does not exist, so no non-existing volume will end up in the result
(prepare() is only called with volumes that should exist).

This makes it possible to detect a volume without snapshots in the
result of prepare(), and as a consequence, replication will now also
fail early in a situation where source and remote volume both exist,
but (at least) one of them doesn't have any snapshots.

Such a situation can happen, for example, by deleting and re-creating
a volume with the same name on the source side without running
replication after deletion.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/Replication.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/PVE/Replication.pm b/src/PVE/Replication.pm
index 469ca19..f9d454d 100644
--- a/src/PVE/Replication.pm
+++ b/src/PVE/Replication.pm
@@ -172,6 +172,8 @@ sub prepare {
     my $local_snapshots = {};
     my $cleaned_replicated_volumes = {};
     foreach my $volid (@$volids) {
+	$local_snapshots->{$volid} = {};
+
 	my $info = PVE::Storage::volume_snapshot_info($storecfg, $volid);
 
 	my $removal_ok = !defined($snapname) || $info->{$snapname};
-- 
2.30.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pve-devel] [PATCH guest-common 2/2] replication: find common base: improve error when no common base snapshot exists
  2023-01-20 10:18 [pve-devel] [PATCH guest-common 1/2] replication: prepare: include volumes without snapshots in the result Fiona Ebner
@ 2023-01-20 10:18 ` Fiona Ebner
  0 siblings, 0 replies; 2+ messages in thread
From: Fiona Ebner @ 2023-01-20 10:18 UTC (permalink / raw)
  To: pve-devel

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 | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/PVE/Replication.pm b/src/PVE/Replication.pm
index f9d454d..6dce8d6 100644
--- a/src/PVE/Replication.pm
+++ b/src/PVE/Replication.pm
@@ -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);
 }
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-20 10:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-20 10:18 [pve-devel] [PATCH guest-common 1/2] replication: prepare: include volumes without snapshots in the result Fiona Ebner
2023-01-20 10:18 ` [pve-devel] [PATCH guest-common 2/2] replication: find common base: improve error when no common base snapshot exists Fiona Ebner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal