Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9e9da84
Low: fencer: Refresh CIB in case of old diff
nrwahl2 Jan 2, 2026
438d2b3
API: libcrmcommon: Deprecate pcmk_rc_diff_resync, pcmk_err_diff_resync
nrwahl2 Jan 2, 2026
f8587e7
Log: based: Don't send entire CIB in ping reply for digest mismatch
nrwahl2 Jan 2, 2026
974b641
Doc: libcib: Address a comment about possible legacy code
nrwahl2 Jan 2, 2026
913ed87
Refactor: libcib: Drop cib_perform_op() manage_counters argument
nrwahl2 Jan 2, 2026
f5eb52b
Refactor: libcib: Drop op arg from cib__perform_query()/cib_perform_op()
nrwahl2 Jan 2, 2026
aef4d98
Refactor: libcib: Drop call_options arg from cib_perform_op()...
nrwahl2 Jan 2, 2026
f970fcd
Refactor: based: Don't pass type to prepare_input()
nrwahl2 Jan 2, 2026
e335a1e
Refactor: libcib: Drop input arg from cib__perform_query/cib_perform_op
nrwahl2 Jan 2, 2026
6bf5ff8
Low: libcib: Move CIB op input transformation to ops that need it
nrwahl2 Jan 2, 2026
46b1edb
Refactor: libcib: Drop section arg of cib__perform_query/cib_perform_op
nrwahl2 Jan 2, 2026
a11015c
Refactor: libcib: Move process_replace_xpath() downward
nrwahl2 Jan 2, 2026
2cfc231
Fix: libcib: Full-CIB replace op no longer segfaults with cib_xpath
nrwahl2 Jan 2, 2026
58f35a0
Refactor: libcrmcommon: apply_transformation takes xmlDoc * argument
nrwahl2 Jan 2, 2026
16cf654
Refactor: libcrmcommon: apply_upgrade() takes xmlDoc * argument
nrwahl2 Jan 2, 2026
7a4e910
Refactor: libcrmcommon: validate_with() takes xmlDoc * argument
nrwahl2 Jan 2, 2026
a8ae75f
Refactor: libcrmcommon: validate_with_silent() takes xmlDoc * argument
nrwahl2 Jan 2, 2026
4f8742a
Refactor: libcrmcommon: Drop pcmk__validate_xml() validation argument
nrwahl2 Jan 2, 2026
0263802
Refactor: libcib: cib__process_upgrade() keeps same doc
nrwahl2 Jan 2, 2026
26d20b0
Doc: libcib: Require that cib__op_fn_t does not alter doc private data
nrwahl2 Jan 2, 2026
7bcdec5
Refactor: based, libcib: Stricter assertions for commit transaction
nrwahl2 Feb 13, 2026
4a33a6e
Refactor: libcib: cib_perform_op no longer checks tracking flag post-fn
nrwahl2 Jan 2, 2026
988aba1
tmp
nrwahl2 Feb 13, 2026
f066b1c
Refactor: libcib: Deduplicate tracing in cib_perform_op()
nrwahl2 Jan 2, 2026
c5ab3e2
Refactor: libcib: cib_perform_op() takes only one CIB argument
nrwahl2 Jan 2, 2026
23361f9
Refactor: libcib: Drop working_cib variable from cib_perform_op()
nrwahl2 Jan 3, 2026
389c818
Refactor: libcib: Deduplicate enable-ACL and fn call in cib_perform_op()
nrwahl2 Jan 3, 2026
96c0026
Refactor: libcib: Drop op arg from cib__op_fn_t
nrwahl2 Jan 3, 2026
596ec9d
Refactor: libcib: Drop options arg from cib__op_fn_t
nrwahl2 Jan 3, 2026
fc7510e
Refactor: libcib: Drop section arg from cib__op_fn_t
nrwahl2 Jan 3, 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
91 changes: 16 additions & 75 deletions daemons/based/based_callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <crm/cib/internal.h> // cib__*
#include <crm/cluster.h> // pcmk_cluster_disconnect
#include <crm/cluster/internal.h> // pcmk__cluster_send_message
#include <crm/common/cib.h> // pcmk_find_cib_element
#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
Expand Down Expand Up @@ -248,37 +247,32 @@ process_ping_reply(xmlNode *reply)
if (!pcmk__str_eq(ping_digest, digest, pcmk__str_casei)) {
xmlNode *wrapper = pcmk__xe_first_child(pong, PCMK__XE_CIB_CALLDATA,
NULL, NULL);
xmlNode *remote_cib = pcmk__xe_first_child(wrapper, NULL, NULL, NULL);
xmlNode *remote_versions = pcmk__xe_first_child(wrapper, NULL, NULL,
NULL);

const char *admin_epoch_s = NULL;
const char *epoch_s = NULL;
const char *num_updates_s = NULL;

if (remote_cib != NULL) {
admin_epoch_s = pcmk__xe_get(remote_cib, PCMK_XA_ADMIN_EPOCH);
epoch_s = pcmk__xe_get(remote_cib, PCMK_XA_EPOCH);
num_updates_s = pcmk__xe_get(remote_cib, PCMK_XA_NUM_UPDATES);
if (remote_versions != NULL) {
admin_epoch_s = pcmk__xe_get(remote_versions,
PCMK_XA_ADMIN_EPOCH);
epoch_s = pcmk__xe_get(remote_versions,
PCMK_XA_EPOCH);
num_updates_s = pcmk__xe_get(remote_versions,
PCMK_XA_NUM_UPDATES);
}

pcmk__notice("Local CIB %s.%s.%s.%s differs from %s: %s.%s.%s.%s "
"%p",
pcmk__notice("Local CIB %s.%s.%s.%s differs from %s: %s.%s.%s.%s",
pcmk__xe_get(the_cib, PCMK_XA_ADMIN_EPOCH),
pcmk__xe_get(the_cib, PCMK_XA_EPOCH),
pcmk__xe_get(the_cib, PCMK_XA_NUM_UPDATES),
ping_digest, host,
pcmk__s(admin_epoch_s, "_"),
pcmk__s(epoch_s, "_"),
pcmk__s(num_updates_s, "_"),
digest, remote_cib);

if(remote_cib && remote_cib->children) {
// Additional debug
pcmk__xml_mark_changes(the_cib, remote_cib);
pcmk__log_xml_changes(LOG_INFO, remote_cib);
pcmk__trace("End of differences");
}
pcmk__s(num_updates_s, "_"), digest);

pcmk__xml_free(remote_cib);
pcmk__xml_free(remote_versions);
sync_our_cib(reply, false);
}
}
Expand Down Expand Up @@ -517,54 +511,17 @@ forward_request(xmlNode *request)
pcmk__xe_remove_attr(request, PCMK__XA_CIB_DELEGATED_FROM);
}

/*!
* \internal
* \brief Get a CIB operation's input from the request XML
*
* \param[in] request CIB request XML
* \param[in] type CIB operation type
* \param[out] section Where to store CIB section name
*
* \return Input XML for CIB operation
*
* \note If not \c NULL, the return value is a non-const pointer to part of
* \p request. The caller should not free it directly.
*/
static xmlNode *
prepare_input(const xmlNode *request, enum cib__op_type type,
const char **section)
{
xmlNode *wrapper = pcmk__xe_first_child(request, PCMK__XE_CIB_CALLDATA,
NULL, NULL);
xmlNode *input = pcmk__xe_first_child(wrapper, NULL, NULL, NULL);

if (type == cib__op_apply_patch) {
*section = NULL;
} else {
*section = pcmk__xe_get(request, PCMK__XA_CIB_SECTION);
}

// Grab the specified section
if ((*section != NULL) && pcmk__xe_is(input, PCMK_XE_CIB)) {
input = pcmk_find_cib_element(input, *section);
}

return input;
}

static int
cib_process_command(xmlNode *request, const cib__operation_t *operation,
cib__op_fn_t op_function, xmlNode **reply, bool privileged)
{
xmlNode *cib_diff = NULL;
xmlNode *input = NULL;
xmlNode *output = NULL;
xmlNode *result_cib = NULL;

uint32_t call_options = cib_none;

const char *op = pcmk__xe_get(request, PCMK__XA_CIB_OP);
const char *section = NULL;
const char *call_id = pcmk__xe_get(request, PCMK__XA_CIB_CALLID);
const char *client_id = pcmk__xe_get(request, PCMK__XA_CIB_CLIENTID);
const char *client_name = pcmk__xe_get(request, PCMK__XA_CIB_CLIENTNAME);
Expand All @@ -573,7 +530,6 @@ cib_process_command(xmlNode *request, const cib__operation_t *operation,
int rc = pcmk_rc_ok;

bool config_changed = false;
bool manage_counters = true;

static mainloop_timer_t *digest_timer = NULL;

Expand All @@ -600,36 +556,21 @@ cib_process_command(xmlNode *request, const cib__operation_t *operation,
goto done;
}

input = prepare_input(request, operation->type, &section);

if (!pcmk__is_set(operation->flags, cib__op_attr_modifies)) {
rc = cib__perform_query(op, call_options, op_function, section, request,
input, &the_cib, &output);
rc = cib__perform_query(op_function, request, &the_cib, &output);
goto done;
}

/* @COMPAT: Handle a valid write action (legacy)
*
* @TODO: Re-evaluate whether this is truly legacy. PCMK__XA_CIB_UPDATE may
* be set by a sync operation even in non-legacy mode, and manage_counters
* tells xml_create_patchset() whether to update version/epoch info.
*/
if (pcmk__xe_attr_is_true(request, PCMK__XA_CIB_UPDATE)) {
manage_counters = false;
CRM_LOG_ASSERT(pcmk__str_eq(op, PCMK__CIB_REQUEST_REPLACE,
pcmk__str_none));
}

ping_modified_since = true;

/* result_cib must not be modified after cib_perform_op() returns.
*
* It's not important whether the client variant is cib_native or
* cib_remote.
*/
rc = cib_perform_op(cib_undefined, op, call_options, op_function, section,
request, input, manage_counters, &config_changed,
&the_cib, &result_cib, &cib_diff, &output);
result_cib = the_cib;
rc = cib_perform_op(cib_undefined, op_function, request, &config_changed,
&result_cib, &cib_diff, &output);

/* Always write to disk for successful ops with the flag set. This also
* negates the need to detect ordering changes.
Expand Down
58 changes: 16 additions & 42 deletions daemons/based/based_messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ xmlNode *the_cib = NULL;
* \internal
* \brief Process a \c PCMK__CIB_REQUEST_ABS_DELETE
*
* \param[in] op Ignored
* \param[in] options Ignored
* \param[in] section Ignored
* \param[in] req Ignored
* \param[in] input Ignored
* \param[in] cib Ignored
Expand All @@ -50,8 +47,7 @@ xmlNode *the_cib = NULL;
* \note This is unimplemented and simply returns an error.
*/
int
based_process_abs_delete(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
based_process_abs_delete(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer)
{
/* @COMPAT Remove when PCMK__CIB_REQUEST_ABS_DELETE is removed. Note that
Expand All @@ -61,8 +57,7 @@ based_process_abs_delete(const char *op, int options, const char *section,
}

int
based_process_commit_transact(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
based_process_commit_transact(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer)
{
/* On success, our caller will activate *cib locally, trigger a replace
Expand All @@ -87,8 +82,7 @@ based_process_commit_transact(const char *op, int options, const char *section,
}

int
based_process_is_primary(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
based_process_is_primary(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer)
{
// @COMPAT Pacemaker Remote clients <3.0.0 may send this
Expand All @@ -97,17 +91,15 @@ based_process_is_primary(const char *op, int options, const char *section,

// @COMPAT: Remove when PCMK__CIB_REQUEST_NOOP is removed
int
based_process_noop(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
based_process_noop(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer)
{
*answer = NULL;
return pcmk_rc_ok;
}

int
based_process_ping(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
based_process_ping(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer)
{
/* existing_cib and *cib should be identical. In the absence of ACL
Expand All @@ -133,21 +125,10 @@ based_process_ping(const char *op, int options, const char *section,

if (*cib != NULL) {
// Use *cib so that ACL filtering is applied to the answer
pcmk__if_tracing(
{
/* Append additional detail so the receiver can log the
* differences
*/
pcmk__xml_copy(wrapper, *cib);
},
{
// Always include at least the version details
const char *name = (const char *) (*cib)->name;
xmlNode *shallow = pcmk__xe_create(wrapper, name);

pcmk__xe_copy_attrs(shallow, *cib, pcmk__xaf_none);
}
);
xmlNode *shallow = pcmk__xe_create(wrapper,
(const char *) (*cib)->name);

pcmk__xe_copy_attrs(shallow, *cib, pcmk__xaf_none);
}

pcmk__info("Reporting our current digest to %s: %s for %s.%s.%s",
Expand All @@ -162,8 +143,7 @@ based_process_ping(const char *op, int options, const char *section,
}

int
based_process_primary(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
based_process_primary(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer)
{
if (!based_is_primary) {
Expand All @@ -178,8 +158,7 @@ based_process_primary(const char *op, int options, const char *section,
}

int
based_process_schemas(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
based_process_schemas(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer)
{
xmlNode *wrapper = NULL;
Expand Down Expand Up @@ -224,8 +203,7 @@ based_process_schemas(const char *op, int options, const char *section,
}

int
based_process_secondary(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
based_process_secondary(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer)
{
if (based_is_primary) {
Expand All @@ -240,8 +218,7 @@ based_process_secondary(const char *op, int options, const char *section,
}

int
based_process_shutdown(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
based_process_shutdown(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer)
{
const char *host = pcmk__xe_get(req, PCMK__XA_SRC);
Expand All @@ -264,16 +241,14 @@ based_process_shutdown(const char *op, int options, const char *section,
}

int
based_process_sync(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
based_process_sync(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer)
{
return sync_our_cib(req, true);
}

int
based_process_upgrade(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
based_process_upgrade(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer)
{
int rc = pcmk_rc_ok;
Expand All @@ -286,8 +261,7 @@ based_process_upgrade(const char *op, int options, const char *section,
* re-broadcasts the request with PCMK__XA_CIB_SCHEMA_MAX, and each node
* performs the upgrade (and notifies its local clients) here.
*/
return cib__process_upgrade(op, options, section, req, input, cib,
answer);
return cib__process_upgrade(req, input, cib, answer);

} else {
xmlNode *scratch = pcmk__xml_copy(NULL, *cib);
Expand Down
37 changes: 12 additions & 25 deletions daemons/based/based_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,53 +17,40 @@
extern bool based_is_primary;
extern xmlNode *the_cib;

int based_process_abs_delete(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
int based_process_abs_delete(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer);

int based_process_apply_patch(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
int based_process_apply_patch(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer);

int based_process_commit_transact(const char *op, int options,
const char *section, xmlNode *req,
xmlNode *input, xmlNode **cib,
int based_process_commit_transact(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer);

int based_process_is_primary(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
int based_process_is_primary(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer);

int based_process_noop(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
int based_process_noop(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer);

int based_process_ping(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
int based_process_ping(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer);

int based_process_primary(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
int based_process_primary(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer);

int based_process_schemas(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
int based_process_schemas(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer);

int based_process_secondary(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
int based_process_secondary(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer);

int based_process_shutdown(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
int based_process_shutdown(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer);

int based_process_sync(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
int based_process_sync(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer);

int based_process_upgrade(const char *op, int options, const char *section,
xmlNode *req, xmlNode *input, xmlNode **cib,
int based_process_upgrade(xmlNode *req, xmlNode *input, xmlNode **cib,
xmlNode **answer);

int sync_our_cib(xmlNode *request, bool all);
Expand Down
Loading