Blob Blame History Raw
From b7316bb0de7009135b2cb570cc0ad6c7a43c5877 Mon Sep 17 00:00:00 2001
From: Kotresh HR <khiremat@redhat.com>
Date: Tue, 12 Jul 2016 00:39:31 +0530
Subject: [PATCH 196/196] glusterd: Fix gsyncd upgrade issue

Backport of http://review.gluster.org/14898 (mainline)
            http://review.gluster.org/14916 (3.8)
            http://review.gluster.org/14915 (3.7)
Problem:
    gluster upgrade is not generating new volfiles

Cause:
During upgrade, "glusterd --xlator-option *.upgrade=on -N"
is run to generate new volfiles. It is run post 'glusterfs'
rpm installation. The above command fails during upgrade
if geo-replication is installed. This is because on
glusterd start 'gsyncd' binary is called to configure
geo-replication related stuff. Since 'glusterfs' rpm is
installed prior to 'geo-rep' rpm, the 'gsyncd' binary
used to glusterd upgrade command is of old version and
hence it fails before generating new volfiles.

Solution:
Don't call geo-replication configure during upgrade/downgrade.
Geo-replication configuration happens during start of glusterd
after upgrade.

Change-Id: Id58ea44ead9f69982f86fb68dc5b9ee3f6cd11a1
BUG: 1353470
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: http://review.gluster.org/14898
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Smoke: Gluster Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-on: https://code.engineering.redhat.com/gerrit/79963
Tested-by: Atin Mukherjee <amukherj@redhat.com>
---
 xlators/mgmt/glusterd/src/glusterd-utils.c |   32 ++-------------
 xlators/mgmt/glusterd/src/glusterd-utils.h |    4 +-
 xlators/mgmt/glusterd/src/glusterd.c       |   61 +++++++++++++++++++++++++++-
 3 files changed, 66 insertions(+), 31 deletions(-)

diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 01fd446..b1f25c4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -6641,40 +6641,16 @@ glusterd_recreate_volfiles (glusterd_conf_t *conf)
 }
 
 int32_t
-glusterd_handle_upgrade_downgrade (dict_t *options, glusterd_conf_t *conf)
+glusterd_handle_upgrade_downgrade (dict_t *options, glusterd_conf_t *conf,
+                                   gf_boolean_t upgrade, gf_boolean_t downgrade)
 {
         int              ret                            = 0;
         char            *type                           = NULL;
-        gf_boolean_t     upgrade                        = _gf_false;
-        gf_boolean_t     downgrade                      = _gf_false;
         gf_boolean_t     regenerate_volfiles            = _gf_false;
         gf_boolean_t     terminate                      = _gf_false;
 
-        ret = dict_get_str (options, "upgrade", &type);
-        if (!ret) {
-                ret = gf_string2boolean (type, &upgrade);
-                if (ret) {
-                        gf_msg ("glusterd", GF_LOG_ERROR, 0,
-                                GD_MSG_STR_TO_BOOL_FAIL, "upgrade option "
-                                "%s is not a valid boolean type", type);
-                        ret = -1;
-                        goto out;
-                }
-                if (_gf_true == upgrade)
-                        regenerate_volfiles = _gf_true;
-        }
-
-        ret = dict_get_str (options, "downgrade", &type);
-        if (!ret) {
-                ret = gf_string2boolean (type, &downgrade);
-                if (ret) {
-                        gf_msg ("glusterd", GF_LOG_ERROR, 0,
-                                GD_MSG_STR_TO_BOOL_FAIL, "downgrade option "
-                                "%s is not a valid boolean type", type);
-                        ret = -1;
-                        goto out;
-                }
-        }
+        if (_gf_true == upgrade)
+                regenerate_volfiles = _gf_true;
 
         if (upgrade && downgrade) {
                 gf_msg ("glusterd", GF_LOG_ERROR, 0,
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index b508b01..80e3223 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -322,7 +322,9 @@ glusterd_get_local_brickpaths (glusterd_volinfo_t *volinfo,
 int32_t
 glusterd_recreate_bricks (glusterd_conf_t *conf);
 int32_t
-glusterd_handle_upgrade_downgrade (dict_t *options, glusterd_conf_t *conf);
+glusterd_handle_upgrade_downgrade (dict_t *options, glusterd_conf_t *conf,
+                                   gf_boolean_t upgrade,
+                                   gf_boolean_t downgrade);
 
 int
 glusterd_add_brick_detail_to_dict (glusterd_volinfo_t *volinfo,
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 08da203..2533a7f 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -1290,8 +1290,52 @@ glusterd_svcs_build ()
 
         priv->scrub_svc.build = glusterd_scrubsvc_build;
         priv->scrub_svc.build (&(priv->scrub_svc));
+}
 
+static int
+is_upgrade (dict_t *options, gf_boolean_t *upgrade)
+{
+        int              ret              = 0;
+        char            *type             = NULL;
+
+        ret = dict_get_str (options, "upgrade", &type);
+        if (!ret) {
+                ret = gf_string2boolean (type, upgrade);
+                if (ret) {
+                        gf_msg ("glusterd", GF_LOG_ERROR, 0,
+                                GD_MSG_STR_TO_BOOL_FAIL, "upgrade option "
+                                "%s is not a valid boolean type", type);
+                        ret = -1;
+                        goto out;
+                }
+        }
+        ret = 0;
+out:
+        return ret;
 }
+
+static int
+is_downgrade (dict_t *options, gf_boolean_t *downgrade)
+{
+        int              ret              = 0;
+        char            *type             = NULL;
+
+        ret = dict_get_str (options, "downgrade", &type);
+        if (!ret) {
+                ret = gf_string2boolean (type, downgrade);
+                if (ret) {
+                        gf_msg ("glusterd", GF_LOG_ERROR, 0,
+                                GD_MSG_STR_TO_BOOL_FAIL, "downgrade option "
+                                "%s is not a valid boolean type", type);
+                        ret = -1;
+                        goto out;
+                }
+        }
+        ret = 0;
+out:
+        return ret;
+}
+
 /*
  * init - called during glusterd initialization
  *
@@ -1318,6 +1362,8 @@ init (xlator_t *this)
         char              *transport_type             = NULL;
         char               var_run_dir[PATH_MAX]      = {0,};
         int32_t            workers                    = 0;
+        gf_boolean_t       upgrade                    = _gf_false;
+        gf_boolean_t       downgrade                  = _gf_false;
 
 #ifndef GF_DARWIN_HOST_OS
         {
@@ -1722,10 +1768,20 @@ init (xlator_t *this)
         if (ret)
                 goto out;
 
-        ret = configure_syncdaemon (conf);
+        ret = is_upgrade (this->options, &upgrade);
+        if (ret)
+                goto out;
+
+        ret = is_downgrade (this->options, &downgrade);
         if (ret)
                 goto out;
 
+        if (!upgrade && !downgrade) {
+                ret = configure_syncdaemon (conf);
+                if (ret)
+                        goto out;
+        }
+
         /* Restoring op-version needs to be done before initializing the
          * services as glusterd_svc_init_common () invokes
          * glusterd_conn_build_socket_filepath () which uses MY_UUID macro.
@@ -1758,7 +1814,8 @@ init (xlator_t *this)
         if (ret < 0)
                 goto out;
 
-        ret = glusterd_handle_upgrade_downgrade (this->options, conf);
+        ret = glusterd_handle_upgrade_downgrade (this->options, conf, upgrade,
+                                                 downgrade);
         if (ret)
                 goto out;
 
-- 
1.7.1