50dc83
From d148248aa3f0dfe7356a13d6fd029f0c6b3746cf Mon Sep 17 00:00:00 2001
50dc83
From: Kotresh HR <khiremat@redhat.com>
50dc83
Date: Wed, 8 May 2019 10:56:31 +0530
50dc83
Subject: [PATCH 162/169] geo-rep: Fix sync-method config
50dc83
50dc83
Problem:
50dc83
When 'use_tarssh' is set to true, it exits with successful
50dc83
message but the default 'rsync' was used as sync-engine.
50dc83
The new config 'sync-method' is not allowed to set from cli.
50dc83
50dc83
Analysis and Fix:
50dc83
The 'use_tarssh' config is deprecated with new
50dc83
config framework and 'sync-method' is the new
50dc83
config to choose sync-method i.e. tarssh or rsync.
50dc83
This patch fixes the 'sync-method' config. The allowed
50dc83
values are tarssh and rsync.
50dc83
50dc83
Backport of:
50dc83
 > Patch: https://review.gluster.org/22683
50dc83
 > Change-Id: I0edb0319cad0455b29e49f2f08a64ce324735e84
50dc83
 > BUG: 1707686
50dc83
 > Signed-off-by: Kotresh HR <khiremat@redhat.com>
50dc83
50dc83
Change-Id: I0edb0319cad0455b29e49f2f08a64ce324735e84
50dc83
fixes: bz#1708067
50dc83
Signed-off-by: Kotresh HR <khiremat@redhat.com>
50dc83
Reviewed-on: https://code.engineering.redhat.com/gerrit/172394
50dc83
Tested-by: RHGS Build Bot <nigelb@redhat.com>
50dc83
Reviewed-by: Sunny Kumar <sunkumar@redhat.com>
50dc83
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
50dc83
---
50dc83
 geo-replication/gsyncd.conf.in                    | 9 +++++----
50dc83
 geo-replication/syncdaemon/resource.py            | 7 ++++---
50dc83
 tests/00-geo-rep/georep-basic-dr-rsync-arbiter.t  | 4 ++--
50dc83
 tests/00-geo-rep/georep-basic-dr-rsync.t          | 4 ++--
50dc83
 tests/00-geo-rep/georep-basic-dr-tarssh-arbiter.t | 6 +++---
50dc83
 tests/00-geo-rep/georep-basic-dr-tarssh.t         | 6 +++---
50dc83
 tests/geo-rep.rc                                  | 3 ++-
50dc83
 7 files changed, 21 insertions(+), 18 deletions(-)
50dc83
50dc83
diff --git a/geo-replication/gsyncd.conf.in b/geo-replication/gsyncd.conf.in
50dc83
index 6160c7c..c2e4f0d 100644
50dc83
--- a/geo-replication/gsyncd.conf.in
50dc83
+++ b/geo-replication/gsyncd.conf.in
50dc83
@@ -128,10 +128,11 @@ value=
50dc83
 value=5
50dc83
 type=int
50dc83
 
50dc83
-[use-tarssh]
50dc83
-value=false
50dc83
-type=bool
50dc83
-help=Use sync-mode as tarssh
50dc83
+[sync-method]
50dc83
+value=rsync
50dc83
+help=Sync method for data sync. Available methods are tar over ssh and rsync. Default is rsync.
50dc83
+validation=choice
50dc83
+allowed_values=tarssh,rsync
50dc83
 
50dc83
 [remote-gsyncd]
50dc83
 value =
50dc83
diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py
50dc83
index f54ccd9..522279b 100644
50dc83
--- a/geo-replication/syncdaemon/resource.py
50dc83
+++ b/geo-replication/syncdaemon/resource.py
50dc83
@@ -1512,7 +1512,7 @@ class SSH(object):
50dc83
 
50dc83
         return po
50dc83
 
50dc83
-    def tarssh(self, files, slaveurl, log_err=False):
50dc83
+    def tarssh(self, files, log_err=False):
50dc83
         """invoke tar+ssh
50dc83
         -z (compress) can be use if needed, but omitting it now
50dc83
         as it results in weird error (tar+ssh errors out (errcode: 2)
50dc83
@@ -1520,10 +1520,11 @@ class SSH(object):
50dc83
         if not files:
50dc83
             raise GsyncdError("no files to sync")
50dc83
         logging.debug("files: " + ", ".join(files))
50dc83
-        (host, rdir) = slaveurl.split(':')
50dc83
+        (host, rdir) = self.slaveurl.split(':')
50dc83
+
50dc83
         tar_cmd = ["tar"] + \
50dc83
             ["--sparse", "-cf", "-", "--files-from", "-"]
50dc83
-        ssh_cmd = gconf.get("ssh-command-tar").split() + \
50dc83
+        ssh_cmd = gconf.get("ssh-command").split() + \
50dc83
             gconf.get("ssh-options-tar").split() + \
50dc83
             ["-p", str(gconf.get("ssh-port"))] + \
50dc83
             [host, "tar"] + \
50dc83
diff --git a/tests/00-geo-rep/georep-basic-dr-rsync-arbiter.t b/tests/00-geo-rep/georep-basic-dr-rsync-arbiter.t
50dc83
index 1a55ed2..8b90347 100644
50dc83
--- a/tests/00-geo-rep/georep-basic-dr-rsync-arbiter.t
50dc83
+++ b/tests/00-geo-rep/georep-basic-dr-rsync-arbiter.t
50dc83
@@ -159,7 +159,7 @@ EXPECT_WITHIN $GEO_REP_TIMEOUT 0 chown_file_ok ${slave_mnt}/changelog_chown_f1
50dc83
 
50dc83
 #logrotate
50dc83
 EXPECT_WITHIN $GEO_REP_TIMEOUT 0 directory_ok ${slave_mnt}/logrotate
50dc83
-EXPECT_WITHIN $GEO_REP_TIMEOUT 0 arequal_checksum ${master_mnt}/logrotate ${slave_mnt}/logrotate
50dc83
+EXPECT_WITHIN $GEO_REP_TIMEOUT "x0" arequal_checksum ${master_mnt}/logrotate ${slave_mnt}/logrotate
50dc83
 
50dc83
 #CREATE+RENAME
50dc83
 EXPECT_WITHIN $GEO_REP_TIMEOUT 0 create_rename_ok ${slave_mnt}/create_rename_test_file
50dc83
@@ -209,7 +209,7 @@ TEST create_rename_with_existing_destination ${master_mnt}
50dc83
 EXPECT_WITHIN $GEO_REP_TIMEOUT 0 verify_rename_with_existing_destination ${slave_mnt}
50dc83
 
50dc83
 #Verify arequal for whole volume
50dc83
-EXPECT_WITHIN $GEO_REP_TIMEOUT 0 arequal_checksum ${master_mnt} ${slave_mnt}
50dc83
+EXPECT_WITHIN $GEO_REP_TIMEOUT "x0" arequal_checksum ${master_mnt} ${slave_mnt}
50dc83
 
50dc83
 #Stop Geo-rep
50dc83
 TEST $GEOREP_CLI $master $slave stop
50dc83
diff --git a/tests/00-geo-rep/georep-basic-dr-rsync.t b/tests/00-geo-rep/georep-basic-dr-rsync.t
50dc83
index d0c0fc9..428e9ed 100644
50dc83
--- a/tests/00-geo-rep/georep-basic-dr-rsync.t
50dc83
+++ b/tests/00-geo-rep/georep-basic-dr-rsync.t
50dc83
@@ -160,7 +160,7 @@ EXPECT_WITHIN $GEO_REP_TIMEOUT 0 chown_file_ok ${slave_mnt}/changelog_chown_f1
50dc83
 
50dc83
 #logrotate
50dc83
 EXPECT_WITHIN $GEO_REP_TIMEOUT 0 directory_ok ${slave_mnt}/logrotate
50dc83
-EXPECT_WITHIN $GEO_REP_TIMEOUT 0 arequal_checksum ${master_mnt}/logrotate ${slave_mnt}/logrotate
50dc83
+EXPECT_WITHIN $GEO_REP_TIMEOUT "x0" arequal_checksum ${master_mnt}/logrotate ${slave_mnt}/logrotate
50dc83
 
50dc83
 #CREATE+RENAME
50dc83
 EXPECT_WITHIN $GEO_REP_TIMEOUT 0 create_rename_ok ${slave_mnt}/create_rename_test_file
50dc83
@@ -210,7 +210,7 @@ TEST create_rename_with_existing_destination ${master_mnt}
50dc83
 EXPECT_WITHIN $GEO_REP_TIMEOUT 0 verify_rename_with_existing_destination ${slave_mnt}
50dc83
 
50dc83
 #Verify arequal for whole volume
50dc83
-EXPECT_WITHIN $GEO_REP_TIMEOUT 0 arequal_checksum ${master_mnt} ${slave_mnt}
50dc83
+EXPECT_WITHIN $GEO_REP_TIMEOUT "x0" arequal_checksum ${master_mnt} ${slave_mnt}
50dc83
 
50dc83
 #Stop Geo-rep
50dc83
 TEST $GEOREP_CLI $master $slave stop
50dc83
diff --git a/tests/00-geo-rep/georep-basic-dr-tarssh-arbiter.t b/tests/00-geo-rep/georep-basic-dr-tarssh-arbiter.t
50dc83
index cb530ad..8fed929 100644
50dc83
--- a/tests/00-geo-rep/georep-basic-dr-tarssh-arbiter.t
50dc83
+++ b/tests/00-geo-rep/georep-basic-dr-tarssh-arbiter.t
50dc83
@@ -81,7 +81,7 @@ TEST $GEOREP_CLI $master $slave config use_meta_volume true
50dc83
 TEST $CLI volume set $GMV0 changelog.rollover-time 3
50dc83
 
50dc83
 #Config tarssh as sync-engine
50dc83
-TEST $GEOREP_CLI $master $slave config use_tarssh true
50dc83
+TEST $GEOREP_CLI $master $slave config sync-method tarssh
50dc83
 
50dc83
 #Wait for common secret pem file to be created
50dc83
 EXPECT_WITHIN $GEO_REP_TIMEOUT  0 check_common_secret_file
50dc83
@@ -162,7 +162,7 @@ EXPECT_WITHIN $GEO_REP_TIMEOUT 0 chown_file_ok ${slave_mnt}/changelog_chown_f1
50dc83
 
50dc83
 #logrotate
50dc83
 EXPECT_WITHIN $GEO_REP_TIMEOUT 0 directory_ok ${slave_mnt}/logrotate
50dc83
-EXPECT_WITHIN $GEO_REP_TIMEOUT 0 arequal_checksum ${master_mnt}/logrotate ${slave_mnt}/logrotate
50dc83
+EXPECT_WITHIN $GEO_REP_TIMEOUT "x0" arequal_checksum ${master_mnt}/logrotate ${slave_mnt}/logrotate
50dc83
 
50dc83
 #CREATE+RENAME
50dc83
 EXPECT_WITHIN $GEO_REP_TIMEOUT 0 create_rename_ok ${slave_mnt}/create_rename_test_file
50dc83
@@ -208,7 +208,7 @@ TEST create_rename_with_existing_destination ${master_mnt}
50dc83
 EXPECT_WITHIN $GEO_REP_TIMEOUT 0 verify_rename_with_existing_destination ${slave_mnt}
50dc83
 
50dc83
 #Verify arequal for whole volume
50dc83
-EXPECT_WITHIN $GEO_REP_TIMEOUT 0 arequal_checksum ${master_mnt} ${slave_mnt}
50dc83
+EXPECT_WITHIN $GEO_REP_TIMEOUT "x0" arequal_checksum ${master_mnt} ${slave_mnt}
50dc83
 
50dc83
 #Stop Geo-rep
50dc83
 TEST $GEOREP_CLI $master $slave stop
50dc83
diff --git a/tests/00-geo-rep/georep-basic-dr-tarssh.t b/tests/00-geo-rep/georep-basic-dr-tarssh.t
50dc83
index 9e2f613..feb2de7 100644
50dc83
--- a/tests/00-geo-rep/georep-basic-dr-tarssh.t
50dc83
+++ b/tests/00-geo-rep/georep-basic-dr-tarssh.t
50dc83
@@ -81,7 +81,7 @@ TEST $GEOREP_CLI $master $slave config use_meta_volume true
50dc83
 TEST $CLI volume set $GMV0 changelog.rollover-time 3
50dc83
 
50dc83
 #Config tarssh as sync-engine
50dc83
-TEST $GEOREP_CLI $master $slave config use_tarssh true
50dc83
+TEST $GEOREP_CLI $master $slave config sync-method tarssh
50dc83
 
50dc83
 #Wait for common secret pem file to be created
50dc83
 EXPECT_WITHIN $GEO_REP_TIMEOUT  0 check_common_secret_file
50dc83
@@ -162,7 +162,7 @@ EXPECT_WITHIN $GEO_REP_TIMEOUT 0 chown_file_ok ${slave_mnt}/changelog_chown_f1
50dc83
 
50dc83
 #logrotate
50dc83
 EXPECT_WITHIN $GEO_REP_TIMEOUT 0 directory_ok ${slave_mnt}/logrotate
50dc83
-EXPECT_WITHIN $GEO_REP_TIMEOUT 0 arequal_checksum ${master_mnt}/logrotate ${slave_mnt}/logrotate
50dc83
+EXPECT_WITHIN $GEO_REP_TIMEOUT "x0" arequal_checksum ${master_mnt}/logrotate ${slave_mnt}/logrotate
50dc83
 
50dc83
 #CREATE+RENAME
50dc83
 EXPECT_WITHIN $GEO_REP_TIMEOUT 0 create_rename_ok ${slave_mnt}/create_rename_test_file
50dc83
@@ -208,7 +208,7 @@ TEST create_rename_with_existing_destination ${master_mnt}
50dc83
 EXPECT_WITHIN $GEO_REP_TIMEOUT 0 verify_rename_with_existing_destination ${slave_mnt}
50dc83
 
50dc83
 #Verify arequal for whole volume
50dc83
-EXPECT_WITHIN $GEO_REP_TIMEOUT 0 arequal_checksum ${master_mnt} ${slave_mnt}
50dc83
+EXPECT_WITHIN $GEO_REP_TIMEOUT "x0" arequal_checksum ${master_mnt} ${slave_mnt}
50dc83
 
50dc83
 #Stop Geo-rep
50dc83
 TEST $GEOREP_CLI $master $slave stop
50dc83
diff --git a/tests/geo-rep.rc b/tests/geo-rep.rc
50dc83
index e357ba8..2035b9f 100644
50dc83
--- a/tests/geo-rep.rc
50dc83
+++ b/tests/geo-rep.rc
50dc83
@@ -168,7 +168,8 @@ function arequal_checksum()
50dc83
 {
50dc83
     master=$1
50dc83
     slave=$2
50dc83
-    diff <(arequal-checksum -p $master) <(arequal-checksum -p $slave) | wc -l
50dc83
+    ret=$(diff <(arequal-checksum -p $master) <(arequal-checksum -p $slave) | wc -l)
50dc83
+    echo x$ret
50dc83
 }
50dc83
 
50dc83
 function symlink_ok()
50dc83
-- 
50dc83
1.8.3.1
50dc83