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