|
|
a3470f |
From a4d7f6c1999f2c7837aaa674177edca9298d1c00 Mon Sep 17 00:00:00 2001
|
|
|
a3470f |
From: "Kaleb S. KEITHLEY" <kkeithle@redhat.com>
|
|
|
a3470f |
Date: Fri, 7 Apr 2017 09:09:29 -0400
|
|
|
a3470f |
Subject: [PATCH 52/74] common-ha: fixes for Debian-based systems
|
|
|
a3470f |
|
|
|
a3470f |
1) Debian-based systems don't have /usr/libexec/... and there is
|
|
|
a3470f |
a hard-coded invocation of /usr/libexec/ganesha/ganesha-ha.sh within
|
|
|
a3470f |
ganesha-ha.sh itself.
|
|
|
a3470f |
Fix: save $0 and use it instead for further invocations of self.
|
|
|
a3470f |
|
|
|
a3470f |
2) default shell is /bin/dash (not /bin/bash). Various runner_run()
|
|
|
a3470f |
invocations for ganesha used what amounts to
|
|
|
a3470f |
exec("sh /usr/$libexec/ganesha/ganesha-ha.sh ...);
|
|
|
a3470f |
which executes the script using the default shell, but there are
|
|
|
a3470f |
some bash-specific idioms that don't work if the shell is dash.
|
|
|
a3470f |
Fix: change to exec("/usr/$libexec/ganesha/ganesha-ha.sh ...); so that
|
|
|
a3470f |
the shebang forces the use of /bin/bash
|
|
|
a3470f |
|
|
|
a3470f |
3) Fedora and RHEL7 have merged /bin/ and /usr/bin, /bin is a symlink
|
|
|
a3470f |
to /usr/bin. Debian-based systems are not merged, and systemd systems
|
|
|
a3470f |
have /bin/systemctl. The logic to find .../bin/systemctl is backwards.
|
|
|
a3470f |
If the logic looks for /usr/bin/systemctl it will not find it on
|
|
|
a3470f |
Debian-based systems; if it looks for /bin/systemctl it will find it
|
|
|
a3470f |
on Fedora and RHEL by virtue of the symlink. (RHEL6 and others will
|
|
|
a3470f |
find their respective init regardless.)
|
|
|
a3470f |
Fix: change the logic to look for /bin/systemctl instead.
|
|
|
a3470f |
|
|
|
a3470f |
4) The logic for deciding to run systemctl (or not) is a bit silly.
|
|
|
a3470f |
Fix: simply invoke the found method via the function pointer in the
|
|
|
a3470f |
table.
|
|
|
a3470f |
|
|
|
a3470f |
Change-Id: I33681b296a73aebb078bda6ac0d3a1d3b9770a21
|
|
|
a3470f |
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
|
|
|
a3470f |
Reviewed-on: https://review.gluster.org/17013
|
|
|
a3470f |
Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
a3470f |
Reviewed-by: Niels de Vos <ndevos@redhat.com>
|
|
|
a3470f |
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
a3470f |
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
a3470f |
Reviewed-by: jiffin tony Thottan <jthottan@redhat.com>
|
|
|
a3470f |
---
|
|
|
a3470f |
extras/ganesha/scripts/ganesha-ha.sh | 21 ++++++-------
|
|
|
a3470f |
xlators/mgmt/glusterd/src/glusterd-ganesha.c | 44 +++++++++++++---------------
|
|
|
a3470f |
2 files changed, 32 insertions(+), 33 deletions(-)
|
|
|
a3470f |
|
|
|
a3470f |
diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh
|
|
|
a3470f |
index e4135ba..d4844e4 100644
|
|
|
a3470f |
--- a/extras/ganesha/scripts/ganesha-ha.sh
|
|
|
a3470f |
+++ b/extras/ganesha/scripts/ganesha-ha.sh
|
|
|
a3470f |
@@ -20,6 +20,7 @@
|
|
|
a3470f |
# ensure that the NFS GRACE DBUS signal is sent after the VIP moves to
|
|
|
a3470f |
# the new host.
|
|
|
a3470f |
|
|
|
a3470f |
+GANESHA_HA_SH=$(realpath $0)
|
|
|
a3470f |
HA_NUM_SERVERS=0
|
|
|
a3470f |
HA_SERVERS=""
|
|
|
a3470f |
HA_VOL_NAME="gluster_shared_storage"
|
|
|
a3470f |
@@ -68,9 +69,9 @@ function find_rhel7_conf
|
|
|
a3470f |
done
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
-if [ -z $CONFFILE ]
|
|
|
a3470f |
+if [ -z ${CONFFILE} ]
|
|
|
a3470f |
then
|
|
|
a3470f |
- find_rhel7_conf $OPTIONS
|
|
|
a3470f |
+ find_rhel7_conf ${OPTIONS}
|
|
|
a3470f |
|
|
|
a3470f |
fi
|
|
|
a3470f |
|
|
|
a3470f |
@@ -90,9 +91,9 @@ usage() {
|
|
|
a3470f |
|
|
|
a3470f |
determine_service_manager () {
|
|
|
a3470f |
|
|
|
a3470f |
- if [ -e "/usr/bin/systemctl" ];
|
|
|
a3470f |
+ if [ -e "/bin/systemctl" ];
|
|
|
a3470f |
then
|
|
|
a3470f |
- SERVICE_MAN="/usr/bin/systemctl"
|
|
|
a3470f |
+ SERVICE_MAN="/bin/systemctl"
|
|
|
a3470f |
elif [ -e "/sbin/invoke-rc.d" ];
|
|
|
a3470f |
then
|
|
|
a3470f |
SERVICE_MAN="/sbin/invoke-rc.d"
|
|
|
a3470f |
@@ -100,7 +101,7 @@ determine_service_manager () {
|
|
|
a3470f |
then
|
|
|
a3470f |
SERVICE_MAN="/sbin/service"
|
|
|
a3470f |
fi
|
|
|
a3470f |
- if [ "$SERVICE_MAN" == "DISTRO_NOT_FOUND" ]
|
|
|
a3470f |
+ if [ "${SERVICE_MAN}" == "DISTRO_NOT_FOUND" ]
|
|
|
a3470f |
then
|
|
|
a3470f |
echo "Service manager not recognized, exiting"
|
|
|
a3470f |
exit 1
|
|
|
a3470f |
@@ -113,21 +114,21 @@ manage_service ()
|
|
|
a3470f |
local new_node=${2}
|
|
|
a3470f |
local option=
|
|
|
a3470f |
|
|
|
a3470f |
- if [ "$action" == "start" ]; then
|
|
|
a3470f |
+ if [ "${action}" == "start" ]; then
|
|
|
a3470f |
option="yes"
|
|
|
a3470f |
else
|
|
|
a3470f |
option="no"
|
|
|
a3470f |
fi
|
|
|
a3470f |
ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
a3470f |
-${SECRET_PEM} root@${new_node} "/usr/libexec/ganesha/ganesha-ha.sh --setup-ganesha-conf-files $HA_CONFDIR $option"
|
|
|
a3470f |
+${SECRET_PEM} root@${new_node} "${GANESHA_HA_SH} --setup-ganesha-conf-files $HA_CONFDIR $option"
|
|
|
a3470f |
|
|
|
a3470f |
- if [ "$SERVICE_MAN" == "/usr/bin/systemctl" ]
|
|
|
a3470f |
+ if [ "${SERVICE_MAN}" == "/bin/systemctl" ]
|
|
|
a3470f |
then
|
|
|
a3470f |
ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
a3470f |
-${SECRET_PEM} root@${new_node} "$SERVICE_MAN ${action} nfs-ganesha"
|
|
|
a3470f |
+${SECRET_PEM} root@${new_node} "${SERVICE_MAN} ${action} nfs-ganesha"
|
|
|
a3470f |
else
|
|
|
a3470f |
ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
a3470f |
-${SECRET_PEM} root@${new_node} "$SERVICE_MAN nfs-ganesha ${action}"
|
|
|
a3470f |
+${SECRET_PEM} root@${new_node} "${SERVICE_MAN} nfs-ganesha ${action}"
|
|
|
a3470f |
fi
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
|
|
|
a3470f |
index 4346bad..c16dd72 100644
|
|
|
a3470f |
--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c
|
|
|
a3470f |
+++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
|
|
|
a3470f |
@@ -119,11 +119,10 @@ sc_service_action (struct service_command *sc, char *command)
|
|
|
a3470f |
static int
|
|
|
a3470f |
manage_service (char *action)
|
|
|
a3470f |
{
|
|
|
a3470f |
- struct stat stbuf = {0,};
|
|
|
a3470f |
int i = 0;
|
|
|
a3470f |
int ret = 0;
|
|
|
a3470f |
struct service_command sc_list[] = {
|
|
|
a3470f |
- { .binary = "/usr/bin/systemctl",
|
|
|
a3470f |
+ { .binary = "/bin/systemctl",
|
|
|
a3470f |
.service = "nfs-ganesha",
|
|
|
a3470f |
.action = sc_systemctl_action
|
|
|
a3470f |
},
|
|
|
a3470f |
@@ -140,16 +139,11 @@ manage_service (char *action)
|
|
|
a3470f |
};
|
|
|
a3470f |
|
|
|
a3470f |
while (sc_list[i].binary != NULL) {
|
|
|
a3470f |
- ret = sys_stat (sc_list[i].binary, &stbuf);
|
|
|
a3470f |
+ ret = sys_access (sc_list[i].binary, X_OK);
|
|
|
a3470f |
if (ret == 0) {
|
|
|
a3470f |
gf_msg_debug (THIS->name, 0,
|
|
|
a3470f |
- "%s found.", sc_list[i].binary);
|
|
|
a3470f |
- if (strcmp (sc_list[i].binary, "/usr/bin/systemctl") == 0)
|
|
|
a3470f |
- ret = sc_systemctl_action (&sc_list[i], action);
|
|
|
a3470f |
- else
|
|
|
a3470f |
- ret = sc_service_action (&sc_list[i], action);
|
|
|
a3470f |
-
|
|
|
a3470f |
- return ret;
|
|
|
a3470f |
+ "%s found.", sc_list[i].binary);
|
|
|
a3470f |
+ return sc_list[i].action (&sc_list[i], action);
|
|
|
a3470f |
}
|
|
|
a3470f |
i++;
|
|
|
a3470f |
}
|
|
|
a3470f |
@@ -465,9 +459,9 @@ manage_export_config (char *volname, char *value, char **op_errstr)
|
|
|
a3470f |
|
|
|
a3470f |
GF_ASSERT(volname);
|
|
|
a3470f |
runinit (&runner);
|
|
|
a3470f |
- runner_add_args (&runner, "sh",
|
|
|
a3470f |
- GANESHA_PREFIX"/create-export-ganesha.sh",
|
|
|
a3470f |
- CONFDIR, value, volname, NULL);
|
|
|
a3470f |
+ runner_add_args (&runner,
|
|
|
a3470f |
+ GANESHA_PREFIX"/create-export-ganesha.sh",
|
|
|
a3470f |
+ CONFDIR, value, volname, NULL);
|
|
|
a3470f |
ret = runner_run(&runner);
|
|
|
a3470f |
|
|
|
a3470f |
if (ret)
|
|
|
a3470f |
@@ -570,8 +564,9 @@ ganesha_manage_export (dict_t *dict, char *value, char **op_errstr)
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
if (check_host_list()) {
|
|
|
a3470f |
- runner_add_args (&runner, "sh", GANESHA_PREFIX"/dbus-send.sh",
|
|
|
a3470f |
- CONFDIR, value, volname, NULL);
|
|
|
a3470f |
+ runner_add_args (&runner,
|
|
|
a3470f |
+ GANESHA_PREFIX"/dbus-send.sh",
|
|
|
a3470f |
+ CONFDIR, value, volname, NULL);
|
|
|
a3470f |
ret = runner_run (&runner);
|
|
|
a3470f |
if (ret) {
|
|
|
a3470f |
gf_asprintf(op_errstr, "Dynamic export"
|
|
|
a3470f |
@@ -610,9 +605,9 @@ tear_down_cluster(gf_boolean_t run_teardown)
|
|
|
a3470f |
|
|
|
a3470f |
if (run_teardown) {
|
|
|
a3470f |
runinit (&runner);
|
|
|
a3470f |
- runner_add_args (&runner, "sh",
|
|
|
a3470f |
- GANESHA_PREFIX"/ganesha-ha.sh", "teardown",
|
|
|
a3470f |
- CONFDIR, NULL);
|
|
|
a3470f |
+ runner_add_args (&runner,
|
|
|
a3470f |
+ GANESHA_PREFIX"/ganesha-ha.sh", "teardown",
|
|
|
a3470f |
+ CONFDIR, NULL);
|
|
|
a3470f |
ret = runner_run(&runner);
|
|
|
a3470f |
/* *
|
|
|
a3470f |
* Remove all the entries in CONFDIR expect ganesha.conf and
|
|
|
a3470f |
@@ -675,7 +670,8 @@ setup_cluster(gf_boolean_t run_setup)
|
|
|
a3470f |
|
|
|
a3470f |
if (run_setup) {
|
|
|
a3470f |
runinit (&runner);
|
|
|
a3470f |
- runner_add_args (&runner, "sh", GANESHA_PREFIX"/ganesha-ha.sh",
|
|
|
a3470f |
+ runner_add_args (&runner,
|
|
|
a3470f |
+ GANESHA_PREFIX"/ganesha-ha.sh",
|
|
|
a3470f |
"setup", CONFDIR, NULL);
|
|
|
a3470f |
ret = runner_run (&runner);
|
|
|
a3470f |
}
|
|
|
a3470f |
@@ -702,8 +698,9 @@ teardown (gf_boolean_t run_teardown, char **op_errstr)
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
runinit (&runner);
|
|
|
a3470f |
- runner_add_args (&runner, "sh", GANESHA_PREFIX"/ganesha-ha.sh",
|
|
|
a3470f |
- "cleanup", CONFDIR, NULL);
|
|
|
a3470f |
+ runner_add_args (&runner,
|
|
|
a3470f |
+ GANESHA_PREFIX"/ganesha-ha.sh",
|
|
|
a3470f |
+ "cleanup", CONFDIR, NULL);
|
|
|
a3470f |
ret = runner_run (&runner);
|
|
|
a3470f |
if (ret)
|
|
|
a3470f |
gf_msg_debug (THIS->name, 0, "Could not clean up"
|
|
|
a3470f |
@@ -747,7 +744,8 @@ stop_ganesha (char **op_errstr) {
|
|
|
a3470f |
runner_t runner = {0,};
|
|
|
a3470f |
|
|
|
a3470f |
runinit (&runner);
|
|
|
a3470f |
- runner_add_args (&runner, "sh", GANESHA_PREFIX"/ganesha-ha.sh",
|
|
|
a3470f |
+ runner_add_args (&runner,
|
|
|
a3470f |
+ GANESHA_PREFIX"/ganesha-ha.sh",
|
|
|
a3470f |
"--setup-ganesha-conf-files", CONFDIR, "no", NULL);
|
|
|
a3470f |
ret = runner_run (&runner);
|
|
|
a3470f |
if (ret) {
|
|
|
a3470f |
@@ -810,7 +808,7 @@ start_ganesha (char **op_errstr)
|
|
|
a3470f |
|
|
|
a3470f |
if (check_host_list()) {
|
|
|
a3470f |
runinit (&runner);
|
|
|
a3470f |
- runner_add_args (&runner, "sh", GANESHA_PREFIX"/ganesha-ha.sh",
|
|
|
a3470f |
+ runner_add_args (&runner, GANESHA_PREFIX"/ganesha-ha.sh",
|
|
|
a3470f |
"--setup-ganesha-conf-files", CONFDIR, "yes",
|
|
|
a3470f |
NULL);
|
|
|
a3470f |
ret = runner_run (&runner);
|
|
|
a3470f |
--
|
|
|
a3470f |
1.8.3.1
|
|
|
a3470f |
|