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