summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAtin Mukherjee <amukherj@redhat.com>2015-04-20 17:37:21 +0530
committerKrishnan Parthasarathi <kparthas@redhat.com>2015-04-28 01:53:35 -0700
commit018a0a5b846ed903d5d2545c2c353281e1e9949d (patch)
tree1fe0f9a9b0e2e8f93ccdb73a614f3ccd1b9d1b10
parent00b02d1f18308016fa9a134bea593d3095b1157f (diff)
glusterd: initialize snapd svc at volume restore path
In restore path snapd svc was not initialized because of which any glusterd instance which went down and came back may have uninitialized snapd svc. The reason I used 'may' is because depending on the nodes in the cluster. In a single node cluster this wouldn't be a problem since glusterd_spawn_daemon takes care of initializing it. Backport of http://review.gluster.org/10304 Change-Id: I2da1e419a0506d3b2742c1cf39a3b9416eb3c305 BUG: 1215518 Signed-off-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-on: http://review.gluster.org/10304 Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System Reviewed-by: Kaushal M <kaushal@redhat.com> (cherry picked from commit 18fd2fdd60839d737ab0ac64f33a444b54bdeee4) Reviewed-on: http://review.gluster.org/10397 Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
-rw-r--r--tests/bugs/glusterd/bug-1213295-snapd-svc-uninitialized.t26
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapd-svc.c11
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c8
4 files changed, 35 insertions, 11 deletions
diff --git a/tests/bugs/glusterd/bug-1213295-snapd-svc-uninitialized.t b/tests/bugs/glusterd/bug-1213295-snapd-svc-uninitialized.t
new file mode 100644
index 00000000000..1dbfdf8697b
--- /dev/null
+++ b/tests/bugs/glusterd/bug-1213295-snapd-svc-uninitialized.t
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../cluster.rc
+
+cleanup
+
+TEST launch_cluster 2;
+TEST $CLI_1 peer probe $H2;
+EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count
+
+TEST $CLI_1 volume create $V0 $H1:$B1/$V0 $H2:$B2/$V0
+TEST $CLI_1 volume start $V0
+
+kill_glusterd 2
+TEST start_glusterd 2
+
+EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count
+
+#volume stop should not crash
+TEST $CLI_2 volume stop $V0
+
+# check whether glusterd instance is running on H2 as this is the node which
+# restored the volume configuration after a restart
+EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count
+cleanup
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c
index d1a7da7e0ae..7e63929f28e 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c
@@ -319,17 +319,6 @@ glusterd_snapdsvc_restart ()
GF_ASSERT (conf);
cds_list_for_each_entry (volinfo, &conf->volumes, vol_list) {
- /* Init per volume snapd svc */
- ret = glusterd_snapdsvc_init (volinfo);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "snapd service "
- "initialization failed for volume %s",
- volinfo->volname);
- goto out;
- }
- gf_log (this->name, GF_LOG_DEBUG, "snapd service initialized "
- "for %s", volinfo->volname);
-
/* Start per volume snapd svc */
if (volinfo->status == GLUSTERD_STATUS_STARTED &&
glusterd_is_snapd_enabled (volinfo)) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index cdd19cd354d..b344559dd0d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -6064,6 +6064,7 @@ glusterd_snapshot_clone_commit (dict_t *dict, char **op_errstr,
goto out;
}
ret = glusterd_snapdsvc_init (snap_vol);
+
glusterd_list_add_order (&snap_vol->vol_list, &priv->volumes,
glusterd_compare_volume_name);
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 0e581b198a9..3a2bb01c11f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -2947,6 +2947,14 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap)
if (snap)
volinfo->is_snap_volume = _gf_true;
+ /* Initialize the snapd service */
+ ret = glusterd_snapdsvc_init (volinfo);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to initialize snapd "
+ "service for volume %s", volinfo->volname);
+ goto out;
+ }
+
ret = glusterd_store_update_volinfo (volinfo);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Failed to update volinfo "