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