a3470f
From 17b75c3bf216c53b4303a9c59adaf89d3da328ea Mon Sep 17 00:00:00 2001
a3470f
From: Jiffin Tony Thottan <jthottan@redhat.com>
a3470f
Date: Wed, 19 Apr 2017 16:12:10 +0530
a3470f
Subject: [PATCH 57/74] ganesha : allow refresh-config and volume
a3470f
 export/unexport in failover state
a3470f
a3470f
If ganesha is not running on one of nodes in HA cluster, then alli dbus
a3470f
commands send to that ganesha server will fail. This results in both
a3470f
refresh-config and volume export/unepxort failure. This change will
a3470f
gracefully handle those scenarios.
a3470f
a3470f
Change-Id: I3f1b7b7ca98e54c273c266e56357d8e24dd1b14b
a3470f
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
a3470f
Reviewed-on: https://review.gluster.org/17081
a3470f
Smoke: Gluster Build System <jenkins@build.gluster.org>
a3470f
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
a3470f
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
a3470f
Reviewed-by: soumya k <skoduri@redhat.com>
a3470f
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
a3470f
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
a3470f
---
a3470f
 extras/ganesha/scripts/ganesha-ha.sh          |  6 ++----
a3470f
 xlators/mgmt/glusterd/src/glusterd-ganesha.c  | 25 ++++++++++++++++---------
a3470f
 xlators/mgmt/glusterd/src/glusterd-messages.h | 10 +++++++++-
a3470f
 3 files changed, 27 insertions(+), 14 deletions(-)
a3470f
a3470f
diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh
a3470f
index df4f0b8..db2fa54 100644
a3470f
--- a/extras/ganesha/scripts/ganesha-ha.sh
a3470f
+++ b/extras/ganesha/scripts/ganesha-ha.sh
a3470f
@@ -275,8 +275,7 @@ string:\"EXPORT(Export_Id=$export_id)\" 2>&1")
a3470f
                 ret=$?
a3470f
                 logger <<< "${output}"
a3470f
                 if [ ${ret} -ne 0 ]; then
a3470f
-                        echo "Error: refresh-config failed on ${current_host}."
a3470f
-                        exit 1
a3470f
+                        echo "Refresh-config failed on ${current_host}"
a3470f
                 else
a3470f
                         echo "Refresh-config completed on ${current_host}."
a3470f
                 fi
a3470f
@@ -297,8 +296,7 @@ string:"EXPORT(Export_Id=$export_id)" 2>&1)
a3470f
         ret=$?
a3470f
         logger <<< "${output}"
a3470f
         if [ ${ret} -ne 0 ] ; then
a3470f
-                echo "Error: refresh-config failed on localhost."
a3470f
-                exit 1
a3470f
+                echo "Refresh-config failed on localhost."
a3470f
         else
a3470f
                 echo "Success: refresh-config completed."
a3470f
         fi
a3470f
diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
a3470f
index 5c582cd..38fa378 100644
a3470f
--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c
a3470f
+++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
a3470f
@@ -554,15 +554,22 @@ ganesha_manage_export (dict_t *dict, char *value, char **op_errstr)
a3470f
         }
a3470f
 
a3470f
         if (check_host_list()) {
a3470f
-                runner_add_args (&runner,
a3470f
-                                 GANESHA_PREFIX"/dbus-send.sh",
a3470f
-                                 CONFDIR, value, volname, NULL);
a3470f
-                ret = runner_run (&runner);
a3470f
-                if (ret) {
a3470f
-                        gf_asprintf(op_errstr, "Dynamic export"
a3470f
-                                    " addition/deletion failed."
a3470f
-                                    " Please see log file for details");
a3470f
-                        goto out;
a3470f
+                /* Check whether ganesha is running on this node */
a3470f
+                if (manage_service ("status")) {
a3470f
+                        gf_msg (this->name, GF_LOG_WARNING, 0,
a3470f
+                                GD_MSG_GANESHA_NOT_RUNNING,
a3470f
+                                "Export failed, NFS-Ganesha is not running");
a3470f
+                } else {
a3470f
+                        runner_add_args (&runner,
a3470f
+                                         GANESHA_PREFIX"/dbus-send.sh",
a3470f
+                                         CONFDIR, value, volname, NULL);
a3470f
+                        ret = runner_run (&runner);
a3470f
+                        if (ret) {
a3470f
+                                gf_asprintf(op_errstr, "Dynamic export"
a3470f
+                                            " addition/deletion failed."
a3470f
+                                        " Please see log file for details");
a3470f
+                                goto out;
a3470f
+                        }
a3470f
                 }
a3470f
         }
a3470f
 
a3470f
diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h
a3470f
index cc7f371..fb2079f 100644
a3470f
--- a/xlators/mgmt/glusterd/src/glusterd-messages.h
a3470f
+++ b/xlators/mgmt/glusterd/src/glusterd-messages.h
a3470f
@@ -41,7 +41,7 @@
a3470f
 
a3470f
 #define GLUSTERD_COMP_BASE      GLFS_MSGID_GLUSTERD
a3470f
 
a3470f
-#define GLFS_NUM_MESSAGES       612
a3470f
+#define GLFS_NUM_MESSAGES       613
a3470f
 
a3470f
 #define GLFS_MSGID_END          (GLUSTERD_COMP_BASE + GLFS_NUM_MESSAGES + 1)
a3470f
 /* Messaged with message IDs */
a3470f
@@ -4961,6 +4961,14 @@
a3470f
  */
a3470f
 #define GD_MSG_PORTS_EXHAUSTED (GLUSTERD_COMP_BASE + 612)
a3470f
 
a3470f
+#define GD_MSG_GANESHA_NOT_RUNNING                  (GLUSTERD_COMP_BASE + 613)
a3470f
+/*!
a3470f
+ * @messageid
a3470f
+ * @diagnosis
a3470f
+ * @recommendedaction
a3470f
+ *
a3470f
+ */
a3470f
+
a3470f
 /*------------*/
a3470f
 
a3470f
 #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
a3470f
-- 
a3470f
1.8.3.1
a3470f