From fbfcb0ad2aac73c2b5ab8950770c1184352bbf24 Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Thu, 23 Aug 2012 15:32:33 +0530 Subject: glusterd, cli: implement gluster system uuid reset command A commonly faced problem among glusterfs users is: after a fresh installation of glusterfs in a virtual machine, the VM image is cloned to make multiple instances of the server. This breaks glusterd because right after glusterfs installation on the first boot glusterd would have created the node UUID and this gets inherited into the clone. The result is wierd behavior at the time of peer probe where glusterd does not (yet) deal with UUID collisions in a user friendly way. To handle it gluster peer reset command is implemented which upon execution changes the uuid of local glusterd. Change-Id: If207dd2ad93ab94ef1a3253f409c21c442975f87 BUG: 811493 Signed-off-by: Raghavendra Bhat Reviewed-on: http://review.gluster.org/3637 Reviewed-by: Pranith Kumar Karampuri Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/mgmt/glusterd/src/glusterd.c | 40 ++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd.c') diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c index bd9e6e031..c4629c795 100644 --- a/xlators/mgmt/glusterd/src/glusterd.c +++ b/xlators/mgmt/glusterd/src/glusterd.c @@ -43,7 +43,6 @@ #include "glusterd-mountbroker.h" -static uuid_t glusterd_uuid; extern struct rpcsvc_program gluster_handshake_prog; extern struct rpcsvc_program gluster_pmap_prog; extern glusterd_op_info_t opinfo; @@ -93,28 +92,47 @@ glusterd_uuid_init () ret = glusterd_retrieve_uuid (); if (ret == 0) { - uuid_copy (glusterd_uuid, priv->uuid); gf_log (this->name, GF_LOG_INFO, "retrieved UUID: %s", uuid_utoa (priv->uuid)); return 0; } - uuid_generate (glusterd_uuid); + ret = glusterd_uuid_generate_save (); - gf_log (this->name, GF_LOG_INFO, "generated UUID: %s", - uuid_utoa (glusterd_uuid)); + if (ret) { + gf_log ("glusterd", GF_LOG_ERROR, + "Unable to generate and save new UUID"); + return ret; + } + + return 0; +} + +int +glusterd_uuid_generate_save () +{ + int ret = -1; + glusterd_conf_t *priv = NULL; + xlator_t *this = NULL; + + this = THIS; + GF_ASSERT (this); + priv = this->private; + GF_ASSERT (priv); - uuid_copy (priv->uuid, glusterd_uuid); + uuid_generate (priv->uuid); + + gf_log (this->name, GF_LOG_INFO, "generated UUID: %s", + uuid_utoa (priv->uuid)); ret = glusterd_store_global_info (this); - if (ret) { + if (ret) gf_log (this->name, GF_LOG_ERROR, - "Unable to store generated UUID"); - return ret; - } + "Unable to store the generated uuid %s", + uuid_utoa (priv->uuid)); - return 0; + return ret; } int -- cgit