256ebe
From a766878e11a984680ed29f13aae713d464ec985e Mon Sep 17 00:00:00 2001
256ebe
From: Jiffin Tony Thottan <jthottan@redhat.com>
256ebe
Date: Wed, 19 Apr 2017 16:12:10 +0530
256ebe
Subject: [PATCH 061/124] ganesha : allow refresh-config and volume
256ebe
 export/unexport in failover state
256ebe
256ebe
If ganesha is not running on one of nodes in HA cluster, then alli dbus
256ebe
commands send to that ganesha server will fail. This results in both
256ebe
refresh-config and volume export/unepxort failure. This change will
256ebe
gracefully handle those scenarios.
256ebe
256ebe
Label: DOWNSTREAM ONLY
256ebe
256ebe
Change-Id: I3f1b7b7ca98e54c273c266e56357d8e24dd1b14b
256ebe
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
256ebe
Reviewed-on: https://review.gluster.org/17081
256ebe
Smoke: Gluster Build System <jenkins@build.gluster.org>
256ebe
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
256ebe
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
256ebe
Reviewed-by: soumya k <skoduri@redhat.com>
256ebe
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
256ebe
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
256ebe
Reviewed-on: https://code.engineering.redhat.com/gerrit/167146
256ebe
Reviewed-by: Soumya Koduri <skoduri@redhat.com>
256ebe
Tested-by: RHGS Build Bot <nigelb@redhat.com>
256ebe
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
256ebe
---
256ebe
 extras/ganesha/scripts/ganesha-ha.sh          |  6 ++----
256ebe
 xlators/mgmt/glusterd/src/glusterd-ganesha.c  | 24 +++++++++++++++---------
256ebe
 xlators/mgmt/glusterd/src/glusterd-messages.h |  2 +-
256ebe
 3 files changed, 18 insertions(+), 14 deletions(-)
256ebe
256ebe
diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh
256ebe
index db3f921..f040ef6 100644
256ebe
--- a/extras/ganesha/scripts/ganesha-ha.sh
256ebe
+++ b/extras/ganesha/scripts/ganesha-ha.sh
256ebe
@@ -275,8 +275,7 @@ string:\"EXPORT(Export_Id=$export_id)\" 2>&1")
256ebe
                 ret=$?
256ebe
                 logger <<< "${output}"
256ebe
                 if [ ${ret} -ne 0 ]; then
256ebe
-                        echo "Error: refresh-config failed on ${current_host}."
256ebe
-                        exit 1
256ebe
+                        echo "Refresh-config failed on ${current_host}"
256ebe
                 else
256ebe
                         echo "Refresh-config completed on ${current_host}."
256ebe
                 fi
256ebe
@@ -297,8 +296,7 @@ string:"EXPORT(Export_Id=$export_id)" 2>&1)
256ebe
         ret=$?
256ebe
         logger <<< "${output}"
256ebe
         if [ ${ret} -ne 0 ] ; then
256ebe
-                echo "Error: refresh-config failed on localhost."
256ebe
-                exit 1
256ebe
+                echo "Refresh-config failed on localhost."
256ebe
         else
256ebe
                 echo "Success: refresh-config completed."
256ebe
         fi
256ebe
diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
256ebe
index 1d17a33..ee8b588 100644
256ebe
--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c
256ebe
+++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
256ebe
@@ -540,15 +540,21 @@ ganesha_manage_export(dict_t *dict, char *value, char **op_errstr)
256ebe
     }
256ebe
 
256ebe
     if (check_host_list()) {
256ebe
-        runner_add_args(&runner, GANESHA_PREFIX "/dbus-send.sh", CONFDIR, value,
256ebe
-                        volname, NULL);
256ebe
-        ret = runner_run(&runner);
256ebe
-        if (ret) {
256ebe
-            gf_asprintf(op_errstr,
256ebe
-                        "Dynamic export"
256ebe
-                        " addition/deletion failed."
256ebe
-                        " Please see log file for details");
256ebe
-            goto out;
256ebe
+        /* Check whether ganesha is running on this node */
256ebe
+        if (manage_service("status")) {
256ebe
+            gf_msg(this->name, GF_LOG_WARNING, 0, GD_MSG_GANESHA_NOT_RUNNING,
256ebe
+                   "Export failed, NFS-Ganesha is not running");
256ebe
+        } else {
256ebe
+            runner_add_args(&runner, GANESHA_PREFIX "/dbus-send.sh", CONFDIR,
256ebe
+                            value, volname, NULL);
256ebe
+            ret = runner_run(&runner);
256ebe
+            if (ret) {
256ebe
+                gf_asprintf(op_errstr,
256ebe
+                            "Dynamic export"
256ebe
+                            " addition/deletion failed."
256ebe
+                            " Please see log file for details");
256ebe
+                goto out;
256ebe
+            }
256ebe
         }
256ebe
     }
256ebe
 
256ebe
diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h
256ebe
index 9558480..c7b3ca8 100644
256ebe
--- a/xlators/mgmt/glusterd/src/glusterd-messages.h
256ebe
+++ b/xlators/mgmt/glusterd/src/glusterd-messages.h
256ebe
@@ -298,6 +298,6 @@ GLFS_MSGID(
256ebe
     GD_MSG_LOCALTIME_LOGGING_ENABLE, GD_MSG_LOCALTIME_LOGGING_DISABLE,
256ebe
     GD_MSG_PORTS_EXHAUSTED, GD_MSG_CHANGELOG_GET_FAIL,
256ebe
     GD_MSG_MANAGER_FUNCTION_FAILED, GD_MSG_NFS_GANESHA_DISABLED,
256ebe
-    GD_MSG_DAEMON_LOG_LEVEL_VOL_OPT_VALIDATE_FAIL);
256ebe
+    GD_MSG_GANESHA_NOT_RUNNING, GD_MSG_DAEMON_LOG_LEVEL_VOL_OPT_VALIDATE_FAIL);
256ebe
 
256ebe
 #endif /* !_GLUSTERD_MESSAGES_H_ */
256ebe
-- 
256ebe
1.8.3.1
256ebe