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