14f8ab
From 03de45e5fb1c8aa5369848ed9e52abd1365e1d21 Mon Sep 17 00:00:00 2001
14f8ab
From: Shwetha K Acharya <sacharya@redhat.com>
14f8ab
Date: Wed, 31 Jul 2019 11:34:19 +0530
14f8ab
Subject: [PATCH 493/511] geo-rep: Note section is required for ignore_deletes
14f8ab
14f8ab
There exists a window of 15 sec, where the deletes are picked up
14f8ab
by history crawl when the ignore_deletes is set to true.
14f8ab
And it eventually deletes the file/s from slave which is/are not
14f8ab
supposed to be deleted. Though it is working as per design, a
14f8ab
note regarding this is needed.
14f8ab
14f8ab
Added a warning message indicating the same.
14f8ab
Also logged info when the worker restarts after ignore-deletes
14f8ab
option set.
14f8ab
14f8ab
>fixes: bz#1708603
14f8ab
>Change-Id: I103be882fac18b4cef935efa355f5037a396f7c1
14f8ab
>Signed-off-by: Shwetha K Acharya <sacharya@redhat.com>
14f8ab
Upstream patch: https://review.gluster.org/c/glusterfs/+/22702
14f8ab
14f8ab
BUG: 1224906
14f8ab
Change-Id: I103be882fac18b4cef935efa355f5037a396f7c1
14f8ab
Signed-off-by: srijan-sivakumar <ssivakum@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/220757
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
14f8ab
---
14f8ab
 cli/src/cli-cmd-parser.c             | 45 ++++++++++++++++++++------
14f8ab
 cli/src/cli-cmd-volume.c             | 20 ++++++++----
14f8ab
 cli/src/cli.h                        |  3 +-
14f8ab
 geo-replication/syncdaemon/gsyncd.py |  2 +-
14f8ab
 geo-replication/syncdaemon/master.py |  6 ++++
14f8ab
 tests/00-geo-rep/bug-1708603.t       | 63 ++++++++++++++++++++++++++++++++++++
14f8ab
 6 files changed, 120 insertions(+), 19 deletions(-)
14f8ab
 create mode 100644 tests/00-geo-rep/bug-1708603.t
14f8ab
14f8ab
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
14f8ab
index 5fd05f4..34f17c9 100644
14f8ab
--- a/cli/src/cli-cmd-parser.c
14f8ab
+++ b/cli/src/cli-cmd-parser.c
14f8ab
@@ -2901,7 +2901,8 @@ out:
14f8ab
 }
14f8ab
 
14f8ab
 int32_t
14f8ab
-cli_cmd_gsync_set_parse(const char **words, int wordcount, dict_t **options)
14f8ab
+cli_cmd_gsync_set_parse(struct cli_state *state, const char **words,
14f8ab
+                        int wordcount, dict_t **options, char **errstr)
14f8ab
 {
14f8ab
     int32_t ret = -1;
14f8ab
     dict_t *dict = NULL;
14f8ab
@@ -2918,6 +2919,8 @@ cli_cmd_gsync_set_parse(const char **words, int wordcount, dict_t **options)
14f8ab
     char *save_ptr = NULL;
14f8ab
     char *slave_temp = NULL;
14f8ab
     char *token = NULL;
14f8ab
+    gf_answer_t answer = GF_ANSWER_NO;
14f8ab
+    const char *question = NULL;
14f8ab
 
14f8ab
     GF_ASSERT(words);
14f8ab
     GF_ASSERT(options);
14f8ab
@@ -2990,8 +2993,10 @@ cli_cmd_gsync_set_parse(const char **words, int wordcount, dict_t **options)
14f8ab
 
14f8ab
     if (masteri && gsyncd_url_check(words[masteri]))
14f8ab
         goto out;
14f8ab
-    if (slavei && !glob && !gsyncd_url_check(words[slavei]))
14f8ab
+    if (slavei && !glob && !gsyncd_url_check(words[slavei])) {
14f8ab
+        gf_asprintf(errstr, "Invalid slave url: %s", words[slavei]);
14f8ab
         goto out;
14f8ab
+    }
14f8ab
 
14f8ab
     w = str_getunamb(words[cmdi], opwords);
14f8ab
     if (!w)
14f8ab
@@ -3101,16 +3106,36 @@ cli_cmd_gsync_set_parse(const char **words, int wordcount, dict_t **options)
14f8ab
     }
14f8ab
     if (!ret)
14f8ab
         ret = dict_set_int32(dict, "type", type);
14f8ab
-    if (!ret && type == GF_GSYNC_OPTION_TYPE_CONFIG)
14f8ab
+    if (!ret && type == GF_GSYNC_OPTION_TYPE_CONFIG) {
14f8ab
+        if (!strcmp((char *)words[wordcount - 2], "ignore-deletes") &&
14f8ab
+            !strcmp((char *)words[wordcount - 1], "true")) {
14f8ab
+            question =
14f8ab
+                "There exists ~15 seconds delay for the option to take"
14f8ab
+                " effect from stime of the corresponding brick. Please"
14f8ab
+                " check the log for the time, the option is effective."
14f8ab
+                " Proceed";
14f8ab
+
14f8ab
+            answer = cli_cmd_get_confirmation(state, question);
14f8ab
+
14f8ab
+            if (GF_ANSWER_NO == answer) {
14f8ab
+                gf_log("cli", GF_LOG_INFO,
14f8ab
+                       "Operation "
14f8ab
+                       "cancelled, exiting");
14f8ab
+                *errstr = gf_strdup("Aborted by user.");
14f8ab
+                ret = -1;
14f8ab
+                goto out;
14f8ab
+            }
14f8ab
+        }
14f8ab
+
14f8ab
         ret = config_parse(words, wordcount, dict, cmdi, glob);
14f8ab
+    }
14f8ab
 
14f8ab
 out:
14f8ab
     if (slave_temp)
14f8ab
         GF_FREE(slave_temp);
14f8ab
-    if (ret) {
14f8ab
-        if (dict)
14f8ab
-            dict_unref(dict);
14f8ab
-    } else
14f8ab
+    if (ret && dict)
14f8ab
+        dict_unref(dict);
14f8ab
+    else
14f8ab
         *options = dict;
14f8ab
 
14f8ab
     return ret;
14f8ab
@@ -5659,9 +5684,9 @@ cli_cmd_bitrot_parse(const char **words, int wordcount, dict_t **options)
14f8ab
     int32_t ret = -1;
14f8ab
     char *w = NULL;
14f8ab
     char *volname = NULL;
14f8ab
-    char *opwords[] = {
14f8ab
-        "enable",       "disable", "scrub-throttle", "scrub-frequency", "scrub",
14f8ab
-        "signing-time", "signer-threads", NULL};
14f8ab
+    char *opwords[] = {"enable",          "disable", "scrub-throttle",
14f8ab
+                       "scrub-frequency", "scrub",   "signing-time",
14f8ab
+                       "signer-threads",  NULL};
14f8ab
     char *scrub_throt_values[] = {"lazy", "normal", "aggressive", NULL};
14f8ab
     char *scrub_freq_values[] = {"hourly",  "daily",  "weekly", "biweekly",
14f8ab
                                  "monthly", "minute", NULL};
14f8ab
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
14f8ab
index 72504ca..6f5bf8b 100644
14f8ab
--- a/cli/src/cli-cmd-volume.c
14f8ab
+++ b/cli/src/cli-cmd-volume.c
14f8ab
@@ -2457,6 +2457,7 @@ cli_cmd_volume_gsync_set_cbk(struct cli_state *state, struct cli_cmd_word *word,
14f8ab
     rpc_clnt_procedure_t *proc = NULL;
14f8ab
     call_frame_t *frame = NULL;
14f8ab
     cli_local_t *local = NULL;
14f8ab
+    char *errstr = NULL;
14f8ab
 #if (USE_EVENTS)
14f8ab
     int ret1 = -1;
14f8ab
     int cmd_type = -1;
14f8ab
@@ -2468,16 +2469,21 @@ cli_cmd_volume_gsync_set_cbk(struct cli_state *state, struct cli_cmd_word *word,
14f8ab
 
14f8ab
     proc = &cli_rpc_prog->proctable[GLUSTER_CLI_GSYNC_SET];
14f8ab
 
14f8ab
-    frame = create_frame(THIS, THIS->ctx->pool);
14f8ab
-    if (frame == NULL) {
14f8ab
-        ret = -1;
14f8ab
+    ret = cli_cmd_gsync_set_parse(state, words, wordcount, &options, &errstr);
14f8ab
+    if (ret) {
14f8ab
+        if (errstr) {
14f8ab
+            cli_err("%s", errstr);
14f8ab
+            GF_FREE(errstr);
14f8ab
+        } else {
14f8ab
+            cli_usage_out(word->pattern);
14f8ab
+        }
14f8ab
+        parse_err = 1;
14f8ab
         goto out;
14f8ab
     }
14f8ab
 
14f8ab
-    ret = cli_cmd_gsync_set_parse(words, wordcount, &options);
14f8ab
-    if (ret) {
14f8ab
-        cli_usage_out(word->pattern);
14f8ab
-        parse_err = 1;
14f8ab
+    frame = create_frame(THIS, THIS->ctx->pool);
14f8ab
+    if (frame == NULL) {
14f8ab
+        ret = -1;
14f8ab
         goto out;
14f8ab
     }
14f8ab
 
14f8ab
diff --git a/cli/src/cli.h b/cli/src/cli.h
14f8ab
index c30ae9c..7b4f446 100644
14f8ab
--- a/cli/src/cli.h
14f8ab
+++ b/cli/src/cli.h
14f8ab
@@ -269,7 +269,8 @@ int32_t
14f8ab
 cli_cmd_volume_reset_parse(const char **words, int wordcount, dict_t **opt);
14f8ab
 
14f8ab
 int32_t
14f8ab
-cli_cmd_gsync_set_parse(const char **words, int wordcount, dict_t **opt);
14f8ab
+cli_cmd_gsync_set_parse(struct cli_state *state, const char **words,
14f8ab
+                        int wordcount, dict_t **opt, char **errstr);
14f8ab
 
14f8ab
 int32_t
14f8ab
 cli_cmd_quota_parse(const char **words, int wordcount, dict_t **opt);
14f8ab
diff --git a/geo-replication/syncdaemon/gsyncd.py b/geo-replication/syncdaemon/gsyncd.py
14f8ab
index 8940384..215c62d 100644
14f8ab
--- a/geo-replication/syncdaemon/gsyncd.py
14f8ab
+++ b/geo-replication/syncdaemon/gsyncd.py
14f8ab
@@ -315,7 +315,7 @@ def main():
14f8ab
 
14f8ab
     # Log message for loaded config file
14f8ab
     if config_file is not None:
14f8ab
-        logging.info(lf("Using session config file", path=config_file))
14f8ab
+        logging.debug(lf("Using session config file", path=config_file))
14f8ab
 
14f8ab
     set_term_handler()
14f8ab
     excont = FreeObject(exval=0)
14f8ab
diff --git a/geo-replication/syncdaemon/master.py b/geo-replication/syncdaemon/master.py
14f8ab
index 08e98f8..98637e7 100644
14f8ab
--- a/geo-replication/syncdaemon/master.py
14f8ab
+++ b/geo-replication/syncdaemon/master.py
14f8ab
@@ -1549,6 +1549,12 @@ class GMasterChangeloghistoryMixin(GMasterChangelogMixin):
14f8ab
         data_stime = self.get_data_stime()
14f8ab
 
14f8ab
         end_time = int(time.time())
14f8ab
+
14f8ab
+        #as start of historical crawl marks Geo-rep worker restart
14f8ab
+        if gconf.get("ignore-deletes"):
14f8ab
+            logging.info(lf('ignore-deletes config option is set',
14f8ab
+                         stime=data_stime))
14f8ab
+
14f8ab
         logging.info(lf('starting history crawl',
14f8ab
                         turns=self.history_turns,
14f8ab
                         stime=data_stime,
14f8ab
diff --git a/tests/00-geo-rep/bug-1708603.t b/tests/00-geo-rep/bug-1708603.t
14f8ab
new file mode 100644
14f8ab
index 0000000..26913f1
14f8ab
--- /dev/null
14f8ab
+++ b/tests/00-geo-rep/bug-1708603.t
14f8ab
@@ -0,0 +1,63 @@
14f8ab
+#!/bin/bash
14f8ab
+
14f8ab
+. $(dirname $0)/../include.rc
14f8ab
+. $(dirname $0)/../volume.rc
14f8ab
+. $(dirname $0)/../geo-rep.rc
14f8ab
+. $(dirname $0)/../env.rc
14f8ab
+
14f8ab
+SCRIPT_TIMEOUT=300
14f8ab
+
14f8ab
+##Cleanup and start glusterd
14f8ab
+cleanup;
14f8ab
+TEST glusterd;
14f8ab
+TEST pidof glusterd
14f8ab
+
14f8ab
+
14f8ab
+##Variables
14f8ab
+GEOREP_CLI="gluster volume geo-replication"
14f8ab
+master=$GMV0
14f8ab
+SH0="127.0.0.1"
14f8ab
+slave=${SH0}::${GSV0}
14f8ab
+num_active=2
14f8ab
+num_passive=2
14f8ab
+master_mnt=$M0
14f8ab
+slave_mnt=$M1
14f8ab
+
14f8ab
+############################################################
14f8ab
+#SETUP VOLUMES AND GEO-REPLICATION
14f8ab
+############################################################
14f8ab
+
14f8ab
+##create_and_start_master_volume
14f8ab
+TEST $CLI volume create $GMV0 replica 2 $H0:$B0/${GMV0}{1,2,3,4};
14f8ab
+TEST $CLI volume start $GMV0
14f8ab
+
14f8ab
+##create_and_start_slave_volume
14f8ab
+TEST $CLI volume create $GSV0 replica 2 $H0:$B0/${GSV0}{1,2,3,4};
14f8ab
+TEST $CLI volume start $GSV0
14f8ab
+
14f8ab
+##Mount master
14f8ab
+TEST glusterfs -s $H0 --volfile-id $GMV0 $M0
14f8ab
+
14f8ab
+##Mount slave
14f8ab
+TEST glusterfs -s $H0 --volfile-id $GSV0 $M1
14f8ab
+
14f8ab
+#Create geo-rep session
14f8ab
+TEST create_georep_session $master $slave
14f8ab
+
14f8ab
+echo n | $GEOREP_CLI $master $slave config ignore-deletes true >/dev/null 2>&1
14f8ab
+EXPECT "false" echo $($GEOREP_CLI $master $slave config ignore-deletes)
14f8ab
+echo y | $GEOREP_CLI $master $slave config ignore-deletes true
14f8ab
+EXPECT "true" echo $($GEOREP_CLI $master $slave config ignore-deletes)
14f8ab
+
14f8ab
+#Stop Geo-rep
14f8ab
+TEST $GEOREP_CLI $master $slave stop
14f8ab
+
14f8ab
+#Delete Geo-rep
14f8ab
+TEST $GEOREP_CLI $master $slave delete
14f8ab
+
14f8ab
+#Cleanup authorized keys
14f8ab
+sed -i '/^command=.*SSH_ORIGINAL_COMMAND#.*/d' ~/.ssh/authorized_keys
14f8ab
+sed -i '/^command=.*gsyncd.*/d' ~/.ssh/authorized_keys
14f8ab
+
14f8ab
+cleanup;
14f8ab
+#G_TESTDEF_TEST_STATUS_NETBSD7=BAD_TEST,BUG=000000
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab