public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH guest-common 2/4] replication: prepare: return additional information about snapshots
Date: Tue, 19 Oct 2021 09:54:54 +0200	[thread overview]
Message-ID: <20211019075459.14328-6-f.ebner@proxmox.com> (raw)
In-Reply-To: <20211019075459.14328-1-f.ebner@proxmox.com>

This is backwards compatible, because existing users of prepare() only
rely on the elements to evaluate to true or be defined.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---

Depends on pve-storage for the new volume_snapshot_info function.

Build-breaks old pve-manager, because the test there assumes
volume_snapshot_list is used.

 src/PVE/Replication.pm | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/PVE/Replication.pm b/src/PVE/Replication.pm
index 32395ed..4d4f62f 100644
--- a/src/PVE/Replication.pm
+++ b/src/PVE/Replication.pm
@@ -181,11 +181,11 @@ sub prepare {
     my $last_snapshots = {};
     my $cleaned_replicated_volumes = {};
     foreach my $volid (@$volids) {
-	my $list = PVE::Storage::volume_snapshot_list($storecfg, $volid);
-	foreach my $snap (@$list) {
+	my $info = PVE::Storage::volume_snapshot_info($storecfg, $volid);
+	for my $snap (keys $info->%*) {
 	    if ((defined($snapname) && ($snap eq $snapname)) ||
 		(defined($parent_snapname) && ($snap eq $parent_snapname))) {
-		$last_snapshots->{$volid}->{$snap} = 1;
+		$last_snapshots->{$volid}->{$snap} = $info->{$snap};
 	    } elsif ($snap =~ m/^\Q$prefix\E/) {
 		if ($last_sync != 0) {
 		    $logfunc->("delete stale replication snapshot '$snap' on $volid");
@@ -206,11 +206,11 @@ sub prepare {
 		    }		
 		# Last_sync=0 and a replication snapshot only occur, if the VM was stolen
 		} else {
-		    $last_snapshots->{$volid}->{$snap} = 1;
+		    $last_snapshots->{$volid}->{$snap} = $info->{$snap};
 		}
 	    # Other snapshots might need to serve as replication base after rollback
 	    } else {
-		$last_snapshots->{$volid}->{$snap} = 1;
+		$last_snapshots->{$volid}->{$snap} = $info->{$snap};
 	    }
 	}
     }
-- 
2.30.2





  parent reply	other threads:[~2021-10-19  7:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19  7:54 [pve-devel] [PATCH-SERIES storage/guest-common/manager] Follow-up for fixing replication/rollback interaction Fabian Ebner
2021-10-19  7:54 ` [pve-devel] [PATCH storage 1/3] plugin: add volume_snapshot_info function Fabian Ebner
2021-10-19  7:54 ` [pve-devel] [PATCH storage 2/3] plugin: remove volume_snapshot_list Fabian Ebner
2021-10-19  7:54 ` [pve-devel] [PATCH storage 3/3] bump APIVER and APIAGE Fabian Ebner
2021-10-19  7:54 ` [pve-devel] [PATCH guest-common 1/4] replication: refactor finding most recent common replication snapshot Fabian Ebner
2021-10-19  7:54 ` Fabian Ebner [this message]
2021-10-19  7:54 ` [pve-devel] [PATCH guest-common 3/4] replication: find common snapshot: use additional information Fabian Ebner
2021-10-19  7:54 ` [pve-devel] [RFC guest-common 4/4] config: snapshot delete check: use volume_snapshot_info Fabian Ebner
2021-10-19  7:54 ` [pve-devel] [PATCH manager 1/3] test: replication: avoid implicit return for volume_snapshot Fabian Ebner
2021-10-19  7:54 ` [pve-devel] [PATCH manager 2/3] test: replication: mock volume_snapshot_info Fabian Ebner
2021-10-19  7:54 ` [pve-devel] [PATCH manager 3/3] test: replication: remove mocking for obsolete volume_snapshot_list Fabian Ebner
2021-11-09 16:50 ` [pve-devel] applied-series: [PATCH-SERIES storage/guest-common/manager] Follow-up for fixing replication/rollback interaction Fabian Grünbichler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211019075459.14328-6-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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