From c5a19652c80162e670d29a7bd8c910d0acdfacb9 Mon Sep 17 00:00:00 2001 From: Atin Mukherjee Date: Wed, 1 Jul 2015 14:47:48 +0530 Subject: glusterd: initialize the daemon services on demand Backport of http://review.gluster.org/#/c/11488/ As of now all the daemon services are initialized at glusterD init path. Since socket file path of per node daemon demands the uuid of the node, MY_UUID macro is invoked as part of the initialization. The above flow breaks the usecases where a gluster image is built following a template could be Dockerfile, Vagrantfile or any kind of virtualization environment. This means bringing instances of this image would have same UUIDs for the node resulting in peer probe failure. Solution is to lazily initialize the services on demand. Change-Id: If7caa533026c83e98c7c7678bded67085d0bbc1e BUG: 1247012 Signed-off-by: Atin Mukherjee Reviewed-on: http://review.gluster.org/11488 Tested-by: Gluster Build System Tested-by: NetBSD Build System Reviewed-by: Gaurav Kumar Garg Reviewed-by: Kaushal M Reviewed-on: http://review.gluster.org/11766 --- xlators/mgmt/glusterd/src/glusterd-bitd-svc.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-bitd-svc.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c b/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c index 1b71b6ca7a5..6b606f874b5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c +++ b/xlators/mgmt/glusterd/src/glusterd-bitd-svc.c @@ -15,13 +15,18 @@ #include "glusterd-volgen.h" #include "glusterd-bitd-svc.h" +void +glusterd_bitdsvc_build (glusterd_svc_t *svc) +{ + svc->manager = glusterd_bitdsvc_manager; + svc->start = glusterd_bitdsvc_start; + svc->stop = glusterd_bitdsvc_stop; +} + int glusterd_bitdsvc_init (glusterd_svc_t *svc) { - return glusterd_svc_init (svc, bitd_svc_name, - glusterd_bitdsvc_manager, - glusterd_bitdsvc_start, - glusterd_bitdsvc_stop); + return glusterd_svc_init (svc, bitd_svc_name); } static int @@ -65,6 +70,20 @@ glusterd_bitdsvc_manager (glusterd_svc_t *svc, void *data, int flags) this = THIS; GF_ASSERT (this); + if (!svc->inited) { + ret = glusterd_bitdsvc_init (svc); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_BITD_INIT_FAIL, "Failed to init " + "bitd service"); + goto out; + } else { + svc->inited = _gf_true; + gf_msg_debug (this->name, 0, "BitD service " + "initialized"); + } + } + if (glusterd_should_i_stop_bitd ()) { ret = svc->stop (svc, SIGTERM); } else { -- cgit