Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
5 changes: 3 additions & 2 deletions daemons/based/based_callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1180,8 +1180,9 @@ cib_process_command(xmlNode *request, const cib__operation_t *operation,
*/
if ((operation->type == cib__op_commit_transact)
&& pcmk__str_eq(originator, OUR_NODENAME, pcmk__str_casei)
&& compare_version(pcmk__xe_get(the_cib, PCMK_XA_CRM_FEATURE_SET),
"3.19.0") < 0) {
&& (pcmk__compare_versions(pcmk__xe_get(the_cib,
PCMK_XA_CRM_FEATURE_SET),
"3.19.0") < 0)) {

sync_our_cib(request, TRUE);
}
Expand Down
5 changes: 3 additions & 2 deletions daemons/controld/controld_cib.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,9 @@ build_parameter_list(const lrmd_event_data_t *op,
/* Consider all parameters only except private ones to be consistent with
* what scheduler does with calculate_secure_digest().
*/
if (param_type == ra_param_private
&& compare_version(controld_globals.dc_version, "3.16.0") >= 0) {
if ((param_type == ra_param_private)
&& (pcmk__compare_versions(controld_globals.dc_version,
"3.16.0") >= 0)) {
g_hash_table_foreach(op->params, hash2field, *result);
pcmk__filter_op_for_digest(*result);
}
Expand Down
2 changes: 1 addition & 1 deletion daemons/controld/controld_execd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2190,7 +2190,7 @@ process_lrm_event(lrm_state_t *lrm_state, lrmd_event_data_t *op,
CRM_CHECK(op->rsc_id != NULL, return);

// Remap new status codes for older DCs
if (compare_version(controld_globals.dc_version, "3.2.0") < 0) {
if (pcmk__compare_versions(controld_globals.dc_version, "3.2.0") < 0) {
switch (op->op_status) {
case PCMK_EXEC_NOT_CONNECTED:
lrmd__set_result(op, PCMK_OCF_CONNECTION_DIED,
Expand Down
6 changes: 4 additions & 2 deletions daemons/controld/controld_membership.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ create_node_state_update(pcmk__node_status_t *node, uint32_t flags,
* "< 3.18.0" code here and below.
*/
if (pcmk__is_set(flags, controld_node_update_cluster)) {
if (compare_version(controld_globals.dc_version, "3.18.0") >= 0) {
if (pcmk__compare_versions(controld_globals.dc_version,
"3.18.0") >= 0) {
// A value 0 means the node is not a cluster member.
pcmk__xe_set_ll(node_state, PCMK__XA_IN_CCM, node->when_member);

Expand All @@ -174,7 +175,8 @@ create_node_state_update(pcmk__node_status_t *node, uint32_t flags,

if (!pcmk__is_set(node->flags, pcmk__node_status_remote)) {
if (pcmk__is_set(flags, controld_node_update_peer)) {
if (compare_version(controld_globals.dc_version, "3.18.0") >= 0) {
if (pcmk__compare_versions(controld_globals.dc_version,
"3.18.0") >= 0) {
// A value 0 means the peer is offline in CPG.
pcmk__xe_set_ll(node_state, PCMK_XA_CRMD, node->when_online);

Expand Down
7 changes: 4 additions & 3 deletions daemons/controld/controld_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ log_ra_ocf_version(const char *ra_key, const char *ra_ocf_version)
if (pcmk__str_empty(ra_ocf_version)) {
crm_warn("%s does not advertise OCF version supported", ra_key);

} else if (compare_version(ra_ocf_version, "2") >= 0) {
} else if (pcmk__compare_versions(ra_ocf_version, "2") >= 0) {
crm_warn("%s supports OCF version %s (this Pacemaker version supports "
PCMK_OCF_VERSION " and might not work properly with agent)",
ra_key, ra_ocf_version);

} else if (compare_version(ra_ocf_version, PCMK_OCF_VERSION) > 0) {
} else if (pcmk__compare_versions(ra_ocf_version, PCMK_OCF_VERSION) > 0) {
crm_info("%s supports OCF version %s (this Pacemaker version supports "
PCMK_OCF_VERSION " and might not use all agent features)",
ra_key, ra_ocf_version);
Expand Down Expand Up @@ -151,7 +151,8 @@ controld_cache_metadata(GHashTable *mdc, const lrmd_rsc_info_t *rsc,
}
log_ra_ocf_version(key, (const char *) content);
if (content != NULL) {
ocf1_1 = (compare_version((const char *) content, "1.1") >= 0);
ocf1_1 = (pcmk__compare_versions((const char *) content,
"1.1") >= 0);
xmlFree(content);
}
}
Expand Down
3 changes: 2 additions & 1 deletion daemons/execd/execd_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,8 @@ execd_process_signon(pcmk__client_t *client, xmlNode *request, int call_id,
PCMK__XA_LRMD_PROTOCOL_VERSION);
const char *start_state = pcmk__env_option(PCMK__ENV_NODE_START_STATE);

if (compare_version(protocol_version, LRMD_COMPATIBLE_PROTOCOL) < 0) {
if (pcmk__compare_versions(protocol_version,
LRMD_COMPATIBLE_PROTOCOL) < 0) {
crm_err("Cluster API version must be greater than or equal to %s, not %s",
LRMD_COMPATIBLE_PROTOCOL, protocol_version);
rc = EPROTO;
Expand Down
2 changes: 1 addition & 1 deletion include/crm/cib.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern "C" {
* \ingroup cib
*/

// Use compare_version() for doing comparisons
// Use pcmk__compare_versions() for doing comparisons
# define CIB_FEATURE_SET "2.0"

/* Core functions */
Expand Down
1 change: 1 addition & 0 deletions include/crm/common/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ pcmk__flag_text(uint64_t flag_group, uint64_t flags)

// miscellaneous utilities (from utils.c)

int pcmk__compare_versions(const char *version1, const char *version2);
int pcmk__daemon_user(uid_t *uid, gid_t *gid);
char *pcmk__generate_uuid(void);
int pcmk__lookup_user(const char *name, uid_t *uid, gid_t *gid);
Expand Down
6 changes: 4 additions & 2 deletions include/crm/lrmd.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the Pacemaker project contributors
* Copyright 2012-2025 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
Expand All @@ -16,6 +16,8 @@
#include <crm/lrmd_events.h>
#include <crm/services.h>

#include <crm/common/internal.h> // pcmk__compare_versions()

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -43,7 +45,7 @@ typedef struct lrmd_key_value_s {
*/
#define LRMD_PROTOCOL_VERSION "1.2"

#define LRMD_SUPPORTS_SCHEMA_XFER(x) (compare_version((x), "1.2") >= 0)
#define LRMD_SUPPORTS_SCHEMA_XFER(x) (pcmk__compare_versions((x), "1.2") >= 0)

/* The major protocol version the client and server both need to support for
* the connection to be successful. This should only ever be the major
Expand Down
3 changes: 2 additions & 1 deletion lib/cluster/election.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,8 @@ election_count_vote(pcmk_cluster_t *cluster, const xmlNode *message,
} else {
// A peer vote requires a comparison to determine which node is better
int age_result = compare_age(vote.age);
int version_result = compare_version(vote.version, CRM_FEATURE_SET);
int version_result = pcmk__compare_versions(vote.version,
CRM_FEATURE_SET);

if (version_result < 0) {
reason = "Version";
Expand Down
3 changes: 2 additions & 1 deletion lib/common/cib.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ pcmk_find_cib_element(xmlNode *cib, const char *element_name)
int
pcmk__check_feature_set(const char *cib_version)
{
if (cib_version && compare_version(cib_version, CRM_FEATURE_SET) > 0) {
if ((cib_version != NULL)
&& (pcmk__compare_versions(cib_version, CRM_FEATURE_SET) > 0)) {
return EPROTONOSUPPORT;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/common/digest.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ char *
calculate_xml_versioned_digest(xmlNode *input, gboolean sort,
gboolean do_filter, const char *version)
{
if ((version == NULL) || (compare_version("3.0.5", version) > 0)) {
if ((version == NULL) || (pcmk__compare_versions("3.0.5", version) > 0)) {
xmlNode *sorted = NULL;
char *digest = NULL;

Expand Down
2 changes: 1 addition & 1 deletion lib/common/rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ pcmk__cmp_by_type(const char *value1, const char *value2, enum pcmk__type type)
break;

case pcmk__type_version:
return compare_version(value1, value2);
return pcmk__compare_versions(value1, value2);

default: // Invalid type
return 0;
Expand Down
2 changes: 1 addition & 1 deletion lib/common/tests/utils/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ include $(top_srcdir)/mk/tap.mk
include $(top_srcdir)/mk/unittest.mk

# Add "_test" to the end of all test program names to simplify .gitignore.
check_PROGRAMS = compare_version_test \
check_PROGRAMS = pcmk__compare_versions_test \
pcmk__daemon_user_test \
pcmk__fail_attr_name_test \
pcmk__failcount_name_test \
Expand Down
Loading