Blob Blame History Raw
From 17b75c3bf216c53b4303a9c59adaf89d3da328ea Mon Sep 17 00:00:00 2001
From: Jiffin Tony Thottan <jthottan@redhat.com>
Date: Wed, 19 Apr 2017 16:12:10 +0530
Subject: [PATCH 57/74] ganesha : allow refresh-config and volume
 export/unexport in failover state

If ganesha is not running on one of nodes in HA cluster, then alli dbus
commands send to that ganesha server will fail. This results in both
refresh-config and volume export/unepxort failure. This change will
gracefully handle those scenarios.

Change-Id: I3f1b7b7ca98e54c273c266e56357d8e24dd1b14b
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
Reviewed-on: https://review.gluster.org/17081
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: soumya k <skoduri@redhat.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
---
 extras/ganesha/scripts/ganesha-ha.sh          |  6 ++----
 xlators/mgmt/glusterd/src/glusterd-ganesha.c  | 25 ++++++++++++++++---------
 xlators/mgmt/glusterd/src/glusterd-messages.h | 10 +++++++++-
 3 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh
index df4f0b8..db2fa54 100644
--- a/extras/ganesha/scripts/ganesha-ha.sh
+++ b/extras/ganesha/scripts/ganesha-ha.sh
@@ -275,8 +275,7 @@ string:\"EXPORT(Export_Id=$export_id)\" 2>&1")
                 ret=$?
                 logger <<< "${output}"
                 if [ ${ret} -ne 0 ]; then
-                        echo "Error: refresh-config failed on ${current_host}."
-                        exit 1
+                        echo "Refresh-config failed on ${current_host}"
                 else
                         echo "Refresh-config completed on ${current_host}."
                 fi
@@ -297,8 +296,7 @@ string:"EXPORT(Export_Id=$export_id)" 2>&1)
         ret=$?
         logger <<< "${output}"
         if [ ${ret} -ne 0 ] ; then
-                echo "Error: refresh-config failed on localhost."
-                exit 1
+                echo "Refresh-config failed on localhost."
         else
                 echo "Success: refresh-config completed."
         fi
diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
index 5c582cd..38fa378 100644
--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c
+++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
@@ -554,15 +554,22 @@ ganesha_manage_export (dict_t *dict, char *value, char **op_errstr)
         }
 
         if (check_host_list()) {
-                runner_add_args (&runner,
-                                 GANESHA_PREFIX"/dbus-send.sh",
-                                 CONFDIR, value, volname, NULL);
-                ret = runner_run (&runner);
-                if (ret) {
-                        gf_asprintf(op_errstr, "Dynamic export"
-                                    " addition/deletion failed."
-                                    " Please see log file for details");
-                        goto out;
+                /* Check whether ganesha is running on this node */
+                if (manage_service ("status")) {
+                        gf_msg (this->name, GF_LOG_WARNING, 0,
+                                GD_MSG_GANESHA_NOT_RUNNING,
+                                "Export failed, NFS-Ganesha is not running");
+                } else {
+                        runner_add_args (&runner,
+                                         GANESHA_PREFIX"/dbus-send.sh",
+                                         CONFDIR, value, volname, NULL);
+                        ret = runner_run (&runner);
+                        if (ret) {
+                                gf_asprintf(op_errstr, "Dynamic export"
+                                            " addition/deletion failed."
+                                        " Please see log file for details");
+                                goto out;
+                        }
                 }
         }
 
diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h
index cc7f371..fb2079f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-messages.h
+++ b/xlators/mgmt/glusterd/src/glusterd-messages.h
@@ -41,7 +41,7 @@
 
 #define GLUSTERD_COMP_BASE      GLFS_MSGID_GLUSTERD
 
-#define GLFS_NUM_MESSAGES       612
+#define GLFS_NUM_MESSAGES       613
 
 #define GLFS_MSGID_END          (GLUSTERD_COMP_BASE + GLFS_NUM_MESSAGES + 1)
 /* Messaged with message IDs */
@@ -4961,6 +4961,14 @@
  */
 #define GD_MSG_PORTS_EXHAUSTED (GLUSTERD_COMP_BASE + 612)
 
+#define GD_MSG_GANESHA_NOT_RUNNING                  (GLUSTERD_COMP_BASE + 613)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
 /*------------*/
 
 #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
-- 
1.8.3.1