21ab4e
From 0b0c306cbcabee7539af2dbafde2d5af3da037d4 Mon Sep 17 00:00:00 2001
21ab4e
From: Jiffin Tony Thottan <jthottan@redhat.com>
21ab4e
Date: Wed, 19 Apr 2017 16:12:10 +0530
21ab4e
Subject: [PATCH 399/406] ganesha : allow refresh-config and volume
21ab4e
 export/unexport in failover state
21ab4e
21ab4e
If ganesha is not running on one of nodes in HA cluster, then all dbus
21ab4e
commands send to that ganesha server will fail. This results in both
21ab4e
refresh-config and volume export/unepxort failure. This change will
21ab4e
gracefully handle those scenarios.
21ab4e
21ab4e
Upstream reference :
21ab4e
>Change-Id: I3f1b7b7ca98e54c273c266e56357d8e24dd1b14b
21ab4e
>BUG: 1443490 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
21ab4e
>Reviewed-on: https://review.gluster.org/17081
21ab4e
>Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
>Reviewed-by: soumya k <skoduri@redhat.com>
21ab4e
>Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
21ab4e
21ab4e
Change-Id: I3f1b7b7ca98e54c273c266e56357d8e24dd1b14b
21ab4e
BUG: 1419816
21ab4e
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/104142
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 extras/ganesha/scripts/ganesha-ha.sh          |  6 ++----
21ab4e
 xlators/mgmt/glusterd/src/glusterd-ganesha.c  | 25 +++++++++++++++++--------
21ab4e
 xlators/mgmt/glusterd/src/glusterd-messages.h |  8 ++++++++
21ab4e
 3 files changed, 27 insertions(+), 12 deletions(-)
21ab4e
21ab4e
diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh
21ab4e
index c145805..0a15f1f 100644
21ab4e
--- a/extras/ganesha/scripts/ganesha-ha.sh
21ab4e
+++ b/extras/ganesha/scripts/ganesha-ha.sh
21ab4e
@@ -267,8 +267,7 @@ string:\"EXPORT(Export_Id=$export_id)\" 2>&1")
21ab4e
                 ret=$?
21ab4e
                 logger <<< "${output}"
21ab4e
                 if [ ${ret} -ne 0 ]; then
21ab4e
-                        echo "Error: refresh-config failed on ${current_host}."
21ab4e
-                        exit 1
21ab4e
+                        echo "Refresh-config failed on ${current_host}"
21ab4e
                 else
21ab4e
                         echo "Refresh-config completed on ${current_host}."
21ab4e
                 fi
21ab4e
@@ -289,8 +288,7 @@ string:"EXPORT(Export_Id=$export_id)" 2>&1)
21ab4e
         ret=$?
21ab4e
         logger <<< "${output}"
21ab4e
         if [ ${ret} -ne 0 ] ; then
21ab4e
-                echo "Error: refresh-config failed on localhost."
21ab4e
-                exit 1
21ab4e
+                echo "Refresh-config failed on localhost."
21ab4e
         else
21ab4e
                 echo "Success: refresh-config completed."
21ab4e
         fi
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
21ab4e
index 4a76e7e..79f8c6d 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
21ab4e
@@ -579,14 +579,23 @@ ganesha_manage_export (dict_t *dict, char *value, char **op_errstr)
21ab4e
         }
21ab4e
 
21ab4e
         if (check_host_list()) {
21ab4e
-                runner_add_args (&runner, "sh", GANESHA_PREFIX"/dbus-send.sh",
21ab4e
-                         CONFDIR, value, volname, NULL);
21ab4e
-                ret = runner_run (&runner);
21ab4e
-                if (ret) {
21ab4e
-                        gf_asprintf(op_errstr, "Dynamic export"
21ab4e
-                                    " addition/deletion failed."
21ab4e
-                                    " Please see log file for details");
21ab4e
-                        goto out;
21ab4e
+                /* Check whether ganesha is running on this node */
21ab4e
+                if (manage_service ("status")) {
21ab4e
+                        gf_msg (this->name, GF_LOG_WARNING, 0,
21ab4e
+                                GD_MSG_GANESHA_NOT_RUNNING,
21ab4e
+                                "Export failed, NFS-Ganesha is not running");
21ab4e
+                } else {
21ab4e
+                        runner_add_args (&runner,
21ab4e
+                                         GANESHA_PREFIX"/dbus-send.sh",
21ab4e
+                                         CONFDIR, value, volname, NULL);
21ab4e
+                        ret = runner_run (&runner);
21ab4e
+                        if (ret) {
21ab4e
+                                gf_asprintf(op_errstr, "Dynamic export"
21ab4e
+                                            " addition/deletion failed."
21ab4e
+                                        " Please see log file for details");
21ab4e
+                                goto out;
21ab4e
+                        }
21ab4e
+
21ab4e
                 }
21ab4e
         }
21ab4e
 
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h
21ab4e
index 4728810..a093d33 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-messages.h
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-messages.h
21ab4e
@@ -4792,6 +4792,14 @@
21ab4e
 
21ab4e
 /*------------*/
21ab4e
 
21ab4e
+#define GD_MSG_GANESHA_NOT_RUNNING                 (GLUSTERD_COMP_BASE + 599)
21ab4e
+/*!
21ab4e
+ * @messageid
21ab4e
+ * @diagnosis
21ab4e
+ * @recommendedaction
21ab4e
+ *
21ab4e
+ */
21ab4e
+
21ab4e
 #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
21ab4e
 #endif /* !_GLUSTERD_MESSAGES_H_ */
21ab4e
 
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e