a3470f
From b69a36e8c61a0e1d45b3def6436d223bd14e76ef Mon Sep 17 00:00:00 2001
a3470f
From: Sunny Kumar <sunkumar@redhat.com>
a3470f
Date: Tue, 28 Nov 2017 13:37:43 +0530
a3470f
Subject: [PATCH 098/128] snapshot : snapshot creation failed after brick
a3470f
 reset/replace
a3470f
a3470f
Problem : snapshot creation was failing after brick reset/replace
a3470f
a3470f
Fix : changed code to set mount_dir value in rsp_dict during prerequisites
a3470f
      phase i.e glusterd_brick_op_prerequisites call and removed form prevalidate
a3470f
      phase.
a3470f
Upstream patch : https://review.gluster.org/c/18730/
a3470f
a3470f
>Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
a3470f
>BUG: 1512451
a3470f
a3470f
BUG: 1507394
a3470f
Change-Id: Ief5d0fafe882a7eb1a7da8535b7c7ce6f011604c
a3470f
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/124467
a3470f
Tested-by: RHGS Build Bot <nigelb@redhat.com>
a3470f
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
a3470f
---
a3470f
 ...51-snapshot-creation-failed-after-brick-reset.t | 39 ++++++++++++++++++++++
a3470f
 xlators/mgmt/glusterd/src/glusterd-replace-brick.c |  8 -----
a3470f
 xlators/mgmt/glusterd/src/glusterd-reset-brick.c   | 10 ------
a3470f
 xlators/mgmt/glusterd/src/glusterd-utils.c         |  9 +++++
a3470f
 4 files changed, 48 insertions(+), 18 deletions(-)
a3470f
 create mode 100644 tests/bugs/snapshot/bug-1512451-snapshot-creation-failed-after-brick-reset.t
a3470f
a3470f
diff --git a/tests/bugs/snapshot/bug-1512451-snapshot-creation-failed-after-brick-reset.t b/tests/bugs/snapshot/bug-1512451-snapshot-creation-failed-after-brick-reset.t
a3470f
new file mode 100644
a3470f
index 0000000..0624a5d
a3470f
--- /dev/null
a3470f
+++ b/tests/bugs/snapshot/bug-1512451-snapshot-creation-failed-after-brick-reset.t
a3470f
@@ -0,0 +1,39 @@
a3470f
+#!/bin/bash
a3470f
+
a3470f
+. $(dirname $0)/../../include.rc
a3470f
+. $(dirname $0)/../../cluster.rc
a3470f
+. $(dirname $0)/../../volume.rc
a3470f
+. $(dirname $0)/../../snapshot.rc
a3470f
+
a3470f
+cleanup;
a3470f
+TEST verify_lvm_version
a3470f
+TEST launch_cluster 2
a3470f
+TEST setup_lvm 2
a3470f
+
a3470f
+TEST $CLI_1 peer probe $H2
a3470f
+EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count
a3470f
+
a3470f
+TEST $CLI_1 volume create $V0 $H1:$L1/B1 $H2:$L2/B1
a3470f
+EXPECT 'Created' volinfo_field $V0 'Status'
a3470f
+
a3470f
+TEST $CLI_1 volume start $V0
a3470f
+EXPECT 'Started' volinfo_field $V0 'Status'
a3470f
+
a3470f
+TEST $CLI_1 snapshot create ${V0}_snap1 ${V0} no-timestamp
a3470f
+TEST snapshot_exists 1 ${V0}_snap1
a3470f
+
a3470f
+TEST $CLI_1 snapshot delete ${V0}_snap1
a3470f
+TEST ! snapshot_exists 1 ${V0}_snap1
a3470f
+
a3470f
+TEST $CLI_1 volume reset-brick $V0 $H1:$L1/B1 start
a3470f
+TEST $CLI_1 volume reset-brick $V0 $H1:$L1/B1 $H1:$L1/B1 commit force
a3470f
+
a3470f
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status_1 $V0 $H1 $L1/B1
a3470f
+
a3470f
+TEST $CLI_1 snapshot create ${V0}_snap1 ${V0} no-timestamp
a3470f
+TEST snapshot_exists 1 ${V0}_snap1
a3470f
+
a3470f
+TEST $CLI_1 snapshot delete ${V0}_snap1
a3470f
+TEST ! snapshot_exists 1 ${V0}_snap1
a3470f
+
a3470f
+cleanup;
a3470f
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
a3470f
index 18fc741..0e28608 100644
a3470f
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
a3470f
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
a3470f
@@ -319,14 +319,6 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr,
a3470f
                         goto out;
a3470f
                 }
a3470f
 
a3470f
-                ret = dict_set_dynstr_with_alloc (rsp_dict, "brick1.mount_dir",
a3470f
-                                                  dst_brickinfo->mount_dir);
a3470f
-                if (ret) {
a3470f
-                        gf_msg (this->name, GF_LOG_ERROR, 0,
a3470f
-                                GD_MSG_DICT_SET_FAILED,
a3470f
-                                "Failed to set brick1.mount_dir");
a3470f
-                        goto out;
a3470f
-                }
a3470f
 
a3470f
                 ret = dict_set_int32 (rsp_dict, "brick_count", 1);
a3470f
                 if (ret) {
a3470f
diff --git a/xlators/mgmt/glusterd/src/glusterd-reset-brick.c b/xlators/mgmt/glusterd/src/glusterd-reset-brick.c
a3470f
index abb44e0..10ee6f4 100644
a3470f
--- a/xlators/mgmt/glusterd/src/glusterd-reset-brick.c
a3470f
+++ b/xlators/mgmt/glusterd/src/glusterd-reset-brick.c
a3470f
@@ -208,16 +208,6 @@ glusterd_reset_brick_prevalidate (dict_t *dict, char **op_errstr,
a3470f
                 goto out;
a3470f
         }
a3470f
 
a3470f
-        ret = dict_set_dynstr_with_alloc (rsp_dict,
a3470f
-                                  "brick1.mount_dir",
a3470f
-                                   dst_brickinfo->mount_dir);
a3470f
-        if (ret) {
a3470f
-                gf_msg (this->name, GF_LOG_ERROR, 0,
a3470f
-                        GD_MSG_DICT_SET_FAILED,
a3470f
-                        "Failed to set brick1.mount_dir");
a3470f
-                goto out;
a3470f
-        }
a3470f
-
a3470f
         ret = dict_set_int32 (rsp_dict, "brick_count", 1);
a3470f
         if (ret) {
a3470f
                 gf_msg (this->name, GF_LOG_ERROR, 0,
a3470f
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
a3470f
index f611fbb..23fc6e9 100644
a3470f
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
a3470f
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
a3470f
@@ -13648,6 +13648,15 @@ glusterd_brick_op_prerequisites (dict_t *dict,
a3470f
                                         (*src_brickinfo)->port);
a3470f
                         }
a3470f
                 }
a3470f
+                /* setting mount_dir */
a3470f
+                ret = dict_set_dynstr_with_alloc (rsp_dict, "brick1.mount_dir",
a3470f
+                                                  (*src_brickinfo)->mount_dir);
a3470f
+                if (ret) {
a3470f
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
a3470f
+                                GD_MSG_DICT_SET_FAILED,
a3470f
+                                "Failed to set brick1.mount_dir");
a3470f
+                        goto out;
a3470f
+                }
a3470f
 
a3470f
                 v = *volinfo;
a3470f
                 b = *src_brickinfo;
a3470f
-- 
a3470f
1.8.3.1
a3470f