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