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