summaryrefslogtreecommitdiffstats
path: root/daemons/pacemakerd
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:45:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:45:40 +0000
commit07d7f4cfa4b10de87a31b68191036ff446add675 (patch)
tree7162524d8aaf1aef62d2f4fa51f595ed113981ff /daemons/pacemakerd
parentAdding upstream version 2.1.6. (diff)
downloadpacemaker-0d560556df519c6626cda7660f843a815b3c227e.tar.xz
pacemaker-0d560556df519c6626cda7660f843a815b3c227e.zip
Adding upstream version 2.1.7.upstream/2.1.7
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'daemons/pacemakerd')
-rw-r--r--daemons/pacemakerd/Makefile.am8
-rw-r--r--daemons/pacemakerd/pacemakerd.c26
-rw-r--r--daemons/pacemakerd/pacemakerd.h6
-rw-r--r--daemons/pacemakerd/pcmkd_corosync.c16
-rw-r--r--daemons/pacemakerd/pcmkd_messages.c2
-rw-r--r--daemons/pacemakerd/pcmkd_subdaemons.c27
6 files changed, 47 insertions, 38 deletions
diff --git a/daemons/pacemakerd/Makefile.am b/daemons/pacemakerd/Makefile.am
index fc0e014..78e7c37 100644
--- a/daemons/pacemakerd/Makefile.am
+++ b/daemons/pacemakerd/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright 2004-2021 the Pacemaker project contributors
+# Copyright 2004-2023 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
@@ -25,8 +25,10 @@ noinst_HEADERS = pacemakerd.h
pacemakerd_CFLAGS = $(CFLAGS_HARDENED_EXE)
pacemakerd_LDFLAGS = $(LDFLAGS_HARDENED_EXE)
-pacemakerd_LDADD = $(top_builddir)/lib/cluster/libcrmcluster.la $(top_builddir)/lib/common/libcrmcommon.la
-pacemakerd_LDADD += $(CLUSTERLIBS)
+pacemakerd_LDADD = $(top_builddir)/lib/cluster/libcrmcluster.la
+pacemakerd_LDADD += $(top_builddir)/lib/common/libcrmcommon.la
+pacemakerd_LDADD += $(CLUSTERLIBS)
+
pacemakerd_SOURCES = pacemakerd.c
if BUILD_CS_SUPPORT
pacemakerd_SOURCES += pcmkd_corosync.c
diff --git a/daemons/pacemakerd/pacemakerd.c b/daemons/pacemakerd/pacemakerd.c
index 9f77ccc..365b743 100644
--- a/daemons/pacemakerd/pacemakerd.c
+++ b/daemons/pacemakerd/pacemakerd.c
@@ -92,7 +92,7 @@ pid_cb(const gchar *option_name, const gchar *optarg, gpointer data, GError **er
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");
+ pcmk__set_env_option(PCMK__ENV_NODE_START_STATE, "standby", false);
return TRUE;
}
@@ -129,7 +129,7 @@ pcmk_sigquit(int nsig)
}
static void
-mcp_chown(const char *path, uid_t uid, gid_t gid)
+pacemakerd_chown(const char *path, uid_t uid, gid_t gid)
{
int rc = chown(path, uid, gid);
@@ -166,7 +166,7 @@ create_pcmk_dirs(void)
crm_warn("Could not create directory " CRM_STATE_DIR ": %s",
pcmk_rc_str(errno));
} else {
- mcp_chown(CRM_STATE_DIR, pcmk_uid, pcmk_gid);
+ pacemakerd_chown(CRM_STATE_DIR, pcmk_uid, pcmk_gid);
}
for (int i = 0; dirs[i] != NULL; ++i) {
@@ -176,7 +176,7 @@ create_pcmk_dirs(void)
crm_warn("Could not create directory %s: %s",
dirs[i], pcmk_rc_str(rc));
} else {
- mcp_chown(dirs[i], pcmk_uid, pcmk_gid);
+ pacemakerd_chown(dirs[i], pcmk_uid, pcmk_gid);
}
}
}
@@ -312,7 +312,8 @@ main(int argc, char **argv)
goto done;
}
- pcmk__set_env_option("mcp", "true");
+ // @COMPAT Drop at 3.0.0; likely last used in 1.1.24
+ pcmk__set_env_option(PCMK__ENV_MCP, "true", true);
if (options.shutdown) {
pcmk__cli_init_logging("pacemakerd", args->verbosity);
@@ -330,7 +331,11 @@ main(int argc, char **argv)
}
pcmk_register_ipc_callback(old_instance, pacemakerd_event_cb, NULL);
- rc = pcmk_connect_ipc(old_instance, pcmk_ipc_dispatch_sync);
+ rc = pcmk__connect_ipc(old_instance, pcmk_ipc_dispatch_sync, 2);
+ if (rc != pcmk_rc_ok) {
+ crm_debug("No existing %s instance found: %s",
+ pcmk_ipc_name(old_instance, true), pcmk_rc_str(rc));
+ }
old_instance_connected = pcmk_ipc_is_connected(old_instance);
if (options.shutdown) {
@@ -388,7 +393,7 @@ main(int argc, char **argv)
}
#ifdef SUPPORT_COROSYNC
- if (mcp_read_config() == FALSE) {
+ if (pacemakerd_read_config() == FALSE) {
crm_exit(CRM_EX_UNAVAILABLE);
}
#endif
@@ -399,7 +404,7 @@ main(int argc, char **argv)
if (!pcmk__str_eq(facility, PCMK__VALUE_NONE,
pcmk__str_casei|pcmk__str_null_matches)) {
- setenv("HA_LOGFACILITY", facility, 1);
+ pcmk__set_env_option("LOGFACILITY", facility, true);
}
}
@@ -409,7 +414,7 @@ main(int argc, char **argv)
remove_core_file_limit();
create_pcmk_dirs();
- pcmk__serve_pacemakerd_ipc(&ipcs, &mcp_ipc_callbacks);
+ pcmk__serve_pacemakerd_ipc(&ipcs, &pacemakerd_ipc_callbacks);
#ifdef SUPPORT_COROSYNC
/* Allows us to block shutdown */
@@ -420,10 +425,7 @@ main(int argc, char **argv)
#endif
if (pcmk__locate_sbd() > 0) {
- setenv("PCMK_watchdog", "true", 1);
running_with_sbd = TRUE;
- } else {
- setenv("PCMK_watchdog", "false", 1);
}
switch (find_and_track_existing_processes()) {
diff --git a/daemons/pacemakerd/pacemakerd.h b/daemons/pacemakerd/pacemakerd.h
index b2a6864..ee6facf 100644
--- a/daemons/pacemakerd/pacemakerd.h
+++ b/daemons/pacemakerd/pacemakerd.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2022 the Pacemaker project contributors
+ * Copyright 2010-2023 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
@@ -14,7 +14,7 @@
#define MAX_RESPAWN 100
extern GMainLoop *mainloop;
-extern struct qb_ipcs_service_handlers mcp_ipc_callbacks;
+extern struct qb_ipcs_service_handlers pacemakerd_ipc_callbacks;
extern const char *pacemakerd_state;
extern gboolean running_with_sbd;
extern unsigned int shutdown_complete_state_reported_to;
@@ -23,7 +23,7 @@ extern crm_trigger_t *shutdown_trigger;
extern crm_trigger_t *startup_trigger;
extern time_t subdaemon_check_progress;
-gboolean mcp_read_config(void);
+gboolean pacemakerd_read_config(void);
gboolean cluster_connect_cfg(void);
void cluster_disconnect_cfg(void);
diff --git a/daemons/pacemakerd/pcmkd_corosync.c b/daemons/pacemakerd/pcmkd_corosync.c
index 2648756..8a1a867 100644
--- a/daemons/pacemakerd/pcmkd_corosync.c
+++ b/daemons/pacemakerd/pcmkd_corosync.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2022 the Pacemaker project contributors
+ * Copyright 2010-2023 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
@@ -82,7 +82,7 @@ cluster_reconnect_cb(gpointer data)
mainloop_timer_del(reconnect_timer);
reconnect_timer = NULL;
crm_notice("Cluster reconnect succeeded");
- mcp_read_config();
+ pacemakerd_read_config();
restart_cluster_subdaemons();
return G_SOURCE_REMOVE;
} else {
@@ -260,7 +260,7 @@ get_config_opt(uint64_t unused, cmap_handle_t object_handle, const char *key, ch
}
gboolean
-mcp_read_config(void)
+pacemakerd_read_config(void)
{
cs_error_t rc = CS_OK;
int retries = 0;
@@ -327,8 +327,10 @@ mcp_read_config(void)
crm_info("Reading configuration for %s stack",
name_for_cluster_type(stack));
- pcmk__set_env_option(PCMK__ENV_CLUSTER_TYPE, "corosync");
- pcmk__set_env_option(PCMK__ENV_QUORUM_TYPE, "corosync");
+ pcmk__set_env_option(PCMK__ENV_CLUSTER_TYPE, "corosync", true);
+
+ // @COMPAT Drop at 3.0.0; added unused in 1.1.9
+ pcmk__set_env_option(PCMK__ENV_QUORUM_TYPE, "corosync", true);
// If debug logging is not configured, check whether corosync has it
if (pcmk__env_option(PCMK__ENV_DEBUG) == NULL) {
@@ -337,13 +339,13 @@ mcp_read_config(void)
get_config_opt(config, local_handle, "logging.debug", &debug_enabled, "off");
if (crm_is_true(debug_enabled)) {
- pcmk__set_env_option(PCMK__ENV_DEBUG, "1");
+ pcmk__set_env_option(PCMK__ENV_DEBUG, "1", true);
if (get_crm_log_level() < LOG_DEBUG) {
set_crm_log_level(LOG_DEBUG);
}
} else {
- pcmk__set_env_option(PCMK__ENV_DEBUG, "0");
+ pcmk__set_env_option(PCMK__ENV_DEBUG, "0", true);
}
free(debug_enabled);
diff --git a/daemons/pacemakerd/pcmkd_messages.c b/daemons/pacemakerd/pcmkd_messages.c
index 7ed9899..4e6f822 100644
--- a/daemons/pacemakerd/pcmkd_messages.c
+++ b/daemons/pacemakerd/pcmkd_messages.c
@@ -269,7 +269,7 @@ pcmk_ipc_dispatch(qb_ipcs_connection_t * qbc, void *data, size_t size)
return 0;
}
-struct qb_ipcs_service_handlers mcp_ipc_callbacks = {
+struct qb_ipcs_service_handlers pacemakerd_ipc_callbacks = {
.connection_accept = pcmk_ipc_accept,
.connection_created = NULL,
.msg_process = pcmk_ipc_dispatch,
diff --git a/daemons/pacemakerd/pcmkd_subdaemons.c b/daemons/pacemakerd/pcmkd_subdaemons.c
index 3b08ecc..21e432e 100644
--- a/daemons/pacemakerd/pcmkd_subdaemons.c
+++ b/daemons/pacemakerd/pcmkd_subdaemons.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2022 the Pacemaker project contributors
+ * Copyright 2010-2023 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
@@ -307,7 +307,7 @@ pcmk_process_exit(pcmk_child_t * child)
} else if (!child->respawn) {
/* nothing to do */
- } else if (crm_is_true(getenv("PCMK_fail_fast"))) {
+ } else if (crm_is_true(pcmk__env_option(PCMK__ENV_FAIL_FAST))) {
crm_err("Rebooting system because of %s", child->name);
pcmk__panic(__func__);
@@ -353,8 +353,8 @@ pcmk_shutdown_worker(gpointer user_data)
" if it vitally depends on some other daemons"
" going down in a controlled way already,"
" or locate and kill the correct %s process"
- " on your own; set PCMK_fail_fast=1 to avoid"
- " this altogether next time around",
+ " on your own; set PCMK_" PCMK__ENV_FAIL_FAST "=1"
+ " to avoid this altogether next time around",
child->name, (long) SHUTDOWN_ESCALATION_PERIOD,
child->command);
}
@@ -389,6 +389,7 @@ pcmk_shutdown_worker(gpointer user_data)
return TRUE;
}
+ // @COMPAT Drop shutdown delay at 3.0.0
{
const char *delay = pcmk__env_option(PCMK__ENV_SHUTDOWN_DELAY);
if(delay) {
@@ -423,8 +424,8 @@ start_child(pcmk_child_t * child)
gid_t gid = 0;
gboolean use_valgrind = FALSE;
gboolean use_callgrind = FALSE;
- const char *env_valgrind = getenv("PCMK_valgrind_enabled");
- const char *env_callgrind = getenv("PCMK_callgrind_enabled");
+ const char *env_valgrind = pcmk__env_option(PCMK__ENV_VALGRIND_ENABLED);
+ const char *env_callgrind = pcmk__env_option(PCMK__ENV_CALLGRIND_ENABLED);
child->active_before_startup = false;
child->check_count = 0;
@@ -712,14 +713,16 @@ find_and_track_existing_processes(void)
continue;
}
+ // @TODO Functionize more of this to reduce nesting
pcmk_children[i].respawn_count = rounds;
switch (rc) {
case pcmk_rc_ok:
if (pcmk_children[i].pid == PCMK__SPECIAL_PID) {
- if (crm_is_true(getenv("PCMK_fail_fast"))) {
+ if (crm_is_true(pcmk__env_option(PCMK__ENV_FAIL_FAST))) {
crm_crit("Cannot reliably track pre-existing"
" authentic process behind %s IPC on this"
- " platform and PCMK_fail_fast requested",
+ " platform and PCMK_" PCMK__ENV_FAIL_FAST
+ " requested",
pcmk_children[i].endpoint);
return EOPNOTSUPP;
} else if (pcmk_children[i].respawn_count == WAIT_TRIES) {
@@ -727,9 +730,9 @@ find_and_track_existing_processes(void)
" on this platform untrackable, process"
" behind %s IPC is stable (was in %d"
" previous samples) so rather than"
- " bailing out (PCMK_fail_fast not"
- " requested), we just switch to a less"
- " optimal IPC liveness monitoring"
+ " bailing out (PCMK_" PCMK__ENV_FAIL_FAST
+ " not requested), we just switch to a"
+ " less optimal IPC liveness monitoring"
" (not very suitable for heavy load)",
pcmk_children[i].name, WAIT_TRIES - 1);
crm_warn("The process behind %s IPC cannot be"
@@ -822,7 +825,7 @@ init_children_processes(void *user_data)
*
* This may be useful for the daemons to know
*/
- setenv("PCMK_respawned", "true", 1);
+ pcmk__set_env_option(PCMK__ENV_RESPAWNED, "true", false);
pacemakerd_state = XML_PING_ATTR_PACEMAKERDSTATE_RUNNING;
return TRUE;
}