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