ca3909
From 2b1738402276f43d7cb64542b74cb50145e46d77 Mon Sep 17 00:00:00 2001
ca3909
From: Kotresh HR <khiremat@redhat.com>
ca3909
Date: Wed, 16 Oct 2019 14:25:47 +0530
ca3909
Subject: [PATCH 309/309] geo-rep: Fix config upgrade on non-participating node
ca3909
ca3909
After upgrade, if the config files are of old format, it
ca3909
gets migrated to new format. Monitor process migrates it.
ca3909
Since monitor doesn't run on nodes where bricks are not
ca3909
hosted, it doesn't get migrated there. So this patch fixes
ca3909
the config upgrade on nodes which doesn't host bricks.
ca3909
This happens during config either on get/set/reset.
ca3909
ca3909
Backport of:
ca3909
 > Patch: https://review.gluster.org/23555
ca3909
 > Change-Id: Ibade2f2310b0f3affea21a3baa1ae0eb71162cba
ca3909
 > Signed-off-by: Kotresh HR <khiremat@redhat.com>
ca3909
 > fixes: bz#1762220
ca3909
ca3909
Change-Id: Ibade2f2310b0f3affea21a3baa1ae0eb71162cba
ca3909
Signed-off-by: Kotresh HR <khiremat@redhat.com>
ca3909
BUG: 1760939
ca3909
Reviewed-on: https://code.engineering.redhat.com/gerrit/183461
ca3909
Tested-by: RHGS Build Bot <nigelb@redhat.com>
ca3909
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
ca3909
---
ca3909
 geo-replication/syncdaemon/gsyncd.py     |   3 +-
ca3909
 tests/00-geo-rep/georep-config-upgrade.t | 132 +++++++++++++++++++++++++++++++
ca3909
 tests/00-geo-rep/gsyncd.conf.old         |  47 +++++++++++
ca3909
 3 files changed, 181 insertions(+), 1 deletion(-)
ca3909
 create mode 100644 tests/00-geo-rep/georep-config-upgrade.t
ca3909
 create mode 100644 tests/00-geo-rep/gsyncd.conf.old
ca3909
ca3909
diff --git a/geo-replication/syncdaemon/gsyncd.py b/geo-replication/syncdaemon/gsyncd.py
ca3909
index 6ae5269..7b48d82 100644
ca3909
--- a/geo-replication/syncdaemon/gsyncd.py
ca3909
+++ b/geo-replication/syncdaemon/gsyncd.py
ca3909
@@ -255,7 +255,8 @@ def main():
ca3909
     if args.subcmd == "slave":
ca3909
         override_from_args = True
ca3909
 
ca3909
-    if args.subcmd == "monitor":
ca3909
+    if config_file is not None and \
ca3909
+       args.subcmd in ["monitor", "config-get", "config-set", "config-reset"]:
ca3909
         ret = gconf.is_config_file_old(config_file, args.master, extra_tmpl_args["slavevol"])
ca3909
         if ret is not None:
ca3909
            gconf.config_upgrade(config_file, ret)
ca3909
diff --git a/tests/00-geo-rep/georep-config-upgrade.t b/tests/00-geo-rep/georep-config-upgrade.t
ca3909
new file mode 100644
ca3909
index 0000000..557461c
ca3909
--- /dev/null
ca3909
+++ b/tests/00-geo-rep/georep-config-upgrade.t
ca3909
@@ -0,0 +1,132 @@
ca3909
+#!/bin/bash
ca3909
+
ca3909
+. $(dirname $0)/../include.rc
ca3909
+. $(dirname $0)/../volume.rc
ca3909
+. $(dirname $0)/../geo-rep.rc
ca3909
+. $(dirname $0)/../env.rc
ca3909
+
ca3909
+SCRIPT_TIMEOUT=300
ca3909
+OLD_CONFIG_PATH=$(dirname $0)/gsyncd.conf.old
ca3909
+WORKING_DIR=/var/lib/glusterd/geo-replication/master_127.0.0.1_slave
ca3909
+
ca3909
+##Cleanup and start glusterd
ca3909
+cleanup;
ca3909
+TEST glusterd;
ca3909
+TEST pidof glusterd
ca3909
+
ca3909
+##Variables
ca3909
+GEOREP_CLI="$CLI volume geo-replication"
ca3909
+master=$GMV0
ca3909
+SH0="127.0.0.1"
ca3909
+slave=${SH0}::${GSV0}
ca3909
+num_active=2
ca3909
+num_passive=2
ca3909
+master_mnt=$M0
ca3909
+slave_mnt=$M1
ca3909
+
ca3909
+############################################################
ca3909
+#SETUP VOLUMES AND GEO-REPLICATION
ca3909
+############################################################
ca3909
+
ca3909
+##create_and_start_master_volume
ca3909
+TEST $CLI volume create $GMV0 replica 2 $H0:$B0/${GMV0}{1,2,3,4};
ca3909
+TEST $CLI volume start $GMV0
ca3909
+
ca3909
+##create_and_start_slave_volume
ca3909
+TEST $CLI volume create $GSV0 replica 2 $H0:$B0/${GSV0}{1,2,3,4};
ca3909
+TEST $CLI volume start $GSV0
ca3909
+
ca3909
+##Create, start and mount meta_volume
ca3909
+TEST $CLI volume create $META_VOL replica 3 $H0:$B0/${META_VOL}{1,2,3};
ca3909
+TEST $CLI volume start $META_VOL
ca3909
+TEST mkdir -p $META_MNT
ca3909
+TEST glusterfs -s $H0 --volfile-id $META_VOL $META_MNT
ca3909
+
ca3909
+##Mount master
ca3909
+TEST glusterfs -s $H0 --volfile-id $GMV0 $M0
ca3909
+
ca3909
+##Mount slave
ca3909
+TEST glusterfs -s $H0 --volfile-id $GSV0 $M1
ca3909
+
ca3909
+############################################################
ca3909
+#BASIC GEO-REPLICATION TESTS
ca3909
+############################################################
ca3909
+
ca3909
+#Create geo-rep session
ca3909
+TEST create_georep_session $master $slave
ca3909
+
ca3909
+#Config gluster-command-dir
ca3909
+TEST $GEOREP_CLI $master $slave config gluster-command-dir ${GLUSTER_CMD_DIR}
ca3909
+
ca3909
+#Config gluster-command-dir
ca3909
+TEST $GEOREP_CLI $master $slave config slave-gluster-command-dir ${GLUSTER_CMD_DIR}
ca3909
+
ca3909
+#Enable_metavolume
ca3909
+TEST $GEOREP_CLI $master $slave config use_meta_volume true
ca3909
+
ca3909
+#Wait for common secret pem file to be created
ca3909
+EXPECT_WITHIN $GEO_REP_TIMEOUT  0 check_common_secret_file
ca3909
+
ca3909
+#Verify the keys are distributed
ca3909
+EXPECT_WITHIN $GEO_REP_TIMEOUT  0 check_keys_distributed
ca3909
+
ca3909
+#Start_georep
ca3909
+TEST $GEOREP_CLI $master $slave start
ca3909
+
ca3909
+EXPECT_WITHIN $GEO_REP_TIMEOUT  2 check_status_num_rows "Active"
ca3909
+EXPECT_WITHIN $GEO_REP_TIMEOUT  2 check_status_num_rows "Passive"
ca3909
+
ca3909
+TEST $GEOREP_CLI $master $slave config sync-method tarssh
ca3909
+
ca3909
+#Stop Geo-rep
ca3909
+TEST $GEOREP_CLI $master $slave stop
ca3909
+
ca3909
+#Copy old config file
ca3909
+mv -f $WORKING_DIR/gsyncd.conf $WORKING_DIR/gsyncd.conf.org
ca3909
+cp -p $OLD_CONFIG_PATH $WORKING_DIR/gsyncd.conf
ca3909
+
ca3909
+#Check if config get all updates config_file
ca3909
+TEST ! grep "sync-method" $WORKING_DIR/gsyncd.conf
ca3909
+TEST $GEOREP_CLI $master $slave config
ca3909
+TEST grep "sync-method" $WORKING_DIR/gsyncd.conf
ca3909
+
ca3909
+#Check if config get updates config_file
ca3909
+rm -f $WORKING_DIR/gsyncd.conf
ca3909
+cp -p $OLD_CONFIG_PATH $WORKING_DIR/gsyncd.conf
ca3909
+TEST ! grep "sync-method" $WORKING_DIR/gsyncd.conf
ca3909
+TEST $GEOREP_CLI $master $slave config sync-method
ca3909
+TEST grep "sync-method" $WORKING_DIR/gsyncd.conf
ca3909
+
ca3909
+#Check if config set updates config_file
ca3909
+rm -f $WORKING_DIR/gsyncd.conf
ca3909
+cp -p $OLD_CONFIG_PATH $WORKING_DIR/gsyncd.conf
ca3909
+TEST ! grep "sync-method" $WORKING_DIR/gsyncd.conf
ca3909
+TEST $GEOREP_CLI $master $slave config sync-xattrs false
ca3909
+TEST grep "sync-method" $WORKING_DIR/gsyncd.conf
ca3909
+
ca3909
+#Check if config reset updates config_file
ca3909
+rm -f $WORKING_DIR/gsyncd.conf
ca3909
+cp -p $OLD_CONFIG_PATH $WORKING_DIR/gsyncd.conf
ca3909
+TEST ! grep "sync-method" $WORKING_DIR/gsyncd.conf
ca3909
+TEST $GEOREP_CLI $master $slave config \!sync-xattrs
ca3909
+TEST grep "sync-method" $WORKING_DIR/gsyncd.conf
ca3909
+
ca3909
+#Check if geo-rep start updates config_file
ca3909
+rm -f $WORKING_DIR/gsyncd.conf
ca3909
+cp -p $OLD_CONFIG_PATH $WORKING_DIR/gsyncd.conf
ca3909
+TEST ! grep "sync-method" $WORKING_DIR/gsyncd.conf
ca3909
+TEST $GEOREP_CLI $master $slave start
ca3909
+TEST grep "sync-method" $WORKING_DIR/gsyncd.conf
ca3909
+
ca3909
+#Stop geo-rep
ca3909
+TEST $GEOREP_CLI $master $slave stop
ca3909
+
ca3909
+#Delete Geo-rep
ca3909
+TEST $GEOREP_CLI $master $slave delete
ca3909
+
ca3909
+#Cleanup authorized keys
ca3909
+sed -i '/^command=.*SSH_ORIGINAL_COMMAND#.*/d' ~/.ssh/authorized_keys
ca3909
+sed -i '/^command=.*gsyncd.*/d' ~/.ssh/authorized_keys
ca3909
+
ca3909
+cleanup;
ca3909
+#G_TESTDEF_TEST_STATUS_NETBSD7=BAD_TEST,BUG=000000
ca3909
diff --git a/tests/00-geo-rep/gsyncd.conf.old b/tests/00-geo-rep/gsyncd.conf.old
ca3909
new file mode 100644
ca3909
index 0000000..519acaf
ca3909
--- /dev/null
ca3909
+++ b/tests/00-geo-rep/gsyncd.conf.old
ca3909
@@ -0,0 +1,47 @@
ca3909
+[__meta__]
ca3909
+version = 2.0
ca3909
+
ca3909
+[peersrx . .]
ca3909
+remote_gsyncd = /usr/local/libexec/glusterfs/gsyncd
ca3909
+georep_session_working_dir = /var/lib/glusterd/geo-replication/${mastervol}_${remotehost}_${slavevol}/
ca3909
+ssh_command_tar = ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i /var/lib/glusterd/geo-replication/tar_ssh.pem
ca3909
+changelog_log_file = /var/log/glusterfs/geo-replication/${mastervol}/${eSlave}${local_id}-changes.log
ca3909
+working_dir = /var/lib/misc/glusterfsd/${mastervol}/${eSlave}
ca3909
+ignore_deletes = false
ca3909
+pid_file = /var/lib/glusterd/geo-replication/${mastervol}_${remotehost}_${slavevol}/monitor.pid
ca3909
+state_file = /var/lib/glusterd/geo-replication/${mastervol}_${remotehost}_${slavevol}/monitor.status
ca3909
+gluster_command_dir = /usr/local/sbin/
ca3909
+gluster_params = aux-gfid-mount acl
ca3909
+ssh_command = ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i /var/lib/glusterd/geo-replication/secret.pem
ca3909
+state_detail_file = /var/lib/glusterd/geo-replication/${mastervol}_${remotehost}_${slavevol}/${eSlave}-detail.status
ca3909
+state_socket_unencoded = /var/lib/glusterd/geo-replication/${mastervol}_${remotehost}_${slavevol}/${eSlave}.socket
ca3909
+socketdir = /var/run/gluster
ca3909
+log_file = /var/log/glusterfs/geo-replication/${mastervol}/${eSlave}.log
ca3909
+gluster_log_file = /var/log/glusterfs/geo-replication/${mastervol}/${eSlave}${local_id}.gluster.log
ca3909
+special_sync_mode = partial
ca3909
+change_detector = changelog
ca3909
+pid-file = /var/lib/glusterd/geo-replication/${mastervol}_${remotehost}_${slavevol}/monitor.pid
ca3909
+state-file = /var/lib/glusterd/geo-replication/${mastervol}_${remotehost}_${slavevol}/monitor.status
ca3909
+
ca3909
+[__section_order__]
ca3909
+peersrx . . = 0
ca3909
+peersrx . %5essh%3a = 2
ca3909
+peersrx . = 3
ca3909
+peers master slave = 4
ca3909
+
ca3909
+[peersrx . %5Essh%3A]
ca3909
+remote_gsyncd = /nonexistent/gsyncd
ca3909
+
ca3909
+[peersrx .]
ca3909
+gluster_command_dir = /usr/local/sbin/
ca3909
+gluster_params = aux-gfid-mount acl
ca3909
+log_file = /var/log/glusterfs/geo-replication-slaves/${session_owner}:${local_node}${local_id}.${slavevol}.log
ca3909
+log_file_mbr = /var/log/glusterfs/geo-replication-slaves/mbr/${session_owner}:${local_node}${local_id}.${slavevol}.log
ca3909
+gluster_log_file = /var/log/glusterfs/geo-replication-slaves/${session_owner}:${local_node}${local_id}.${slavevol}.gluster.log
ca3909
+
ca3909
+[peers master slave]
ca3909
+session_owner = 0732cbd1-3ec5-4920-ab0d-aa5a896d5214
ca3909
+master.stime_xattr_name = trusted.glusterfs.0732cbd1-3ec5-4920-ab0d-aa5a896d5214.07a9005c-ace4-4f67-b3c0-73938fb236c4.stime
ca3909
+volume_id = 0732cbd1-3ec5-4920-ab0d-aa5a896d5214
ca3909
+use_tarssh = true
ca3909
+
ca3909
-- 
ca3909
1.8.3.1
ca3909