summaryrefslogtreecommitdiffstats
path: root/daemons/pacemakerd
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 13:39:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 13:39:28 +0000
commit7332b914bff2786ff70ccace103fc9ebdfb61a23 (patch)
tree3a8a60c4edba014c7e350be41839e3edbf2a315f /daemons/pacemakerd
parentAdding debian version 2.1.7-1. (diff)
downloadpacemaker-7332b914bff2786ff70ccace103fc9ebdfb61a23.tar.xz
pacemaker-7332b914bff2786ff70ccace103fc9ebdfb61a23.zip
Merging upstream version 2.1.8~rc1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--daemons/pacemakerd/Makefile.am3
-rw-r--r--daemons/pacemakerd/pacemakerd.c34
-rw-r--r--daemons/pacemakerd/pacemakerd.h12
-rw-r--r--daemons/pacemakerd/pcmkd_corosync.c20
-rw-r--r--daemons/pacemakerd/pcmkd_corosync.h16
-rw-r--r--daemons/pacemakerd/pcmkd_messages.c55
-rw-r--r--daemons/pacemakerd/pcmkd_subdaemons.c116
7 files changed, 144 insertions, 112 deletions
diff --git a/daemons/pacemakerd/Makefile.am b/daemons/pacemakerd/Makefile.am
index 78e7c37..7571a6c 100644
--- a/daemons/pacemakerd/Makefile.am
+++ b/daemons/pacemakerd/Makefile.am
@@ -20,7 +20,8 @@ EXTRA_DIST = pacemakerd.8.inc
## SOURCES
-noinst_HEADERS = pacemakerd.h
+noinst_HEADERS = pacemakerd.h \
+ pcmkd_corosync.h
pacemakerd_CFLAGS = $(CFLAGS_HARDENED_EXE)
pacemakerd_LDFLAGS = $(LDFLAGS_HARDENED_EXE)
diff --git a/daemons/pacemakerd/pacemakerd.c b/daemons/pacemakerd/pacemakerd.c
index 365b743..5d5a1db 100644
--- a/daemons/pacemakerd/pacemakerd.c
+++ b/daemons/pacemakerd/pacemakerd.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2023 the Pacemaker project contributors
+ * Copyright 2010-2024 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
@@ -10,6 +10,10 @@
#include <crm_internal.h>
#include "pacemakerd.h"
+#if SUPPORT_COROSYNC
+#include "pcmkd_corosync.h"
+#endif
+
#include <pwd.h>
#include <errno.h>
#include <unistd.h>
@@ -21,8 +25,8 @@
#include <sys/resource.h>
#include <crm/crm.h> /* indirectly: CRM_EX_* */
-#include <crm/msg_xml.h>
#include <crm/common/mainloop.h>
+#include <crm/common/xml.h>
#include <crm/common/cmdline_internal.h>
#include <crm/common/ipc_pacemakerd.h>
#include <crm/common/output_internal.h>
@@ -60,19 +64,21 @@ static int
pacemakerd_features_xml(pcmk__output_t *out, va_list args) {
gchar **feature_list = g_strsplit(CRM_FEATURES, " ", 0);
- pcmk__output_xml_create_parent(out, "pacemakerd",
- "version", PACEMAKER_VERSION,
- "build", BUILD_VERSION,
- "feature_set", CRM_FEATURE_SET,
+ pcmk__output_xml_create_parent(out, PCMK_XE_PACEMAKERD,
+ PCMK_XA_VERSION, PACEMAKER_VERSION,
+ PCMK_XA_BUILD, BUILD_VERSION,
+ PCMK_XA_FEATURE_SET, CRM_FEATURE_SET,
NULL);
- out->begin_list(out, NULL, NULL, "features");
+ out->begin_list(out, NULL, NULL, PCMK_XE_FEATURES);
for (char **s = feature_list; *s != NULL; s++) {
- pcmk__output_create_xml_text_node(out, "feature", *s);
+ pcmk__output_create_xml_text_node(out, PCMK_XE_FEATURE, *s);
}
out->end_list(out);
+ pcmk__output_xml_pop_parent(out);
+
g_strfreev(feature_list);
return pcmk_rc_ok;
}
@@ -92,7 +98,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(PCMK__ENV_NODE_START_STATE, "standby", false);
+ pcmk__set_env_option(PCMK__ENV_NODE_START_STATE, PCMK_VALUE_STANDBY, false);
return TRUE;
}
@@ -297,8 +303,6 @@ main(int argc, char **argv)
goto done;
}
- pcmk__force_args(context, &error, "%s --xml-simple-list", g_get_prgname());
-
pcmk__register_messages(out, fmt_functions);
if (options.features) {
@@ -313,7 +317,7 @@ main(int argc, char **argv)
}
// @COMPAT Drop at 3.0.0; likely last used in 1.1.24
- pcmk__set_env_option(PCMK__ENV_MCP, "true", true);
+ pcmk__set_env_option(PCMK__ENV_MCP, PCMK_VALUE_TRUE, true);
if (options.shutdown) {
pcmk__cli_init_logging("pacemakerd", args->verbosity);
@@ -402,7 +406,7 @@ main(int argc, char **argv)
{
const char *facility = pcmk__env_option(PCMK__ENV_LOGFACILITY);
- if (!pcmk__str_eq(facility, PCMK__VALUE_NONE,
+ if (!pcmk__str_eq(facility, PCMK_VALUE_NONE,
pcmk__str_casei|pcmk__str_null_matches)) {
pcmk__set_env_option("LOGFACILITY", facility, true);
}
@@ -444,7 +448,7 @@ main(int argc, char **argv)
if ((running_with_sbd) && pcmk__get_sbd_sync_resource_startup()) {
crm_notice("Waiting for startup-trigger from SBD.");
- pacemakerd_state = XML_PING_ATTR_PACEMAKERDSTATE_WAITPING;
+ pacemakerd_state = PCMK__VALUE_WAIT_FOR_PING;
startup_trigger = mainloop_add_trigger(G_PRIORITY_HIGH, init_children_processes, NULL);
} else {
if (running_with_sbd) {
@@ -452,7 +456,7 @@ main(int argc, char **argv)
"by your SBD version) improve reliability of "
"interworking between SBD & pacemaker.");
}
- pacemakerd_state = XML_PING_ATTR_PACEMAKERDSTATE_STARTINGDAEMONS;
+ pacemakerd_state = PCMK__VALUE_STARTING_DAEMONS;
init_children_processes(NULL);
}
diff --git a/daemons/pacemakerd/pacemakerd.h b/daemons/pacemakerd/pacemakerd.h
index ee6facf..51e32b1 100644
--- a/daemons/pacemakerd/pacemakerd.h
+++ b/daemons/pacemakerd/pacemakerd.h
@@ -9,27 +9,19 @@
#include <crm_internal.h>
-#include <stdint.h>
-
#define MAX_RESPAWN 100
extern GMainLoop *mainloop;
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;
extern gboolean shutdown_complete_state_reported_client_closed;
+extern unsigned int shutdown_complete_state_reported_to;
extern crm_trigger_t *shutdown_trigger;
extern crm_trigger_t *startup_trigger;
extern time_t subdaemon_check_progress;
-gboolean pacemakerd_read_config(void);
-
-gboolean cluster_connect_cfg(void);
-void cluster_disconnect_cfg(void);
int find_and_track_existing_processes(void);
gboolean init_children_processes(void *user_data);
-void restart_cluster_subdaemons(void);
void pcmk_shutdown(int nsig);
-void pcmkd_shutdown_corosync(void);
-bool pcmkd_corosync_connected(void);
+void restart_cluster_subdaemons(void);
diff --git a/daemons/pacemakerd/pcmkd_corosync.c b/daemons/pacemakerd/pcmkd_corosync.c
index 8a1a867..43f6231 100644
--- a/daemons/pacemakerd/pcmkd_corosync.c
+++ b/daemons/pacemakerd/pcmkd_corosync.c
@@ -9,6 +9,7 @@
#include <crm_internal.h>
#include "pacemakerd.h"
+#include "pcmkd_corosync.h"
#include <sys/utsname.h>
#include <sys/stat.h> /* for calls to stat() */
@@ -271,7 +272,8 @@ pacemakerd_read_config(void)
gid_t found_gid = 0;
pid_t found_pid = 0;
int rv;
- enum cluster_type_e stack;
+ enum pcmk_cluster_layer cluster_layer = pcmk_cluster_layer_unknown;
+ const char *cluster_layer_s = NULL;
// There can be only one possibility
do {
@@ -318,19 +320,21 @@ pacemakerd_read_config(void)
return FALSE;
}
- stack = get_cluster_type();
- if (stack != pcmk_cluster_corosync) {
+ cluster_layer = pcmk_get_cluster_layer();
+ cluster_layer_s = pcmk_cluster_layer_text(cluster_layer);
+
+ if (cluster_layer != pcmk_cluster_layer_corosync) {
crm_crit("Expected Corosync cluster layer but detected %s "
- CRM_XS " stack=%d", name_for_cluster_type(stack), stack);
+ CRM_XS " cluster_layer=%d",
+ cluster_layer_s, cluster_layer);
return FALSE;
}
- crm_info("Reading configuration for %s stack",
- name_for_cluster_type(stack));
- pcmk__set_env_option(PCMK__ENV_CLUSTER_TYPE, "corosync", true);
+ crm_info("Reading configuration for %s cluster layer", cluster_layer_s);
+ pcmk__set_env_option(PCMK__ENV_CLUSTER_TYPE, PCMK_VALUE_COROSYNC, true);
// @COMPAT Drop at 3.0.0; added unused in 1.1.9
- pcmk__set_env_option(PCMK__ENV_QUORUM_TYPE, "corosync", true);
+ pcmk__set_env_option(PCMK__ENV_QUORUM_TYPE, PCMK_VALUE_COROSYNC, true);
// If debug logging is not configured, check whether corosync has it
if (pcmk__env_option(PCMK__ENV_DEBUG) == NULL) {
diff --git a/daemons/pacemakerd/pcmkd_corosync.h b/daemons/pacemakerd/pcmkd_corosync.h
new file mode 100644
index 0000000..8c4a1e1
--- /dev/null
+++ b/daemons/pacemakerd/pcmkd_corosync.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2010-2023 the Pacemaker project contributors
+ *
+ * The version control history for this file may have further details.
+ *
+ * This source code is licensed under the GNU General Public License version 2
+ * or later (GPLv2+) WITHOUT ANY WARRANTY.
+ */
+
+#include <crm_internal.h>
+
+gboolean cluster_connect_cfg(void);
+void cluster_disconnect_cfg(void);
+gboolean pacemakerd_read_config(void);
+bool pcmkd_corosync_connected(void);
+void pcmkd_shutdown_corosync(void);
diff --git a/daemons/pacemakerd/pcmkd_messages.c b/daemons/pacemakerd/pcmkd_messages.c
index 4e6f822..9837d5a 100644
--- a/daemons/pacemakerd/pcmkd_messages.c
+++ b/daemons/pacemakerd/pcmkd_messages.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2022 the Pacemaker project contributors
+ * Copyright 2010-2024 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
@@ -11,7 +11,7 @@
#include "pacemakerd.h"
#include <crm/crm.h>
-#include <crm/msg_xml.h>
+#include <crm/common/xml.h>
#include <errno.h>
#include <stdbool.h>
@@ -30,7 +30,7 @@ handle_node_cache_request(pcmk__request_t *request)
pcmk__client_name(request->ipc_client));
pcmk__ipc_send_ack(request->ipc_client, request->ipc_id, request->ipc_flags,
- "ack", NULL, CRM_EX_OK);
+ PCMK__XE_ACK, NULL, CRM_EX_OK);
return NULL;
}
@@ -42,23 +42,24 @@ handle_ping_request(pcmk__request_t *request)
const char *value = NULL;
xmlNode *ping = NULL;
xmlNode *reply = NULL;
- const char *from = crm_element_value(msg, F_CRM_SYS_FROM);
+ const char *from = crm_element_value(msg, PCMK__XA_CRM_SYS_FROM);
/* Pinged for status */
- crm_trace("Pinged from " F_CRM_SYS_FROM "='%s' " F_CRM_ORIGIN "='%s'",
+ crm_trace("Pinged from " PCMK__XA_CRM_SYS_FROM "='%s' "
+ PCMK_XA_ORIGIN "='%s'",
pcmk__s(from, ""),
- pcmk__s(crm_element_value(msg, F_CRM_ORIGIN), ""));
+ pcmk__s(crm_element_value(msg, PCMK_XA_ORIGIN), ""));
pcmk__ipc_send_ack(request->ipc_client, request->ipc_id, request->ipc_flags,
- "ack", NULL, CRM_EX_INDETERMINATE);
+ PCMK__XE_ACK, NULL, CRM_EX_INDETERMINATE);
- ping = create_xml_node(NULL, XML_CRM_TAG_PING);
- value = crm_element_value(msg, F_CRM_SYS_TO);
- crm_xml_add(ping, XML_PING_ATTR_SYSFROM, value);
- crm_xml_add(ping, XML_PING_ATTR_PACEMAKERDSTATE, pacemakerd_state);
- crm_xml_add_ll(ping, XML_ATTR_TSTAMP,
+ ping = pcmk__xe_create(NULL, PCMK__XE_PING_RESPONSE);
+ value = crm_element_value(msg, PCMK__XA_CRM_SYS_TO);
+ crm_xml_add(ping, PCMK__XA_CRM_SUBSYSTEM, value);
+ crm_xml_add(ping, PCMK__XA_PACEMAKERD_STATE, pacemakerd_state);
+ crm_xml_add_ll(ping, PCMK_XA_CRM_TIMESTAMP,
(long long) subdaemon_check_progress);
- crm_xml_add(ping, XML_PING_ATTR_STATUS, "ok");
+ crm_xml_add(ping, PCMK_XA_RESULT, "ok");
reply = create_reply(msg, ping);
free_xml(ping);
@@ -73,16 +74,18 @@ handle_ping_request(pcmk__request_t *request)
/* just proceed state on sbd pinging us */
if (from && strstr(from, "sbd")) {
- if (pcmk__str_eq(pacemakerd_state, XML_PING_ATTR_PACEMAKERDSTATE_SHUTDOWNCOMPLETE, pcmk__str_none)) {
+ if (pcmk__str_eq(pacemakerd_state, PCMK__VALUE_SHUTDOWN_COMPLETE,
+ pcmk__str_none)) {
if (pcmk__get_sbd_sync_resource_startup()) {
crm_notice("Shutdown-complete-state passed to SBD.");
}
shutdown_complete_state_reported_to = request->ipc_client->pid;
- } else if (pcmk__str_eq(pacemakerd_state, XML_PING_ATTR_PACEMAKERDSTATE_WAITPING, pcmk__str_none)) {
+ } else if (pcmk__str_eq(pacemakerd_state, PCMK__VALUE_WAIT_FOR_PING,
+ pcmk__str_none)) {
crm_notice("Received startup-trigger from SBD.");
- pacemakerd_state = XML_PING_ATTR_PACEMAKERDSTATE_STARTINGDAEMONS;
+ pacemakerd_state = PCMK__VALUE_STARTING_DAEMONS;
mainloop_set_trigger(startup_trigger);
}
}
@@ -105,19 +108,19 @@ handle_shutdown_request(pcmk__request_t *request)
bool allowed = pcmk_is_set(request->ipc_client->flags, pcmk__client_privileged);
pcmk__ipc_send_ack(request->ipc_client, request->ipc_id, request->ipc_flags,
- "ack", NULL, CRM_EX_INDETERMINATE);
+ PCMK__XE_ACK, NULL, CRM_EX_INDETERMINATE);
- shutdown = create_xml_node(NULL, XML_CIB_ATTR_SHUTDOWN);
+ shutdown = pcmk__xe_create(NULL, PCMK__XE_SHUTDOWN);
if (allowed) {
crm_notice("Shutting down in response to IPC request %s from %s",
- crm_element_value(msg, F_CRM_REFERENCE),
- crm_element_value(msg, F_CRM_ORIGIN));
- crm_xml_add_int(shutdown, XML_LRM_ATTR_OPSTATUS, CRM_EX_OK);
+ crm_element_value(msg, PCMK_XA_REFERENCE),
+ crm_element_value(msg, PCMK_XA_ORIGIN));
+ crm_xml_add_int(shutdown, PCMK__XA_OP_STATUS, CRM_EX_OK);
} else {
crm_warn("Ignoring shutdown request from unprivileged client %s",
pcmk__client_name(request->ipc_client));
- crm_xml_add_int(shutdown, XML_LRM_ATTR_OPSTATUS, CRM_EX_INSUFFICIENT_PRIV);
+ crm_xml_add_int(shutdown, PCMK__XA_OP_STATUS, CRM_EX_INSUFFICIENT_PRIV);
}
reply = create_reply(msg, shutdown);
@@ -142,7 +145,7 @@ static xmlNode *
handle_unknown_request(pcmk__request_t *request)
{
pcmk__ipc_send_ack(request->ipc_client, request->ipc_id, request->ipc_flags,
- "ack", NULL, CRM_EX_INVALID_PARAM);
+ PCMK__XE_ACK, NULL, CRM_EX_INVALID_PARAM);
pcmk__format_result(&request->result, CRM_EX_PROTOCOL, PCMK_EXEC_INVALID,
"Unknown IPC request type '%s' (bug?)",
@@ -168,7 +171,7 @@ pcmk_ipc_accept(qb_ipcs_connection_t * c, uid_t uid, gid_t gid)
{
crm_trace("Connection %p", c);
if (pcmk__new_client(c, uid, gid) == NULL) {
- return -EIO;
+ return -ENOMEM;
}
return 0;
}
@@ -217,7 +220,7 @@ pcmk_ipc_dispatch(qb_ipcs_connection_t * qbc, void *data, size_t size)
msg = pcmk__client_data2xml(c, data, &id, &flags);
if (msg == NULL) {
- pcmk__ipc_send_ack(c, id, flags, "ack", NULL, CRM_EX_PROTOCOL);
+ pcmk__ipc_send_ack(c, id, flags, PCMK__XE_ACK, NULL, CRM_EX_PROTOCOL);
return 0;
} else {
@@ -235,7 +238,7 @@ pcmk_ipc_dispatch(qb_ipcs_connection_t * qbc, void *data, size_t size)
.result = PCMK__UNKNOWN_RESULT,
};
- request.op = crm_element_value_copy(request.xml, F_CRM_TASK);
+ request.op = crm_element_value_copy(request.xml, PCMK__XA_CRM_TASK);
CRM_CHECK(request.op != NULL, return 0);
reply = pcmk__process_request(&request, pcmkd_handlers);
diff --git a/daemons/pacemakerd/pcmkd_subdaemons.c b/daemons/pacemakerd/pcmkd_subdaemons.c
index 21e432e..5bd3512 100644
--- a/daemons/pacemakerd/pcmkd_subdaemons.c
+++ b/daemons/pacemakerd/pcmkd_subdaemons.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2023 the Pacemaker project contributors
+ * Copyright 2010-2024 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
@@ -10,6 +10,10 @@
#include <crm_internal.h>
#include "pacemakerd.h"
+#if SUPPORT_COROSYNC
+#include "pcmkd_corosync.h"
+#endif
+
#include <errno.h>
#include <grp.h>
#include <signal.h>
@@ -21,22 +25,25 @@
#include <unistd.h>
#include <crm/cluster.h>
-#include <crm/msg_xml.h>
+#include <crm/common/xml.h>
+
+enum child_daemon_flags {
+ child_none = 0,
+ child_respawn = 1 << 0,
+ child_needs_cluster = 1 << 1,
+ child_needs_retry = 1 << 2,
+ child_active_before_startup = 1 << 3,
+};
typedef struct pcmk_child_s {
pid_t pid;
int respawn_count;
- bool respawn;
const char *name;
const char *uid;
const char *command;
const char *endpoint; /* IPC server name */
- bool needs_cluster;
int check_count;
-
- /* Anything below here will be dynamically initialized */
- bool needs_retry;
- bool active_before_startup;
+ uint32_t flags;
} pcmk_child_t;
#define PCMK_PROCESS_CHECK_INTERVAL 1
@@ -48,34 +55,34 @@ typedef struct pcmk_child_s {
static pcmk_child_t pcmk_children[] = {
{
- 0, 0, true, "pacemaker-based", CRM_DAEMON_USER,
+ 0, 0, "pacemaker-based", CRM_DAEMON_USER,
CRM_DAEMON_DIR "/pacemaker-based", PCMK__SERVER_BASED_RO,
- true
+ 0, child_respawn | child_needs_cluster
},
{
- 0, 0, true, "pacemaker-fenced", NULL,
+ 0, 0, "pacemaker-fenced", NULL,
CRM_DAEMON_DIR "/pacemaker-fenced", "stonith-ng",
- true
+ 0, child_respawn | child_needs_cluster
},
{
- 0, 0, true, "pacemaker-execd", NULL,
+ 0, 0, "pacemaker-execd", NULL,
CRM_DAEMON_DIR "/pacemaker-execd", CRM_SYSTEM_LRMD,
- false
+ 0, child_respawn
},
{
- 0, 0, true, "pacemaker-attrd", CRM_DAEMON_USER,
- CRM_DAEMON_DIR "/pacemaker-attrd", T_ATTRD,
- true
+ 0, 0, "pacemaker-attrd", CRM_DAEMON_USER,
+ CRM_DAEMON_DIR "/pacemaker-attrd", PCMK__VALUE_ATTRD,
+ 0, child_respawn | child_needs_cluster
},
{
- 0, 0, true, "pacemaker-schedulerd", CRM_DAEMON_USER,
+ 0, 0, "pacemaker-schedulerd", CRM_DAEMON_USER,
CRM_DAEMON_DIR "/pacemaker-schedulerd", CRM_SYSTEM_PENGINE,
- false
+ 0, child_respawn
},
{
- 0, 0, true, "pacemaker-controld", CRM_DAEMON_USER,
+ 0, 0, "pacemaker-controld", CRM_DAEMON_USER,
CRM_DAEMON_DIR "/pacemaker-controld", CRM_SYSTEM_CRMD,
- true
+ 0, child_respawn | child_needs_cluster
},
};
@@ -103,7 +110,7 @@ unsigned int shutdown_complete_state_reported_to = 0;
gboolean shutdown_complete_state_reported_client_closed = FALSE;
/* state we report when asked via pacemakerd-api status-ping */
-const char *pacemakerd_state = XML_PING_ATTR_PACEMAKERDSTATE_INIT;
+const char *pacemakerd_state = PCMK__VALUE_INIT;
gboolean running_with_sbd = FALSE; /* local copy */
GMainLoop *mainloop = NULL;
@@ -154,7 +161,7 @@ check_next_subdaemon(gpointer user_data)
pcmk_children[next_child].pid),
pcmk_children[next_child].check_count);
stop_child(&pcmk_children[next_child], SIGKILL);
- if (pcmk_children[next_child].respawn) {
+ if (pcmk_is_set(pcmk_children[next_child].flags, child_respawn)) {
/* as long as the respawn-limit isn't reached
give it another round of check retries
*/
@@ -166,7 +173,7 @@ check_next_subdaemon(gpointer user_data)
(long long) PCMK__SPECIAL_PID_AS_0(
pcmk_children[next_child].pid),
pcmk_children[next_child].check_count);
- if (pcmk_children[next_child].respawn) {
+ if (pcmk_is_set(pcmk_children[next_child].flags, child_respawn)) {
/* as long as the respawn-limit isn't reached
and we haven't run out of connect retries
we account this as progress we are willing
@@ -180,7 +187,7 @@ check_next_subdaemon(gpointer user_data)
*/
break;
case pcmk_rc_ipc_unresponsive:
- if (!pcmk_children[next_child].respawn) {
+ if (!pcmk_is_set(pcmk_children[next_child].flags, child_respawn)) {
/* if a subdaemon is down and we don't want it
to be restarted this is a success during
shutdown. if it isn't restarted anymore
@@ -191,7 +198,7 @@ check_next_subdaemon(gpointer user_data)
subdaemon_check_progress = time(NULL);
}
}
- if (!pcmk_children[next_child].active_before_startup) {
+ if (!pcmk_is_set(pcmk_children[next_child].flags, child_active_before_startup)) {
crm_trace("found %s[%lld] missing - signal-handler "
"will take care of it",
pcmk_children[next_child].name,
@@ -199,7 +206,7 @@ check_next_subdaemon(gpointer user_data)
pcmk_children[next_child].pid));
break;
}
- if (pcmk_children[next_child].respawn) {
+ if (pcmk_is_set(pcmk_children[next_child].flags, child_respawn)) {
crm_err("%s[%lld] terminated",
pcmk_children[next_child].name,
(long long) PCMK__SPECIAL_PID_AS_0(
@@ -264,14 +271,14 @@ pcmk_child_exit(mainloop_child_t * p, pid_t pid, int core, int signo, int exitco
case CRM_EX_FATAL:
crm_warn("Shutting cluster down because %s[%d] had fatal failure",
name, pid);
- child->respawn = false;
+ child->flags &= ~child_respawn;
fatal_error = TRUE;
pcmk_shutdown(SIGTERM);
break;
case CRM_EX_PANIC:
crm_emerg("%s[%d] instructed the machine to reset", name, pid);
- child->respawn = false;
+ child->flags &= ~child_respawn;
fatal_error = TRUE;
pcmk__panic(__func__);
pcmk_shutdown(SIGTERM);
@@ -291,20 +298,20 @@ static void
pcmk_process_exit(pcmk_child_t * child)
{
child->pid = 0;
- child->active_before_startup = false;
+ child->flags &= ~child_active_before_startup;
child->check_count = 0;
child->respawn_count += 1;
if (child->respawn_count > MAX_RESPAWN) {
crm_err("Child respawn count exceeded by %s", child->name);
- child->respawn = false;
+ child->flags &= ~child_respawn;
}
if (shutdown_trigger) {
/* resume step-wise shutdown (returned TRUE yields no parallelizing) */
mainloop_set_trigger(shutdown_trigger);
- } else if (!child->respawn) {
+ } else if (!pcmk_is_set(child->flags, child_respawn)) {
/* nothing to do */
} else if (crm_is_true(pcmk__env_option(PCMK__ENV_FAIL_FAST))) {
@@ -316,10 +323,10 @@ pcmk_process_exit(pcmk_child_t * child)
" appears alright per %s IPC end-point",
child->name, child->endpoint);
- } else if (child->needs_cluster && !pcmkd_cluster_connected()) {
+ } else if (pcmk_is_set(child->flags, child_needs_cluster) && !pcmkd_cluster_connected()) {
crm_notice("Not respawning %s subdaemon until cluster returns",
child->name);
- child->needs_retry = true;
+ child->flags |= child_needs_retry;
} else {
crm_notice("Respawning %s subdaemon after unexpected exit",
@@ -336,7 +343,7 @@ pcmk_shutdown_worker(gpointer user_data)
if (phase == PCMK__NELEM(pcmk_children) - 1) {
crm_notice("Shutting down Pacemaker");
- pacemakerd_state = XML_PING_ATTR_PACEMAKERDSTATE_SHUTTINGDOWN;
+ pacemakerd_state = PCMK__VALUE_SHUTTING_DOWN;
}
for (; phase >= 0; phase--) {
@@ -345,7 +352,7 @@ pcmk_shutdown_worker(gpointer user_data)
if (child->pid != 0) {
time_t now = time(NULL);
- if (child->respawn) {
+ if (pcmk_is_set(child->flags, child_respawn)) {
if (child->pid == PCMK__SPECIAL_PID) {
crm_warn("The process behind %s IPC cannot be"
" terminated, so either wait the graceful"
@@ -359,7 +366,7 @@ pcmk_shutdown_worker(gpointer user_data)
child->command);
}
next_log = now + 30;
- child->respawn = false;
+ child->flags &= ~child_respawn;
stop_child(child, SIGTERM);
if (phase < PCMK_CHILD_CONTROLD) {
g_timeout_add(SHUTDOWN_ESCALATION_PERIOD,
@@ -381,7 +388,7 @@ pcmk_shutdown_worker(gpointer user_data)
}
crm_notice("Shutdown complete");
- pacemakerd_state = XML_PING_ATTR_PACEMAKERDSTATE_SHUTDOWNCOMPLETE;
+ pacemakerd_state = PCMK__VALUE_SHUTDOWN_COMPLETE;
if (!fatal_error && running_with_sbd &&
pcmk__get_sbd_sync_resource_startup() &&
!shutdown_complete_state_reported_client_closed) {
@@ -393,8 +400,12 @@ pcmk_shutdown_worker(gpointer user_data)
{
const char *delay = pcmk__env_option(PCMK__ENV_SHUTDOWN_DELAY);
if(delay) {
+ long long delay_ms = crm_get_msec(delay);
+
sync();
- pcmk__sleep_ms(crm_get_msec(delay));
+ if (delay_ms > 0) {
+ pcmk__sleep_ms((unsigned int) QB_MIN(delay_ms, UINT_MAX));
+ }
}
}
@@ -427,7 +438,7 @@ start_child(pcmk_child_t * child)
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->flags &= ~child_active_before_startup;
child->check_count = 0;
if (child->command == NULL) {
@@ -481,19 +492,20 @@ start_child(pcmk_child_t * child)
(void)setsid();
/* Setup the two alternate arg arrays */
- opts_vgrind[0] = strdup(VALGRIND_BIN);
+ opts_vgrind[0] = pcmk__str_copy(VALGRIND_BIN);
if (use_callgrind) {
- opts_vgrind[1] = strdup("--tool=callgrind");
- opts_vgrind[2] = strdup("--callgrind-out-file=" CRM_STATE_DIR "/callgrind.out.%p");
- opts_vgrind[3] = strdup(child->command);
+ opts_vgrind[1] = pcmk__str_copy("--tool=callgrind");
+ opts_vgrind[2] = pcmk__str_copy("--callgrind-out-file="
+ CRM_STATE_DIR "/callgrind.out.%p");
+ opts_vgrind[3] = pcmk__str_copy(child->command);
opts_vgrind[4] = NULL;
} else {
- opts_vgrind[1] = strdup(child->command);
+ opts_vgrind[1] = pcmk__str_copy(child->command);
opts_vgrind[2] = NULL;
opts_vgrind[3] = NULL;
opts_vgrind[4] = NULL;
}
- opts_default[0] = strdup(child->command);
+ opts_default[0] = pcmk__str_copy(child->command);
if(gid) {
// Drop root group access if not needed
@@ -759,7 +771,7 @@ find_and_track_existing_processes(void)
(long long) PCMK__SPECIAL_PID_AS_0(
pcmk_children[i].pid));
pcmk_children[i].respawn_count = -1; /* 0~keep watching */
- pcmk_children[i].active_before_startup = true;
+ pcmk_children[i].flags |= child_active_before_startup;
break;
case pcmk_rc_ipc_pid_only:
if (pcmk_children[i].respawn_count == WAIT_TRIES) {
@@ -802,7 +814,7 @@ find_and_track_existing_processes(void)
gboolean
init_children_processes(void *user_data)
{
- if (is_corosync_cluster()) {
+ if (pcmk_get_cluster_layer() == pcmk_cluster_layer_corosync) {
/* Corosync clusters can drop root group access, because we set
* uidgid.gid.${gid}=1 via CMAP, which allows these processes to connect
* to corosync.
@@ -825,8 +837,8 @@ init_children_processes(void *user_data)
*
* This may be useful for the daemons to know
*/
- pcmk__set_env_option(PCMK__ENV_RESPAWNED, "true", false);
- pacemakerd_state = XML_PING_ATTR_PACEMAKERDSTATE_RUNNING;
+ pcmk__set_env_option(PCMK__ENV_RESPAWNED, PCMK_VALUE_TRUE, false);
+ pacemakerd_state = PCMK__VALUE_RUNNING;
return TRUE;
}
@@ -843,13 +855,13 @@ void
restart_cluster_subdaemons(void)
{
for (int i = 0; i < PCMK__NELEM(pcmk_children); i++) {
- if (!pcmk_children[i].needs_retry || pcmk_children[i].pid != 0) {
+ if (!pcmk_is_set(pcmk_children[i].flags, child_needs_retry) || pcmk_children[i].pid != 0) {
continue;
}
crm_notice("Respawning cluster-based subdaemon: %s", pcmk_children[i].name);
if (start_child(&pcmk_children[i])) {
- pcmk_children[i].needs_retry = false;
+ pcmk_children[i].flags &= ~child_needs_retry;
}
}
}