Commit 3206846e authored by Rocky Automation's avatar Rocky Automation 📺
Browse files

import pacemaker-2.1.0-8.el8

parent f7f2f424
SOURCES/nagios-agents-metadata-105ab8a.tar.gz
SOURCES/pacemaker-ba59be7.tar.gz
SOURCES/pacemaker-7c3f660.tar.gz
ea6c0a27fd0ae8ce02f84a11f08a0d79377041c3 SOURCES/nagios-agents-metadata-105ab8a.tar.gz
268769bcd0d6c2ea2d50db92aaea0f31637775d0 SOURCES/pacemaker-ba59be7.tar.gz
17aa11e179c3f9eacbacac5735d7f5b14a1ac010 SOURCES/pacemaker-7c3f660.tar.gz
From c6ee0973522268ed7b3241cf0ec2e06398444114 Mon Sep 17 00:00:00 2001
From: Grace Chin <gchin@redhat.com>
Date: Tue, 4 May 2021 12:02:17 -0400
Subject: [PATCH 1/4] Remove deprecated attrd_options
---
extra/resources/ping | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/extra/resources/ping b/extra/resources/ping
index 3cf8dfe..2e93f22 100755
--- a/extra/resources/ping
+++ b/extra/resources/ping
@@ -178,7 +178,7 @@ ping_stop() {
rm -f "${OCF_RESKEY_pidfile}"
- attrd_updater -D -n "$OCF_RESKEY_name" -d "$OCF_RESKEY_dampen" $attrd_options
+ attrd_updater -D -n "$OCF_RESKEY_name" -d "$OCF_RESKEY_dampen"
return $OCF_SUCCESS
}
@@ -302,9 +302,9 @@ ping_update() {
score=$(expr $active \* $OCF_RESKEY_multiplier)
if [ "$__OCF_ACTION" = "start" ] ; then
- attrd_updater -n "$OCF_RESKEY_name" -B "$score" -d "$OCF_RESKEY_dampen" $attrd_options
+ attrd_updater -n "$OCF_RESKEY_name" -B "$score" -d "$OCF_RESKEY_dampen"
else
- attrd_updater -n "$OCF_RESKEY_name" -v "$score" -d "$OCF_RESKEY_dampen" $attrd_options
+ attrd_updater -n "$OCF_RESKEY_name" -v "$score" -d "$OCF_RESKEY_dampen"
fi
rc=$?
case $rc in
@@ -396,11 +396,6 @@ case "${OCF_RESKEY_debug}" in
;;
esac
-attrd_options='-q'
-if [ "${OCF_RESKEY_debug}" = "true" ]; then
- attrd_options=''
-fi
-
case "$__OCF_ACTION" in
meta-data) meta_data
exit $OCF_SUCCESS
--
1.8.3.1
From 6d6c4691cf0970059689856c354daf9e098b4451 Mon Sep 17 00:00:00 2001
From: Grace Chin <gchin@redhat.com>
Date: Tue, 4 May 2021 14:50:37 -0400
Subject: [PATCH 2/4] Replace debug values, true and false, with 0 and 1
---
extra/resources/ping | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/extra/resources/ping b/extra/resources/ping
index 2e93f22..fee019b 100755
--- a/extra/resources/ping
+++ b/extra/resources/ping
@@ -24,7 +24,7 @@
: ${OCF_RESKEY_dampen:="5s"}
: ${OCF_RESKEY_attempts:="3"}
: ${OCF_RESKEY_multiplier:="1"}
-: ${OCF_RESKEY_debug:="false"}
+: ${OCF_RESKEY_debug:="0"}
: ${OCF_RESKEY_failure_score:="0"}
: ${OCF_RESKEY_use_fping:="1"}
: ${OCF_RESKEY_host_list:=""}
@@ -152,7 +152,7 @@ END
ping_conditional_log() {
level="$1"; shift
- if [ "${OCF_RESKEY_debug}" = "true" ]; then
+ if [ $OCF_RESKEY_debug -gt 0 ]; then
ocf_log "$level" "$*"
fi
}
@@ -388,8 +388,8 @@ fi
# Check the debug option
case "${OCF_RESKEY_debug}" in
- true|True|TRUE|1) OCF_RESKEY_debug=true;;
- false|False|FALSE|0) OCF_RESKEY_debug=false;;
+ true|True|TRUE|1) OCF_RESKEY_debug=0;;
+ false|False|FALSE|0) OCF_RESKEY_debug=1;;
*)
ocf_log warn "Value for 'debug' is incorrect. Please specify 'true' or 'false' not: ${OCF_RESKEY_debug}"
OCF_RESKEY_debug=false
--
1.8.3.1
From a886a31056b6aca764c6911f5432af2c5ebf51df Mon Sep 17 00:00:00 2001
From: Grace Chin <gchin@redhat.com>
Date: Tue, 11 May 2021 11:04:50 -0400
Subject: [PATCH 3/4] Add verbose debug mode which logs ping and fping output
when set
---
extra/resources/ping | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/extra/resources/ping b/extra/resources/ping
index fee019b..cc796af 100755
--- a/extra/resources/ping
+++ b/extra/resources/ping
@@ -249,10 +249,13 @@ fping_check() {
case $rc in
0)
+ if [ $OCF_RESKEY_debug -gt 1 ]; then
+ ping_conditional_log info "$output"
+ fi
;;
1)
for h in $(echo "$output" | grep "is unreachable" | awk '{print $1}'); do
- ping_conditional_log warn "$h is inactive"
+ ping_conditional_log warn "$h is inactive: $output"
done
;;
*)
@@ -282,7 +285,12 @@ ping_check() {
p_out=$($p_exe $p_args $OCF_RESKEY_options $host 2>&1); rc=$?
case $rc in
- 0) active=$(expr $active + 1);;
+ 0)
+ active=$(expr $active + 1)
+ if [ $OCF_RESKEY_debug -gt 1 ]; then
+ ping_conditional_log info "$p_out"
+ fi
+ ;;
1) ping_conditional_log warn "$host is inactive: $p_out";;
*) ocf_log err "Unexpected result for '$p_exe $p_args $OCF_RESKEY_options $host' $rc: $p_out";;
esac
@@ -388,10 +396,11 @@ fi
# Check the debug option
case "${OCF_RESKEY_debug}" in
- true|True|TRUE|1) OCF_RESKEY_debug=0;;
- false|False|FALSE|0) OCF_RESKEY_debug=1;;
+ true|True|TRUE|1) OCF_RESKEY_debug=1;;
+ false|False|FALSE|0) OCF_RESKEY_debug=0;;
+ verbose|Verbose|VERBOSE|2) OCF_RESKEY_debug=2;;
*)
- ocf_log warn "Value for 'debug' is incorrect. Please specify 'true' or 'false' not: ${OCF_RESKEY_debug}"
+ ocf_log warn "Value for 'debug' is incorrect. Please specify 'true', 'false', or 'verbose', not: ${OCF_RESKEY_debug}"
OCF_RESKEY_debug=false
;;
esac
--
1.8.3.1
From 460043f133ced80e923b1290af70502a72deb7f8 Mon Sep 17 00:00:00 2001
From: Grace Chin <gchin@redhat.com>
Date: Tue, 11 May 2021 11:07:05 -0400
Subject: [PATCH 4/4] Improve variable names
---
extra/resources/ping | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/extra/resources/ping b/extra/resources/ping
index cc796af..9763b60 100755
--- a/extra/resources/ping
+++ b/extra/resources/ping
@@ -244,22 +244,22 @@ fping_check() {
timeout=$(expr $OCF_RESKEY_timeout \* 1000 / $OCF_RESKEY_attempts)
cmd="$p_exe -r $OCF_RESKEY_attempts -t $timeout -B 1.0 $OCF_RESKEY_options $OCF_RESKEY_host_list"
- output=$($cmd 2>&1); rc=$?
- active=$(echo "$output" | grep "is alive" | wc -l)
+ fping_output=$($cmd 2>&1); rc=$?
+ active=$(echo "$fping_output" | grep "is alive" | wc -l)
case $rc in
0)
if [ $OCF_RESKEY_debug -gt 1 ]; then
- ping_conditional_log info "$output"
+ ping_conditional_log info "$fping_output"
fi
;;
1)
- for h in $(echo "$output" | grep "is unreachable" | awk '{print $1}'); do
- ping_conditional_log warn "$h is inactive: $output"
+ for h in $(echo "$fping_output" | grep "is unreachable" | awk '{print $1}'); do
+ ping_conditional_log warn "$h is inactive: $fping_output"
done
;;
*)
- ocf_log err "Unexpected result for '$cmd' $rc: $(echo "$output" | tr '\n' ';')"
+ ocf_log err "Unexpected result for '$cmd' $rc: $(echo "$fping_output" | tr '\n' ';')"
;;
esac
@@ -282,17 +282,17 @@ ping_check() {
*:*) p_exe=ping6
esac
- p_out=$($p_exe $p_args $OCF_RESKEY_options $host 2>&1); rc=$?
+ ping_output=$($p_exe $p_args $OCF_RESKEY_options $host 2>&1); rc=$?
case $rc in
0)
active=$(expr $active + 1)
if [ $OCF_RESKEY_debug -gt 1 ]; then
- ping_conditional_log info "$p_out"
+ ping_conditional_log info "$ping_output"
fi
;;
- 1) ping_conditional_log warn "$host is inactive: $p_out";;
- *) ocf_log err "Unexpected result for '$p_exe $p_args $OCF_RESKEY_options $host' $rc: $p_out";;
+ 1) ping_conditional_log warn "$host is inactive: $ping_output";;
+ *) ocf_log err "Unexpected result for '$p_exe $p_args $OCF_RESKEY_options $host' $rc: $ping_output";;
esac
done
return $active
--
1.8.3.1
From 0d40ebf10b1794ece2c5c9768ea7222d3834d3b3 Mon Sep 17 00:00:00 2001
From: Chris Lumens <clumens@redhat.com>
Date: Thu, 13 May 2021 11:42:18 -0400
Subject: [PATCH 1/4] Build: Use a different variable to find man page
includes.
With other programs outside of the tools directory being converted to
use glib for command line handling, their includes are not going to be
in tools/. So we need to use a different autoconf variable to find
them.
---
mk/common.mk | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mk/common.mk b/mk/common.mk
index b247670..aa59feb 100644
--- a/mk/common.mk
+++ b/mk/common.mk
@@ -1,5 +1,5 @@
#
-# Copyright 2014-2020 the Pacemaker project contributors
+# Copyright 2014-2021 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
@@ -68,11 +68,11 @@ HELP2MAN_ARGS = -N --section 8 --name "Part of the Pacemaker cluster resource ma
# and all wrappers to C code.
%.8: % $(MAN8DEPS)
$(AM_V_at)chmod a+x $(abs_builddir)/$<
- $(AM_V_MAN)if [ -f $(top_srcdir)/tools/$@.inc ]; then \
+ $(AM_V_MAN)if [ -f $(abs_srcdir)/$@.inc ]; then \
PATH=$(abs_builddir):$$PATH $(HELP2MAN) $(HELP2MAN_ARGS) \
-h --help-all \
--no-discard-stderr \
- -i $(top_srcdir)/tools/$@.inc $(abs_builddir)/$< \
+ -i $(abs_srcdir)/$@.inc $(abs_builddir)/$< \
| sed -f $(top_srcdir)/tools/fix-manpages > $@ ; \
else \
PATH=$(abs_builddir):$$PATH $(HELP2MAN) $(HELP2MAN_ARGS) \
--
1.8.3.1
From c7ab1d901bcbbf0137277e783e072777ca2f82d9 Mon Sep 17 00:00:00 2001
From: Chris Lumens <clumens@redhat.com>
Date: Thu, 13 May 2021 11:44:16 -0400
Subject: [PATCH 2/4] Refactor: daemons: Remove the pid_file variable from
pacemakerd.
It's never used anywhere.
---
daemons/pacemakerd/pacemakerd.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/daemons/pacemakerd/pacemakerd.c b/daemons/pacemakerd/pacemakerd.c
index 8ec9708..03d688e 100644
--- a/daemons/pacemakerd/pacemakerd.c
+++ b/daemons/pacemakerd/pacemakerd.c
@@ -27,8 +27,7 @@
static crm_trigger_t *shutdown_trigger = NULL;
static crm_trigger_t *startup_trigger = NULL;
-static const char *pid_file = PCMK_RUN_DIR "/pacemaker.pid";
/* state we report when asked via pacemakerd-api status-ping */
static const char *pacemakerd_state = XML_PING_ATTR_PACEMAKERDSTATE_INIT;
static gboolean running_with_sbd = FALSE; /* local copy */
@@ -224,7 +222,6 @@ main(int argc, char **argv)
/* Legacy */
break;
case 'p':
- pid_file = optarg;
break;
case 's':
pcmk__set_env_option("node_start_state", "standby");
--
1.8.3.1
From 98990eed9f6a5dbde7c8a5aa0783e93d5479295b Mon Sep 17 00:00:00 2001
From: Chris Lumens <clumens@redhat.com>
Date: Thu, 13 May 2021 13:14:38 -0400
Subject: [PATCH 3/4] Refactor: daemons: Use glib for command line handling in
pacemakerd.
---
daemons/pacemakerd/Makefile.am | 2 +
daemons/pacemakerd/pacemakerd.8.inc | 5 +
daemons/pacemakerd/pacemakerd.c | 195 ++++++++++++++++++------------------
3 files changed, 102 insertions(+), 100 deletions(-)
create mode 100644 daemons/pacemakerd/pacemakerd.8.inc
diff --git a/daemons/pacemakerd/Makefile.am b/daemons/pacemakerd/Makefile.am
index cc657f5..84517a3 100644
--- a/daemons/pacemakerd/Makefile.am
+++ b/daemons/pacemakerd/Makefile.am
@@ -15,6 +15,8 @@ if BUILD_SYSTEMD
systemdsystemunit_DATA = pacemaker.service
endif
+EXTRA_DIST = pacemakerd.8.inc
+
## SOURCES
noinst_HEADERS = pacemakerd.h
diff --git a/daemons/pacemakerd/pacemakerd.8.inc b/daemons/pacemakerd/pacemakerd.8.inc
new file mode 100644
index 0000000..902af4e
--- /dev/null
+++ b/daemons/pacemakerd/pacemakerd.8.inc
@@ -0,0 +1,5 @@
+[synopsis]
+pacemakerd [options]
+
+/subsidiary Pacemaker daemons/
+.SH OPTIONS
diff --git a/daemons/pacemakerd/pacemakerd.c b/daemons/pacemakerd/pacemakerd.c
index 03d688e..ce194bf 100644
--- a/daemons/pacemakerd/pacemakerd.c
+++ b/daemons/pacemakerd/pacemakerd.c
@@ -23,12 +23,54 @@
#include <crm/msg_xml.h>
#include <crm/common/ipc_internal.h>
#include <crm/common/mainloop.h>
+#include <crm/common/cmdline_internal.h>
#include <crm/cluster/internal.h>
#include <crm/cluster.h>
#include <dirent.h>
#include <ctype.h>
+#define SUMMARY "pacemakerd - primary Pacemaker daemon that launches and monitors all subsidiary Pacemaker daemons"
+
+struct {
+ gboolean features;
+ gboolean foreground;
+ gboolean shutdown;
+ gboolean standby;
+} options;
+
+static gboolean
+pid_cb(const gchar *option_name, const gchar *optarg, gpointer data, GError **err) {
+ return TRUE;
+}
+
+static gboolean
+standby_cb(const gchar *option_name, const gchar *optarg, gpointer data, GError **err) {
+ options.standby = TRUE;
+ pcmk__set_env_option("node_start_state", "standby");
+ return TRUE;
+}
+
+static GOptionEntry entries[] = {
+ { "features", 'F', 0, G_OPTION_ARG_NONE, &options.features,
+ "Display full version and list of features Pacemaker was built with",
+ NULL },
+ { "foreground", 'f', 0, G_OPTION_ARG_NONE, &options.foreground,
+ "(Ignored) Pacemaker always runs in the foreground",
+ NULL },
+ { "pid-file", 'p', 0, G_OPTION_ARG_CALLBACK, pid_cb,
+ "(Ignored) Daemon pid file location",
+ "FILE" },
+ { "shutdown", 'S', 0, G_OPTION_ARG_NONE, &options.shutdown,
+ "Instruct Pacemaker to shutdown on this machine",
+ NULL },
+ { "standby", 's', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, standby_cb,
+ "Start node in standby state",
+ NULL },
+
+ { NULL }
+};
+
static gboolean fatal_error = FALSE;
static GMainLoop *mainloop = NULL;
static bool global_keep_tracking = false;
@@ -642,49 +685,6 @@ pcmk_sigquit(int nsig)
.connection_destroyed = pcmk_ipc_destroy
};
-static pcmk__cli_option_t long_options[] = {
- // long option, argument type, storage, short option, description, flags
- {
- "help", no_argument, NULL, '?',
- "\tThis text", pcmk__option_default
- },
- {
- "version", no_argument, NULL, '$',
- "\tVersion information", pcmk__option_default
- },
- {
- "verbose", no_argument, NULL, 'V',
- "\tIncrease debug output", pcmk__option_default
- },
- {
- "shutdown", no_argument, NULL, 'S',
- "\tInstruct Pacemaker to shutdown on this machine", pcmk__option_default
- },
- {
- "features", no_argument, NULL, 'F',
- "\tDisplay full version and list of features Pacemaker was built with",
- pcmk__option_default
- },
- {
- "-spacer-", no_argument, NULL, '-',
- "\nAdditional Options:", pcmk__option_default
- },
- {
- "foreground", no_argument, NULL, 'f',
- "\t(Ignored) Pacemaker always runs in the foreground",
- pcmk__option_default
- },
- {
- "pid-file", required_argument, NULL, 'p',
- "\t(Ignored) Daemon pid file location", pcmk__option_default
- },
- {
- "standby", no_argument, NULL, 's',
- "\tStart node in standby state", pcmk__option_default
- },
- { 0, 0, 0, 0 }
-};
-
static void
mcp_chown(const char *path, uid_t uid, gid_t gid)
{
@@ -1168,83 +1211,66 @@ request_shutdown(crm_ipc_t *ipc)
return status;
}
+static GOptionContext *
+build_arg_context(pcmk__common_args_t *args) {
+ GOptionContext *context = NULL;
+
+ context = pcmk__build_arg_context(args, NULL, NULL, NULL);
+ pcmk__add_main_args(context, entries);
+ return context;
+}
+
int
main(int argc, char **argv)
{
- int flag;
- int argerr = 0;
+ crm_exit_t exit_code = CRM_EX_OK;
+
+ GError *error = NULL;
+
+ pcmk__common_args_t *args = pcmk__new_common_args(SUMMARY);
+ gchar **processed_args = pcmk__cmdline_preproc(argv, "p");
+ GOptionContext *context = build_arg_context(args);
- int option_index = 0;
bool old_instance_connected = false;
- gboolean shutdown = FALSE;
crm_ipc_t *old_instance = NULL;
qb_ipcs_service_t *ipcs = NULL;
crm_log_preinit(NULL, argc, argv);
- pcmk__set_cli_options(NULL, "[options]", long_options,
- "primary Pacemaker daemon that launches and "
- "monitors all subsidiary Pacemaker daemons");
mainloop_add_signal(SIGHUP, pcmk_ignore);
mainloop_add_signal(SIGQUIT, pcmk_sigquit);
- while (1) {
- flag = pcmk__next_cli_option(argc, argv, &option_index, NULL);
- if (flag == -1)
- break;
-
- switch (flag) {
- case 'V':
- crm_bump_log_level(argc, argv);
- break;
- case 'f':
- /* Legacy */
- break;
- case 'p':
- break;
- case 's':
- pcmk__set_env_option("node_start_state", "standby");
- break;
- case '$':
- case '?':
- pcmk__cli_help(flag, CRM_EX_OK);
- break;
- case 'S':
- shutdown = TRUE;
- break;
- case 'F':
- printf("Pacemaker %s (Build: %s)\n Supporting v%s: %s\n", PACEMAKER_VERSION, BUILD_VERSION,
- CRM_FEATURE_SET, CRM_FEATURES);
- crm_exit(CRM_EX_OK);
- default:
- printf("Argument code 0%o (%c) is not (?yet?) supported\n", flag, flag);
- ++argerr;
- break;
- }
+ if (!g_option_context_parse_strv(context, &processed_args, &error)) {
+ exit_code = CRM_EX_USAGE;
+ goto done;
}
- if (optind < argc) {
- printf("non-option ARGV-elements: ");
- while (optind < argc)
- printf("%s ", argv[optind++]);
- printf("\n");
- }
- if (argerr) {
- pcmk__cli_help('?', CRM_EX_USAGE);
+ if (options.features) {
+ printf("Pacemaker %s (Build: %s)\n Supporting v%s: %s\n", PACEMAKER_VERSION, BUILD_VERSION,
+ CRM_FEATURE_SET, CRM_FEATURES);
+ exit_code = CRM_EX_OK;
+ goto done;
}
+ if (args->version) {
+ g_strfreev(processed_args);
+ pcmk__free_arg_context(context);
+ /* FIXME: When pacemakerd is converted to use formatted output, this can go. */
+ pcmk__cli_help('v', CRM_EX_USAGE);
+ }
setenv("LC_ALL", "C", 1);
pcmk__set_env_option("mcp", "true");
+ pcmk__cli_init_logging("pacemakerd", args->verbosity);
crm_log_init(NULL, LOG_INFO, TRUE, FALSE, argc, argv, FALSE);
crm_debug("Checking for existing Pacemaker instance");
old_instance = crm_ipc_new(CRM_SYSTEM_MCP, 0);
old_instance_connected = crm_ipc_connect(old_instance);
- if (shutdown) {
+ if (options.shutdown) {
if (old_instance_connected) {
crm_exit(request_shutdown(old_instance));
} else {
@@ -1253,22 +1279,25 @@ main(int argc, char **argv)
"Pacemaker instance: %s", strerror(errno));
crm_ipc_close(old_instance);
crm_ipc_destroy(old_instance);
- crm_exit(CRM_EX_DISCONNECT);
+ exit_code = CRM_EX_DISCONNECT;
+ goto done;
}
} else if (old_instance_connected) {
crm_ipc_close(old_instance);
crm_ipc_destroy(old_instance);
crm_err("Aborting start-up because active Pacemaker instance found");
- crm_exit(CRM_EX_FATAL);
+ exit_code = CRM_EX_FATAL;
+ goto done;
}
crm_ipc_close(old_instance);
crm_ipc_destroy(old_instance);
#ifdef SUPPORT_COROSYNC
if (mcp_read_config() == FALSE) {
- crm_exit(CRM_EX_UNAVAILABLE);
+ exit_code = CRM_EX_UNAVAILABLE;
+ goto done;
}
#endif
@@ -1292,7 +1321,8 @@ main(int argc, char **argv)
#ifdef SUPPORT_COROSYNC
/* Allows us to block shutdown */
if (!cluster_connect_cfg()) {
- crm_exit(CRM_EX_PROTOCOL);
+ exit_code = CRM_EX_PROTOCOL;
+ goto done;
}
#endif
@@ -1307,9 +1337,11 @@ main(int argc, char **argv)
case pcmk_rc_ok:
break;
case pcmk_rc_ipc_unauthorized:
- crm_exit(CRM_EX_CANTCREAT);
+ exit_code = CRM_EX_CANTCREAT;
+ goto done;
default:
- crm_exit(CRM_EX_FATAL);
+ exit_code = CRM_EX_FATAL;
+ goto done;
};
mainloop_add_signal(SIGTERM, pcmk_shutdown);
@@ -1342,5 +1374,11 @@ main(int argc, char **argv)
#ifdef SUPPORT_COROSYNC
cluster_disconnect_cfg();
#endif
- crm_exit(CRM_EX_OK);
+
+done:
+ g_strfreev(processed_args);
+ pcmk__free_arg_context(context);
+
+ pcmk__output_and_clear_error(error, NULL);