[pve-devel] [PATCH pve-manager 2/3] use new PVE::ReplicationState::replication_snapshot_name()
Dietmar Maurer
dietmar at proxmox.com
Tue Jun 6 13:02:34 CEST 2017
Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
PVE/Replication.pm | 18 ++++++------------
bin/test/replication_test5.log | 42 +++++++++++++++++++++---------------------
bin/test/replication_test5.pl | 2 +-
3 files changed, 28 insertions(+), 34 deletions(-)
diff --git a/PVE/Replication.pm b/PVE/Replication.pm
index 71e2624d..a4013fb4 100644
--- a/PVE/Replication.pm
+++ b/PVE/Replication.pm
@@ -112,15 +112,6 @@ my $get_next_job = sub {
return undef;
};
-sub replication_snapshot_name {
- my ($jobid, $last_sync) = @_;
-
- my $prefix = "replicate_${jobid}_";
- my $snapname = "${prefix}${last_sync}_snap";
-
- wantarray ? ($prefix, $snapname) : $snapname;
-}
-
sub remote_prepare_local_job {
my ($ssh_info, $jobid, $vmid, $volumes, $last_sync, $force) = @_;
@@ -159,7 +150,8 @@ sub remote_finalize_local_job {
sub prepare {
my ($storecfg, $volids, $jobid, $last_sync, $start_time, $logfunc) = @_;
- my ($prefix, $snapname) = replication_snapshot_name($jobid, $last_sync);
+ my ($prefix, $snapname) =
+ PVE::ReplicationState::replication_snapshot_name($jobid, $last_sync);
my $last_snapshots = {};
foreach my $volid (@$volids) {
@@ -279,8 +271,10 @@ sub replicate {
# test if we have a replication_ snapshot from last sync
# and remove all other/stale replication snapshots
- my $last_sync_snapname = replication_snapshot_name($jobid, $last_sync);
- my $sync_snapname = replication_snapshot_name($jobid, $start_time);
+ my $last_sync_snapname =
+ PVE::ReplicationState::replication_snapshot_name($jobid, $last_sync);
+ my $sync_snapname =
+ PVE::ReplicationState::replication_snapshot_name($jobid, $start_time);
my $last_snapshots = prepare(
$storecfg, $sorted_volids, $jobid, $last_sync, $start_time, $logfunc);
diff --git a/bin/test/replication_test5.log b/bin/test/replication_test5.log
index 45cdad87..e70c79ba 100644
--- a/bin/test/replication_test5.log
+++ b/bin/test/replication_test5.log
@@ -2,8 +2,8 @@
1000 job_900_to_node2: start replication job
1000 job_900_to_node2: guest => 900, type => qemu, running => 0
1000 job_900_to_node2: volumes => local-zfs:vm-900-disk-1
-1000 job_900_to_node2: create snapshot 'replicate_job_900_to_node2_1000_snap' on local-zfs:vm-900-disk-1
-1000 job_900_to_node2: full sync 'local-zfs:vm-900-disk-1' (replicate_job_900_to_node2_1000_snap)
+1000 job_900_to_node2: create snapshot '__replicate_job_900_to_node2_1000__' on local-zfs:vm-900-disk-1
+1000 job_900_to_node2: full sync 'local-zfs:vm-900-disk-1' (__replicate_job_900_to_node2_1000__)
1000 job_900_to_node2: end replication job
1000 job_900_to_node2: changed config next_sync => 1800
1000 job_900_to_node2: changed state last_node => node1, last_try => 1000, last_sync => 1000
@@ -11,41 +11,41 @@
1840 job_900_to_node2: start replication job
1840 job_900_to_node2: guest => 900, type => qemu, running => 0
1840 job_900_to_node2: volumes => local-zfs:vm-900-disk-1
-1840 job_900_to_node2: create snapshot 'replicate_job_900_to_node2_1840_snap' on local-zfs:vm-900-disk-1
-1840 job_900_to_node2: incremental sync 'local-zfs:vm-900-disk-1' (replicate_job_900_to_node2_1000_snap => replicate_job_900_to_node2_1840_snap)
-1840 job_900_to_node2: delete snapshot 'replicate_job_900_to_node2_1000_snap' on local-zfs:vm-900-disk-1
+1840 job_900_to_node2: create snapshot '__replicate_job_900_to_node2_1840__' on local-zfs:vm-900-disk-1
+1840 job_900_to_node2: incremental sync 'local-zfs:vm-900-disk-1' (__replicate_job_900_to_node2_1000__ => __replicate_job_900_to_node2_1840__)
+1840 job_900_to_node2: delete snapshot '__replicate_job_900_to_node2_1000__' on local-zfs:vm-900-disk-1
1840 job_900_to_node2: end replication job
1840 job_900_to_node2: changed config next_sync => 2700
1840 job_900_to_node2: changed state last_try => 1840, last_sync => 1840
2740 job_900_to_node2: start replication job
2740 job_900_to_node2: guest => 900, type => qemu, running => 0
2740 job_900_to_node2: volumes => local-zfs:vm-900-disk-1,local-zfs:vm-900-disk-2
-2740 job_900_to_node2: create snapshot 'replicate_job_900_to_node2_2740_snap' on local-zfs:vm-900-disk-1
-2740 job_900_to_node2: create snapshot 'replicate_job_900_to_node2_2740_snap' on local-zfs:vm-900-disk-2
-2740 job_900_to_node2: delete snapshot 'replicate_job_900_to_node2_2740_snap' on local-zfs:vm-900-disk-1
+2740 job_900_to_node2: create snapshot '__replicate_job_900_to_node2_2740__' on local-zfs:vm-900-disk-1
+2740 job_900_to_node2: create snapshot '__replicate_job_900_to_node2_2740__' on local-zfs:vm-900-disk-2
+2740 job_900_to_node2: delete snapshot '__replicate_job_900_to_node2_2740__' on local-zfs:vm-900-disk-1
2740 job_900_to_node2: end replication job with error: no such volid 'local-zfs:vm-900-disk-2'
2740 job_900_to_node2: changed config next_sync => 3040
2740 job_900_to_node2: changed state last_try => 2740, fail_count => 1, error => no such volid 'local-zfs:vm-900-disk-2'
3040 job_900_to_node2: start replication job
3040 job_900_to_node2: guest => 900, type => qemu, running => 0
3040 job_900_to_node2: volumes => local-zfs:vm-900-disk-1,local-zfs:vm-900-disk-2
-3040 job_900_to_node2: create snapshot 'replicate_job_900_to_node2_3040_snap' on local-zfs:vm-900-disk-1
-3040 job_900_to_node2: create snapshot 'replicate_job_900_to_node2_3040_snap' on local-zfs:vm-900-disk-2
-3040 job_900_to_node2: incremental sync 'local-zfs:vm-900-disk-1' (replicate_job_900_to_node2_1840_snap => replicate_job_900_to_node2_3040_snap)
-3040 job_900_to_node2: full sync 'local-zfs:vm-900-disk-2' (replicate_job_900_to_node2_3040_snap)
-3040 job_900_to_node2: delete snapshot 'replicate_job_900_to_node2_1840_snap' on local-zfs:vm-900-disk-1
+3040 job_900_to_node2: create snapshot '__replicate_job_900_to_node2_3040__' on local-zfs:vm-900-disk-1
+3040 job_900_to_node2: create snapshot '__replicate_job_900_to_node2_3040__' on local-zfs:vm-900-disk-2
+3040 job_900_to_node2: incremental sync 'local-zfs:vm-900-disk-1' (__replicate_job_900_to_node2_1840__ => __replicate_job_900_to_node2_3040__)
+3040 job_900_to_node2: full sync 'local-zfs:vm-900-disk-2' (__replicate_job_900_to_node2_3040__)
+3040 job_900_to_node2: delete snapshot '__replicate_job_900_to_node2_1840__' on local-zfs:vm-900-disk-1
3040 job_900_to_node2: end replication job
3040 job_900_to_node2: changed config next_sync => 3600
3040 job_900_to_node2: changed state last_try => 3040, last_sync => 3040, fail_count => 0, error =>
3640 job_900_to_node2: start replication job
3640 job_900_to_node2: guest => 900, type => qemu, running => 0
3640 job_900_to_node2: volumes => local-zfs:vm-900-disk-1,local-zfs:vm-900-disk-2
-3640 job_900_to_node2: create snapshot 'replicate_job_900_to_node2_3640_snap' on local-zfs:vm-900-disk-1
-3640 job_900_to_node2: create snapshot 'replicate_job_900_to_node2_3640_snap' on local-zfs:vm-900-disk-2
-3640 job_900_to_node2: incremental sync 'local-zfs:vm-900-disk-1' (replicate_job_900_to_node2_3040_snap => replicate_job_900_to_node2_3640_snap)
-3640 job_900_to_node2: incremental sync 'local-zfs:vm-900-disk-2' (replicate_job_900_to_node2_3040_snap => replicate_job_900_to_node2_3640_snap)
-3640 job_900_to_node2: delete snapshot 'replicate_job_900_to_node2_3040_snap' on local-zfs:vm-900-disk-1
-3640 job_900_to_node2: delete snapshot 'replicate_job_900_to_node2_3040_snap' on local-zfs:vm-900-disk-2
+3640 job_900_to_node2: create snapshot '__replicate_job_900_to_node2_3640__' on local-zfs:vm-900-disk-1
+3640 job_900_to_node2: create snapshot '__replicate_job_900_to_node2_3640__' on local-zfs:vm-900-disk-2
+3640 job_900_to_node2: incremental sync 'local-zfs:vm-900-disk-1' (__replicate_job_900_to_node2_3040__ => __replicate_job_900_to_node2_3640__)
+3640 job_900_to_node2: incremental sync 'local-zfs:vm-900-disk-2' (__replicate_job_900_to_node2_3040__ => __replicate_job_900_to_node2_3640__)
+3640 job_900_to_node2: delete snapshot '__replicate_job_900_to_node2_3040__' on local-zfs:vm-900-disk-1
+3640 job_900_to_node2: delete snapshot '__replicate_job_900_to_node2_3040__' on local-zfs:vm-900-disk-2
3640 job_900_to_node2: end replication job
3640 job_900_to_node2: changed config next_sync => 4500
3640 job_900_to_node2: changed state last_try => 3640, last_sync => 3640
@@ -53,8 +53,8 @@
3700 job_900_to_node2: guest => 900, type => qemu, running => 0
3700 job_900_to_node2: volumes => local-zfs:vm-900-disk-1,local-zfs:vm-900-disk-2
3700 job_900_to_node2: start job removal - mode 'full'
-3700 job_900_to_node2: delete stale snapshot 'replicate_job_900_to_node2_3640_snap' on local-zfs:vm-900-disk-1
-3700 job_900_to_node2: delete stale snapshot 'replicate_job_900_to_node2_3640_snap' on local-zfs:vm-900-disk-2
+3700 job_900_to_node2: delete stale snapshot '__replicate_job_900_to_node2_3640__' on local-zfs:vm-900-disk-1
+3700 job_900_to_node2: delete stale snapshot '__replicate_job_900_to_node2_3640__' on local-zfs:vm-900-disk-2
3700 job_900_to_node2: job removed
3700 job_900_to_node2: end replication job
3700 job_900_to_node2: vanished job
diff --git a/bin/test/replication_test5.pl b/bin/test/replication_test5.pl
index 5e31b859..3db7351d 100755
--- a/bin/test/replication_test5.pl
+++ b/bin/test/replication_test5.pl
@@ -40,7 +40,7 @@ my $mocked_remote_prepare_local_job = sub {
return $last_snapshots if !defined($replicated_volume_status->{$target});
- my $last_sync_snapname = PVE::Replication::replication_snapshot_name($jobid, $last_sync);
+ my $last_sync_snapname = PVE::ReplicationState::replication_snapshot_name($jobid, $last_sync);
foreach my $volid (keys %{$replicated_volume_status->{$target}}) {
if (!grep { $_ eq $volid } @$volumes) {
--
2.11.0
More information about the pve-devel
mailing list