|
|
7f4c2a |
From 0568fbdb19131f571e3ee61d7e275281cbc40dfd Mon Sep 17 00:00:00 2001
|
|
|
7f4c2a |
From: Gaurav Kumar Garg <ggarg@redhat.com>
|
|
|
7f4c2a |
Date: Tue, 25 Aug 2015 11:15:56 +0530
|
|
|
7f4c2a |
Subject: [PATCH 299/304] glusterd: stop all the daemons services on peer detach
|
|
|
7f4c2a |
|
|
|
7f4c2a |
This patch is backport of: http://review.gluster.org/#/c/11509/
|
|
|
7f4c2a |
|
|
|
7f4c2a |
Currently glusterd is not stopping all the deamon service on peer detach
|
|
|
7f4c2a |
|
|
|
7f4c2a |
With this fix it will do peer detach cleanup properlly and will stop all
|
|
|
7f4c2a |
the daemon which was running before peer detach on the node.
|
|
|
7f4c2a |
|
|
|
7f4c2a |
>>Change-Id: Ifed403ed09187e84f2a60bf63135156ad1f15775
|
|
|
7f4c2a |
>>BUG: 1255386
|
|
|
7f4c2a |
>>Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com>
|
|
|
7f4c2a |
|
|
|
7f4c2a |
Change-Id: I632e61e4cb6b7cbfcb626ab2217b55071ed690ca
|
|
|
7f4c2a |
BUG: 1238070
|
|
|
7f4c2a |
Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com>
|
|
|
7f4c2a |
Reviewed-on: https://code.engineering.redhat.com/gerrit/56148
|
|
|
7f4c2a |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
7f4c2a |
Tested-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
7f4c2a |
---
|
|
|
7f4c2a |
.../bug-1238706-daemons-stop-on-peer-cleanup.t | 41 ++++++++++++++++++++
|
|
|
7f4c2a |
tests/volume.rc | 16 ++++----
|
|
|
7f4c2a |
xlators/mgmt/glusterd/src/glusterd-messages.h | 16 ++++++++
|
|
|
7f4c2a |
xlators/mgmt/glusterd/src/glusterd-sm.c | 40 ++++++++++++-------
|
|
|
7f4c2a |
4 files changed, 90 insertions(+), 23 deletions(-)
|
|
|
7f4c2a |
create mode 100644 tests/bugs/glusterd/bug-1238706-daemons-stop-on-peer-cleanup.t
|
|
|
7f4c2a |
|
|
|
7f4c2a |
diff --git a/tests/bugs/glusterd/bug-1238706-daemons-stop-on-peer-cleanup.t b/tests/bugs/glusterd/bug-1238706-daemons-stop-on-peer-cleanup.t
|
|
|
7f4c2a |
new file mode 100644
|
|
|
7f4c2a |
index 0000000..9ff1758
|
|
|
7f4c2a |
--- /dev/null
|
|
|
7f4c2a |
+++ b/tests/bugs/glusterd/bug-1238706-daemons-stop-on-peer-cleanup.t
|
|
|
7f4c2a |
@@ -0,0 +1,41 @@
|
|
|
7f4c2a |
+#!/bin/bash
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+## Test case for stopping all running daemons service on peer detach.
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+. $(dirname $0)/../../include.rc
|
|
|
7f4c2a |
+. $(dirname $0)/../../volume.rc
|
|
|
7f4c2a |
+. $(dirname $0)/../../cluster.rc
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+cleanup;
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+## Start a 2 node virtual cluster
|
|
|
7f4c2a |
+TEST launch_cluster 2;
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+## Peer probe server 2 from server 1 cli
|
|
|
7f4c2a |
+TEST $CLI_1 peer probe $H2;
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+## Creating and starting volume
|
|
|
7f4c2a |
+TEST $CLI_1 volume create $V0 $H1:$B1/${V0}0 $H1:$B1/${V0}1
|
|
|
7f4c2a |
+TEST $CLI_1 volume start $V0
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+## To Do: Add test case for quota and snapshot daemon. Currently quota
|
|
|
7f4c2a |
+## Daemon is not working in cluster framework. And sanpd daemon
|
|
|
7f4c2a |
+## Start only in one node in cluster framework. Add test case
|
|
|
7f4c2a |
+## once patch http://review.gluster.org/#/c/11666/ merged,
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+## We are having 2 node "nfs" daemon should run on both node.
|
|
|
7f4c2a |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "2" get_nfs_count
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+## Detach 2nd node from the cluster.
|
|
|
7f4c2a |
+TEST $CLI_1 peer detach $H2;
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+## After detaching 2nd node we will have only 1 nfs and quota daemon running.
|
|
|
7f4c2a |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_nfs_count
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+cleanup;
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
diff --git a/tests/volume.rc b/tests/volume.rc
|
|
|
7f4c2a |
index aeffa4a..d90dda7 100644
|
|
|
7f4c2a |
--- a/tests/volume.rc
|
|
|
7f4c2a |
+++ b/tests/volume.rc
|
|
|
7f4c2a |
@@ -547,6 +547,14 @@ function get_quotad_count {
|
|
|
7f4c2a |
ps auxww | grep glusterfs | grep quotad.pid | grep -v grep | wc -l
|
|
|
7f4c2a |
}
|
|
|
7f4c2a |
|
|
|
7f4c2a |
+function get_nfs_count {
|
|
|
7f4c2a |
+ ps auxww | grep glusterfs | grep nfs.pid | grep -v grep | wc -l
|
|
|
7f4c2a |
+}
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+function get_snapd_count {
|
|
|
7f4c2a |
+ ps auxww | grep glusterfs | grep snapd.pid | grep -v grep | wc -l
|
|
|
7f4c2a |
+}
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
function quota_list_field () {
|
|
|
7f4c2a |
local QUOTA_PATH=$1
|
|
|
7f4c2a |
local FIELD=$2
|
|
|
7f4c2a |
@@ -565,11 +573,3 @@ function quota_usage()
|
|
|
7f4c2a |
{
|
|
|
7f4c2a |
quota_list_field $1 4
|
|
|
7f4c2a |
}
|
|
|
7f4c2a |
-
|
|
|
7f4c2a |
-function get_nfs_count {
|
|
|
7f4c2a |
- ps auxww | grep glusterfs | grep nfs.pid | grep -v grep | wc -l
|
|
|
7f4c2a |
-}
|
|
|
7f4c2a |
-
|
|
|
7f4c2a |
-function get_snapd_count {
|
|
|
7f4c2a |
- ps auxww | grep glusterfs | grep snapd.pid | grep -v grep | wc -l
|
|
|
7f4c2a |
-}
|
|
|
7f4c2a |
diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h
|
|
|
7f4c2a |
index addd3e2..d678372 100644
|
|
|
7f4c2a |
--- a/xlators/mgmt/glusterd/src/glusterd-messages.h
|
|
|
7f4c2a |
+++ b/xlators/mgmt/glusterd/src/glusterd-messages.h
|
|
|
7f4c2a |
@@ -4594,6 +4594,22 @@
|
|
|
7f4c2a |
*/
|
|
|
7f4c2a |
#define GD_MSG_SVC_STOP_SUCCESS (GLUSTERD_COMP_BASE + 568)
|
|
|
7f4c2a |
|
|
|
7f4c2a |
+/*!
|
|
|
7f4c2a |
+ * @messageid
|
|
|
7f4c2a |
+ * @diagnosis
|
|
|
7f4c2a |
+ * @recommendedaction
|
|
|
7f4c2a |
+ *
|
|
|
7f4c2a |
+ */
|
|
|
7f4c2a |
+#define GD_MSG_PARAM_NULL (GLUSTERD_COMP_BASE + 569)
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+/*!
|
|
|
7f4c2a |
+ * @messageid
|
|
|
7f4c2a |
+ * @diagnosis
|
|
|
7f4c2a |
+ * @recommendedaction
|
|
|
7f4c2a |
+ *
|
|
|
7f4c2a |
+ */
|
|
|
7f4c2a |
+#define GD_MSG_SVC_STOP_FAIL (GLUSTERD_COMP_BASE + 570)
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
/*------------*/
|
|
|
7f4c2a |
#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
|
|
|
7f4c2a |
#endif /* !_GLUSTERD_MESSAGES_H_ */
|
|
|
7f4c2a |
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c
|
|
|
7f4c2a |
index e8e9b3a..8e91cef 100644
|
|
|
7f4c2a |
--- a/xlators/mgmt/glusterd/src/glusterd-sm.c
|
|
|
7f4c2a |
+++ b/xlators/mgmt/glusterd/src/glusterd-sm.c
|
|
|
7f4c2a |
@@ -35,6 +35,7 @@
|
|
|
7f4c2a |
#include "glusterd-op-sm.h"
|
|
|
7f4c2a |
#include "glusterd-utils.h"
|
|
|
7f4c2a |
#include "glusterd-store.h"
|
|
|
7f4c2a |
+#include "glusterd-svc-helper.h"
|
|
|
7f4c2a |
#include "glusterd-snapshot-utils.h"
|
|
|
7f4c2a |
#include "glusterd-server-quorum.h"
|
|
|
7f4c2a |
|
|
|
7f4c2a |
@@ -600,17 +601,29 @@ out:
|
|
|
7f4c2a |
/* Clean up stale volumes on the peer being detached. The volumes which have
|
|
|
7f4c2a |
* bricks on other peers are stale with respect to the detached peer.
|
|
|
7f4c2a |
*/
|
|
|
7f4c2a |
-static int
|
|
|
7f4c2a |
+static void
|
|
|
7f4c2a |
glusterd_peer_detach_cleanup (glusterd_conf_t *priv)
|
|
|
7f4c2a |
{
|
|
|
7f4c2a |
- int ret = -1;
|
|
|
7f4c2a |
- glusterd_volinfo_t *volinfo = NULL;
|
|
|
7f4c2a |
+ int ret = -1;
|
|
|
7f4c2a |
+ glusterd_volinfo_t *volinfo = NULL;
|
|
|
7f4c2a |
glusterd_volinfo_t *tmp_volinfo = NULL;
|
|
|
7f4c2a |
+ glusterd_svc_t *svc = NULL;
|
|
|
7f4c2a |
|
|
|
7f4c2a |
GF_ASSERT (priv);
|
|
|
7f4c2a |
|
|
|
7f4c2a |
cds_list_for_each_entry_safe (volinfo, tmp_volinfo, &priv->volumes,
|
|
|
7f4c2a |
vol_list) {
|
|
|
7f4c2a |
+ /* Stop snapd daemon service if snapd daemon is running*/
|
|
|
7f4c2a |
+ if (!volinfo->is_snap_volume) {
|
|
|
7f4c2a |
+ svc = &(volinfo->snapd.svc);
|
|
|
7f4c2a |
+ ret = svc->stop (svc, SIGTERM);
|
|
|
7f4c2a |
+ if (ret) {
|
|
|
7f4c2a |
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
|
|
|
7f4c2a |
+ GD_MSG_SVC_STOP_FAIL, "Failed to "
|
|
|
7f4c2a |
+ "stop snapd daemon service.");
|
|
|
7f4c2a |
+ }
|
|
|
7f4c2a |
+ }
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
/* The peer detach checks make sure that, at this point in the
|
|
|
7f4c2a |
* detach process, there are only volumes contained completely
|
|
|
7f4c2a |
* within or completely outside the detached peer.
|
|
|
7f4c2a |
@@ -627,14 +640,17 @@ glusterd_peer_detach_cleanup (glusterd_conf_t *priv)
|
|
|
7f4c2a |
gf_msg (THIS->name, GF_LOG_ERROR, 0,
|
|
|
7f4c2a |
GD_MSG_STALE_VOL_REMOVE_FAIL,
|
|
|
7f4c2a |
"Error deleting stale volume");
|
|
|
7f4c2a |
- goto out;
|
|
|
7f4c2a |
}
|
|
|
7f4c2a |
}
|
|
|
7f4c2a |
}
|
|
|
7f4c2a |
- ret = 0;
|
|
|
7f4c2a |
-out:
|
|
|
7f4c2a |
- gf_msg_debug (THIS->name, 0, "Returning %d", ret);
|
|
|
7f4c2a |
- return ret;
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+ /* Stop all daemon services of Detaching node once peer detached */
|
|
|
7f4c2a |
+ ret = glusterd_svcs_stop ();
|
|
|
7f4c2a |
+ if (ret) {
|
|
|
7f4c2a |
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
|
|
|
7f4c2a |
+ GD_MSG_SVC_STOP_FAIL,
|
|
|
7f4c2a |
+ "Failed to stop all daemon services.");
|
|
|
7f4c2a |
+ }
|
|
|
7f4c2a |
}
|
|
|
7f4c2a |
|
|
|
7f4c2a |
static int
|
|
|
7f4c2a |
@@ -679,13 +695,7 @@ glusterd_ac_handle_friend_remove_req (glusterd_friend_sm_event_t *event,
|
|
|
7f4c2a |
}
|
|
|
7f4c2a |
rcu_read_unlock ();
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- ret = glusterd_peer_detach_cleanup (priv);
|
|
|
7f4c2a |
- if (ret) {
|
|
|
7f4c2a |
- gf_msg (THIS->name, GF_LOG_WARNING, 0,
|
|
|
7f4c2a |
- GD_MSG_PEER_DETACH_CLEANUP_FAIL,
|
|
|
7f4c2a |
- "Peer detach cleanup was not successful");
|
|
|
7f4c2a |
- ret = 0;
|
|
|
7f4c2a |
- }
|
|
|
7f4c2a |
+ glusterd_peer_detach_cleanup (priv);
|
|
|
7f4c2a |
out:
|
|
|
7f4c2a |
if (new_event)
|
|
|
7f4c2a |
GF_FREE (new_event->peername);
|
|
|
7f4c2a |
--
|
|
|
7f4c2a |
1.7.1
|
|
|
7f4c2a |
|