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