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