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