Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8867d48
Refactor: various: Drop cluster/internal.h includes from .c files
nrwahl2 Jul 23, 2026
6b63bca
Refactor: various: Don't include cluster/election_internal.h directly
nrwahl2 Jul 23, 2026
a16fb66
Refactor: various: Drop common/internal.h includes from .c files
nrwahl2 Jul 23, 2026
7d016f5
Refactor: based: Clean up shutdown logic
nrwahl2 Jan 11, 2026
b0aa2d9
Refactor: based: based_cib should always be non-NULL after init now
nrwahl2 Jan 14, 2026
56f7ded
Refactor: controller: Don't set mainloop to NULL in crmd_exit()
nrwahl2 Jul 23, 2026
5a22496
Refactor: various: Unref main loop consistently
nrwahl2 Jan 11, 2026
05166f4
Refactor: attrd: Drop mainloop_destroy_signal() from attrd_shutdown()
nrwahl2 Jan 11, 2026
536e4b9
Refactor: attrd: Assume main loop is running in attrd_shutdown()
nrwahl2 Jan 11, 2026
cc1ab8a
Refactor: based: Don't init node caches explicitly
nrwahl2 Jan 11, 2026
19a6288
Refactor: based: Drop based_peer_callback()
nrwahl2 Jan 11, 2026
6d0e08c
API: libcib: Deprecate cib_query and cib_connected_query
nrwahl2 Jan 11, 2026
dc7089b
Refactor: remoted: Drop cib_proxy_accept_ro()
nrwahl2 Jan 11, 2026
7be7e4f
Refactor: based: Check for old PCMK__SERVER_BASED_RW instance
nrwahl2 Jan 11, 2026
c17d49f
Refactor: based: Make PCMK__SERVER_BASED_RO behave like _RW
nrwahl2 Jan 11, 2026
60391d9
Refactor: based: Drop privileged argument of based_process_request()
nrwahl2 Jan 11, 2026
f773a3c
Refactor: libcib: Drop cib__op_attr_privileged
nrwahl2 Jan 11, 2026
d04c239
Refactor: liblrmd: Map proxied PCMK__SERVER_BASED_RO clients to _RW
nrwahl2 Jan 11, 2026
1439265
Refactor: libcrmcommon: pcmk__serve_based_ipc() starts only one server
nrwahl2 Jan 12, 2026
635374e
Refactor: based: Standardize based_cpg_dispatch()
nrwahl2 Jan 12, 2026
2652d38
Refactor: libcib: Drop unnecessary rc check in cib_native_signon()
nrwahl2 Jul 23, 2026
95611f7
Refactor: libcib: Unindent some of cib_native_signon()
nrwahl2 Jul 23, 2026
6279154
Refactor: libcib: Unindent more of cib_native_signon()
nrwahl2 Jul 23, 2026
1b431b7
Refactor: libcib: Unindent one more block of cib_native_signon()
nrwahl2 Jul 23, 2026
88c713b
Refactor: libcib: Compare CRM_OP_REGISTER case-sensitively
nrwahl2 Jul 23, 2026
e8ceff8
Feature: libcib: Ignore name argument of cib_api_operations_t:signon()
nrwahl2 Jul 23, 2026
b63210d
Feature: libcib: Don't set cib_t:type
nrwahl2 Jul 23, 2026
cd3ed6e
API: libcib: Deprecate cib_no_connection
nrwahl2 Jul 23, 2026
f4c78cc
Feature: libcib: Ignore type argument of signon method for native client
nrwahl2 Jul 23, 2026
b391967
API: libcib: Deprecate enum cib_conn_type
nrwahl2 Jul 23, 2026
97fb8b3
Refactor: libcib: Clean up the end of cib_native_signon()
nrwahl2 Jul 23, 2026
adbf9fd
Refactor: based: goto cleanup consistently in based_ipc_dispatch()
nrwahl2 Jul 24, 2026
2147d3f
Refactor: various: Use pcmk__is_set() and friends in more places
nrwahl2 Jul 24, 2026
e8c609b
Refactor: based: Add extra XML attrs only before based_process_request()
nrwahl2 Jul 24, 2026
5a4a4ef
Low: based: Ignore requests from unregistered clients
nrwahl2 Jul 24, 2026
fc7061d
Refactor: based: Standardize based_ipc_dispatch()
nrwahl2 Jan 12, 2026
e985f33
Refactor: libcrmcommon: Assert non-NULL args in pcmk__serve_execd_ipc()
nrwahl2 Jul 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions daemons/attrd/attrd_alerts.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
*/

#include <crm_internal.h>

#include <crm/crm.h>
#include <crm/cib/internal.h>
#include <crm/cluster/internal.h>
#include <crm/cluster/election_internal.h>
#include <crm/common/xml.h>
#include <crm/lrmd_internal.h>

#include "pacemaker-attrd.h"

static GList *attrd_alert_list = NULL;
Expand Down
1 change: 0 additions & 1 deletion daemons/attrd/attrd_cib.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <crm/common/logging.h>
#include <crm/common/results.h>
#include <crm/common/xml.h>
#include <crm/cluster/internal.h> // pcmk__get_node()

#include "pacemaker-attrd.h"

Expand Down
1 change: 0 additions & 1 deletion daemons/attrd/attrd_corosync.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <stdlib.h>

#include <crm/cluster.h>
#include <crm/cluster/internal.h>
#include <crm/common/logging.h>
#include <crm/common/results.h>
#include <crm/common/xml.h>
Expand Down
1 change: 0 additions & 1 deletion daemons/attrd/attrd_elections.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <stdbool.h>

#include <crm/cluster.h>
#include <crm/cluster/election_internal.h>
#include <crm/common/xml.h>

#include "pacemaker-attrd.h"
Expand Down
1 change: 0 additions & 1 deletion daemons/attrd/attrd_ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <sys/types.h>

#include <crm/cluster.h>
#include <crm/cluster/internal.h>
#include <crm/common/logging.h>
#include <crm/common/results.h>
#include <crm/common/util.h>
Expand Down
1 change: 0 additions & 1 deletion daemons/attrd/attrd_messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include <glib.h>

#include <crm/cluster/internal.h> // pcmk__get_node()
#include <crm/common/xml.h>

#include "pacemaker-attrd.h"
Expand Down
23 changes: 6 additions & 17 deletions daemons/attrd/attrd_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,16 @@ attrd_shutdown(int nsig)
// Tell various functions not to do anthing
shutting_down = true;

// Don't respond to signals while shutting down
mainloop_destroy_signal(SIGTERM);
mainloop_destroy_signal(SIGCHLD);
mainloop_destroy_signal(SIGPIPE);
mainloop_destroy_signal(SIGUSR1);
mainloop_destroy_signal(SIGUSR2);
mainloop_destroy_signal(SIGTRAP);

attrd_free_waitlist();
attrd_free_confirmations();

g_clear_pointer(&peer_protocol_vers, g_hash_table_destroy);

if ((mloop == NULL) || !g_main_loop_is_running(mloop)) {
/* If there's no main loop active, just exit. This should be possible
* only if we get SIGTERM in brief windows at start-up and shutdown.
*/
crm_exit(CRM_EX_OK);
} else {
g_main_loop_quit(mloop);
g_main_loop_unref(mloop);
}
// There should be no way to get here without the main loop running
CRM_CHECK((mloop != NULL) && g_main_loop_is_running(mloop),
crm_exit(CRM_EX_OK));

g_main_loop_quit(mloop);
}

/*!
Expand All @@ -99,6 +87,7 @@ void
attrd_run_mainloop(void)
{
g_main_loop_run(mloop);
g_clear_pointer(&mloop, g_main_loop_unref);
}

/* strlen("value") */
Expand Down
1 change: 0 additions & 1 deletion daemons/attrd/pacemaker-attrd.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <crm/common/iso8601.h>
#include <crm/common/ipc.h>
#include <crm/common/xml.h>
#include <crm/cluster/internal.h>

#include "pacemaker-attrd.h"

Expand Down
2 changes: 1 addition & 1 deletion daemons/attrd/pacemaker-attrd.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <crm/crm.h>
#include <crm/cluster.h>
#include <crm/cluster/election_internal.h>
#include <crm/cluster/internal.h>
#include <crm/common/internal.h>
#include <crm/cib/cib_types.h>

Expand Down
40 changes: 17 additions & 23 deletions daemons/based/based_callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

#include <crm/cib.h> // cib_call_options values
#include <crm/cib/internal.h> // cib__*
#include <crm/cluster/internal.h> // pcmk__cluster_send_message
#include <crm/common/internal.h> // pcmk__s, pcmk__str_eq
#include <crm/common/ipc.h> // crm_ipc_*, pcmk_ipc_*
#include <crm/common/logging.h> // CRM_LOG_ASSERT, CRM_CHECK
#include <crm/common/mainloop.h> // mainloop_*
Expand Down Expand Up @@ -69,6 +67,10 @@ digest_timer_cb(void *data)
{
xmlNode *ping = NULL;

if (based_shutting_down()) {
return G_SOURCE_REMOVE;
}

if (!based_get_local_node_dc()) {
// Only the DC sends a ping
return G_SOURCE_REMOVE;
Expand Down Expand Up @@ -615,14 +617,9 @@ log_op_result(const xmlNode *request, const cib__operation_t *operation, int rc,
originator = pcmk__s(originator, "local");
client_name = pcmk__s(client_name, "client");

/* @FIXME based_cib should always be non-NULL, but that's currently not the
* case during shutdown
*/
if (based_cib != NULL) {
pcmk__xe_get_int(based_cib, PCMK_XA_ADMIN_EPOCH, &admin_epoch);
pcmk__xe_get_int(based_cib, PCMK_XA_EPOCH, &epoch);
pcmk__xe_get_int(based_cib, PCMK_XA_NUM_UPDATES, &num_updates);
}
pcmk__xe_get_int(based_cib, PCMK_XA_ADMIN_EPOCH, &admin_epoch);
pcmk__xe_get_int(based_cib, PCMK_XA_EPOCH, &epoch);
pcmk__xe_get_int(based_cib, PCMK_XA_NUM_UPDATES, &num_updates);

do_crm_log(level,
"Completed %s operation for section %s: %s (rc=%d, "
Expand Down Expand Up @@ -659,17 +656,14 @@ send_peer_reply(xmlNode *msg, const char *originator)
* \internal
* \brief Handle an IPC or CPG message containing a request
*
* \param[in,out] request Request XML
* \param[in] privileged If \c true, operations with
* \c cib__op_attr_privileged can be run
* \param[in] client IPC client that sent request (\c NULL if request
* came from CPG)
* \param[in,out] request Request XML
* \param[in] client IPC client that sent request (\c NULL if request came
* from CPG)
*
* \return Standard Pacemaker return code
*/
int
based_process_request(xmlNode *request, bool privileged,
const pcmk__client_t *client)
based_process_request(xmlNode *request, const pcmk__client_t *client)
{
// @TODO: Break into multiple smaller functions
uint32_t call_options = cib_none;
Expand All @@ -696,6 +690,11 @@ based_process_request(xmlNode *request, bool privileged,
xmlNode *output = NULL;
time_t start_time = 0;

if (based_shutting_down()) {
pcmk__info("Ignoring pending CIB request during shutdown");
return ENOTCONN;
}

rc = pcmk__xe_get_flags(request, PCMK__XA_CIB_CALLOPT, &call_options,
cib_none);
if (rc != pcmk_rc_ok) {
Expand Down Expand Up @@ -793,12 +792,7 @@ based_process_request(xmlNode *request, bool privileged,

start_time = time(NULL);

if (!privileged
&& pcmk__is_set(operation->flags, cib__op_attr_privileged)) {

rc = EACCES;

} else if (!pcmk__is_set(operation->flags, cib__op_attr_modifies)) {
if (!pcmk__is_set(operation->flags, cib__op_attr_modifies)) {
rc = cib__perform_op_ro(op_function, request, &based_cib, &output);

} else {
Expand Down
5 changes: 1 addition & 4 deletions daemons/based/based_callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@
#ifndef BASED_CALLBACKS__H
#define BASED_CALLBACKS__H

#include <stdbool.h>

#include <libxml/tree.h> // xmlNode

#include <crm/common/internal.h> // pcmk__client_t

void based_callbacks_init(void);
void based_callbacks_cleanup(void);

int based_process_request(xmlNode *request, bool privileged,
const pcmk__client_t *client);
int based_process_request(xmlNode *request, const pcmk__client_t *client);

#endif // BASED_CALLBACKS__H
89 changes: 60 additions & 29 deletions daemons/based/based_corosync.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <crm_internal.h>

#include <stdbool.h>
#include <inttypes.h> // PRIu32
#include <stddef.h> // NULL, size_t
#include <stdint.h> // uint32_t
#include <stdlib.h> // free
Expand All @@ -20,41 +20,69 @@

#include <crm_config.h> // SUPPORT_COROSYNC
#include <crm/cluster.h> // pcmk_cluster_*
#include <crm/cluster/internal.h> // pcmk__cluster_*, etc.
#include <crm/common/internal.h> // pcmk__err, pcmk__xml_free, etc.
#include <crm/common/results.h> // CRM_EX_DISCONNECT, pcmk_rc_ok

#include "pacemaker-based.h"

static pcmk_cluster_t *cluster = NULL;

static void
based_peer_callback(xmlNode *msg, void *private_data)
based_peer_message(pcmk__node_status_t *peer, xmlNode *xml)
{
const char *reason = NULL;
const char *originator = pcmk__xe_get(msg, PCMK__XA_SRC);

if (pcmk__peer_cache == NULL) {
reason = "membership not established";
goto bail;
}

if (pcmk__xe_get(msg, PCMK__XA_CIB_CLIENTNAME) == NULL) {
pcmk__xe_set(msg, PCMK__XA_CIB_CLIENTNAME, originator);
}

based_process_request(msg, true, NULL);
return;
int rc = pcmk_rc_ok;

bail:
if (reason) {
const char *op = pcmk__xe_get(msg, PCMK__XA_CIB_OP);
if (based_shutting_down()) {
pcmk__info("Ignoring CPG message from %s[%" PRIu32 "] during shutdown",
peer->name, peer->cluster_layer_id);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are inconsistent about logging in this case. You could either make it consistent in this PR (either way - logging or not), or I'll look at it when I get around to merging all this code together.

return;

pcmk__warn("Discarding %s message from %s: %s", op, originator, reason);
} else {
pcmk__request_t request = {
.ipc_client = NULL,
.ipc_id = 0,
.ipc_flags = 0,
Comment thread
nrwahl2 marked this conversation as resolved.
.peer = peer->name,
.xml = xml,
.call_options = cib_none,
Comment thread
nrwahl2 marked this conversation as resolved.
.result = PCMK__UNKNOWN_RESULT,
};

rc = pcmk__xe_get_flags(xml, PCMK__XA_CIB_CALLOPT,
(uint32_t *) &request.call_options, cib_none);
if (rc != pcmk_rc_ok) {
pcmk__warn("Couldn't parse options from request: %s",
pcmk_rc_str(rc));
}

request.op = pcmk__xe_get_copy(request.xml, PCMK__XA_CIB_OP);
CRM_CHECK(request.op != NULL, return);

if (pcmk__is_set(request.call_options, cib_sync_call)) {
pcmk__set_request_flags(&request, pcmk__request_sync);
}

if (pcmk__xe_get(request.xml, PCMK__XA_CIB_CLIENTNAME) == NULL) {
pcmk__xe_set(request.xml, PCMK__XA_CIB_CLIENTNAME,
pcmk__xe_get(request.xml, PCMK__XA_SRC));
}

based_process_request(request.xml, request.ipc_client);
pcmk__reset_request(&request);
}
}

#if SUPPORT_COROSYNC
/*!
* \internal
* \brief Callback for when a peer message is received
*
* \param[in] handle Cluster connection
* \param[in] group_name Group that \p nodeid is a member of
* \param[in] nodeid Peer node that sent \p msg
* \param[in] pid Process that sent \p msg
* \param[in,out] msg Received message
* \param[in] msg_len Length of \p msg
*/
static void
based_cpg_dispatch(cpg_handle_t handle, const struct cpg_name *group_name,
uint32_t nodeid, uint32_t pid, void *msg, size_t msg_len)
Expand All @@ -69,12 +97,15 @@ based_cpg_dispatch(cpg_handle_t handle, const struct cpg_name *group_name,

xml = pcmk__xml_parse(data);
if (xml == NULL) {
pcmk__err("Invalid XML: '%.120s'", data);
free(data);
return;
pcmk__err("Bad message received from %s[%" PRIu32 "]: '%.120s'", from,
nodeid, data);

} else {
pcmk__xe_set(xml, PCMK__XA_SRC, from);
based_peer_message(pcmk__get_node(nodeid, from, NULL,
pcmk__node_search_cluster_member),
xml);
}
pcmk__xe_set(xml, PCMK__XA_SRC, from);
based_peer_callback(xml, NULL);

pcmk__xml_free(xml);
free(data);
Expand All @@ -88,8 +119,8 @@ based_cpg_destroy(void *user_data)
return;
}

pcmk__crit("Exiting immediately after losing connection to cluster layer");
based_terminate(CRM_EX_DISCONNECT);
pcmk__crit("Exiting after losing connection to cluster layer");
based_quit_main_loop(CRM_EX_DISCONNECT);
}
#endif

Expand Down
5 changes: 4 additions & 1 deletion daemons/based/based_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#include <crm/cib/internal.h> // cib_file_*
#include <crm/cib/util.h> // createEmptyCib
#include <crm/common/internal.h> // pcmk__assert_asprintf, PCMK__XE_*, etc.
#include <crm/common/logging.h> // CRM_CHECK
#include <crm/common/mainloop.h> // mainloop_*
#include <crm/common/results.h> // pcmk_legacy2rc, pcmk_rc_*
Expand Down Expand Up @@ -93,6 +92,10 @@ write_cib_async(void *user_data)
pid_t pid = 0;
int blackbox_state = qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_STATE_GET, 0);

if (based_shutting_down()) {
pcmk__info("Skipping CIB write during shutdown");
Comment thread
nrwahl2 marked this conversation as resolved.
}

/* Disable blackbox logging before the fork to avoid two processes writing
* to the same shared memory. The disable should not be done in the child,
* because this would close shared memory files in the parent.
Expand Down
Loading