From 32e0219d63e1b2da403a95a7e78cb376b58c367c Mon Sep 17 00:00:00 2001 From: liupei Date: Mon, 9 Dec 2024 11:32:53 +0800 Subject: [PATCH] Refactor: libpacemaker: de-inline pcmk__colocation_has_influence() --- ...nsure-there-are-spaces-around-CRM_XS.patch | 85 ++++++++++++ ...maker-de-inline-pcmk__colocation_has.patch | 131 ++++++++++++++++++ pacemaker.spec | 8 +- 3 files changed, 223 insertions(+), 1 deletion(-) create mode 100644 backport-Log-various-ensure-there-are-spaces-around-CRM_XS.patch create mode 100644 backport-Refactor-libpacemaker-de-inline-pcmk__colocation_has.patch diff --git a/backport-Log-various-ensure-there-are-spaces-around-CRM_XS.patch b/backport-Log-various-ensure-there-are-spaces-around-CRM_XS.patch new file mode 100644 index 0000000..34ca007 --- /dev/null +++ b/backport-Log-various-ensure-there-are-spaces-around-CRM_XS.patch @@ -0,0 +1,85 @@ +From 1246f8d355d8e53956b6d2dc1e134b04756f5396 Mon Sep 17 00:00:00 2001 +From: Ken Gaillot +Date: Tue, 30 Jul 2024 17:07:14 -0500 +Subject: [PATCH] Log: various: ensure there are spaces around CRM_XS + +--- + daemons/fenced/fenced_remote.c | 4 ++-- + lib/cluster/membership.c | 2 +- + lib/common/mainloop.c | 2 +- + lib/fencing/st_rhcs.c | 4 ++-- + lib/pacemaker/pcmk_sched_resource.c | 2 +- + 5 files changed, 7 insertions(+), 7 deletions(-) + +diff --git a/daemons/fenced/fenced_remote.c b/daemons/fenced/fenced_remote.c +index 0146cd1ddf..653c2e697b 100644 +--- a/daemons/fenced/fenced_remote.c ++++ b/daemons/fenced/fenced_remote.c +@@ -1896,8 +1896,8 @@ request_peer_fencing(remote_fencing_op_t *op, peer_device_info_t *peer) + op->total_timeout = TIMEOUT_MULTIPLY_FACTOR * get_op_total_timeout(op, peer); + op->op_timer_total = g_timeout_add(1000 * op->total_timeout, remote_op_timeout, op); + report_timeout_period(op, op->total_timeout); +- crm_info("Total timeout set to %ds for peer's fencing targeting %s for %s" +- CRM_XS "id=%.8s", ++ crm_info("Total timeout set to %ds for peer's fencing targeting %s for %s " ++ CRM_XS " id=%.8s", + op->total_timeout, op->target, op->client_name, op->id); + } + +diff --git a/lib/cluster/membership.c b/lib/cluster/membership.c +index 7eedc2ef38..b248853cd2 100644 +--- a/lib/cluster/membership.c ++++ b/lib/cluster/membership.c +@@ -1203,7 +1203,7 @@ update_peer_state_iter(const char *source, crm_node_t *node, const char *state, + gboolean is_member; + + CRM_CHECK(node != NULL, +- crm_err("Could not set state for unknown host to %s" ++ crm_err("Could not set state for unknown host to %s " + CRM_XS " source=%s", state, source); + return NULL); + +diff --git a/lib/common/mainloop.c b/lib/common/mainloop.c +index 76261342dd..d44d691e5c 100644 +--- a/lib/common/mainloop.c ++++ b/lib/common/mainloop.c +@@ -758,7 +758,7 @@ mainloop_gio_callback(GIOChannel *gio, GIOCondition condition, gpointer data) + } + + if (client->ipc && !crm_ipc_connected(client->ipc)) { +- crm_err("Connection to %s closed " CRM_XS "client=%p condition=%d", ++ crm_err("Connection to %s closed " CRM_XS " client=%p condition=%d", + client->name, client, condition); + rc = G_SOURCE_REMOVE; + +diff --git a/lib/fencing/st_rhcs.c b/lib/fencing/st_rhcs.c +index d104fe804f..ebf3399bf6 100644 +--- a/lib/fencing/st_rhcs.c ++++ b/lib/fencing/st_rhcs.c +@@ -60,8 +60,8 @@ stonith__list_rhcs_agents(stonith_key_value_t **devices) + #else + if (dirfd == -1) { + if (i == 0) { +- crm_notice("Problem with listing %s directory" +- CRM_XS "errno=%d", RH_STONITH_PREFIX, errno); ++ crm_notice("Problem with listing %s directory " ++ CRM_XS " errno=%d", RH_STONITH_PREFIX, errno); + } + free(namelist[i]); + continue; +diff --git a/lib/pacemaker/pcmk_sched_resource.c b/lib/pacemaker/pcmk_sched_resource.c +index 0791994f8f..4bbfa9501b 100644 +--- a/lib/pacemaker/pcmk_sched_resource.c ++++ b/lib/pacemaker/pcmk_sched_resource.c +@@ -601,7 +601,7 @@ pcmk__threshold_reached(pcmk_resource_t *rsc, const pcmk_node_t *node, + + if (remaining_tries <= 0) { + pcmk__sched_warn("%s cannot run on %s due to reaching migration " +- "threshold (clean up resource to allow again)" ++ "threshold (clean up resource to allow again) " + CRM_XS " failures=%d " + PCMK_META_MIGRATION_THRESHOLD "=%d", + rsc_to_ban->id, pcmk__node_name(node), fail_count, +-- +2.33.1.windows.1 + diff --git a/backport-Refactor-libpacemaker-de-inline-pcmk__colocation_has.patch b/backport-Refactor-libpacemaker-de-inline-pcmk__colocation_has.patch new file mode 100644 index 0000000..9be750d --- /dev/null +++ b/backport-Refactor-libpacemaker-de-inline-pcmk__colocation_has.patch @@ -0,0 +1,131 @@ +From 84e931b7e2f0dd9930f7074e0de441aba86b5dc1 Mon Sep 17 00:00:00 2001 +From: Ken Gaillot +Date: Tue, 30 Jul 2024 17:06:07 -0500 +Subject: [PATCH] Refactor: libpacemaker: de-inline + pcmk__colocation_has_influence() + +It's nontrivial +--- + lib/pacemaker/libpacemaker_private.h | 48 ++------------------------- + lib/pacemaker/pcmk_sched_colocation.c | 46 +++++++++++++++++++++++++ + 2 files changed, 49 insertions(+), 45 deletions(-) + +diff --git a/lib/pacemaker/libpacemaker_private.h b/lib/pacemaker/libpacemaker_private.h +index 3f8870b304..dec254b477 100644 +--- a/lib/pacemaker/libpacemaker_private.h ++++ b/lib/pacemaker/libpacemaker_private.h +@@ -595,51 +595,9 @@ void pcmk__new_colocation(const char *id, const char *node_attr, int score, + G_GNUC_INTERNAL + void pcmk__block_colocation_dependents(pcmk_action_t *action); + +-/*! +- * \internal +- * \brief Check whether colocation's dependent preferences should be considered +- * +- * \param[in] colocation Colocation constraint +- * \param[in] rsc Primary instance (normally this will be +- * colocation->primary, which NULL will be treated as, +- * but for clones or bundles with multiple instances +- * this can be a particular instance) +- * +- * \return true if colocation influence should be effective, otherwise false +- */ +-static inline bool +-pcmk__colocation_has_influence(const pcmk__colocation_t *colocation, +- const pcmk_resource_t *rsc) +-{ +- if (rsc == NULL) { +- rsc = colocation->primary; +- } +- +- /* A bundle replica colocates its remote connection with its container, +- * using a finite score so that the container can run on Pacemaker Remote +- * nodes. +- * +- * Moving a connection is lightweight and does not interrupt the service, +- * while moving a container is heavyweight and does interrupt the service, +- * so don't move a clean, active container based solely on the preferences +- * of its connection. +- * +- * This also avoids problematic scenarios where two containers want to +- * perpetually swap places. +- */ +- if (pcmk_is_set(colocation->dependent->flags, +- pcmk_rsc_remote_nesting_allowed) +- && !pcmk_is_set(rsc->flags, pcmk_rsc_failed) +- && pcmk__list_of_1(rsc->running_on)) { +- return false; +- } +- +- /* The dependent in a colocation influences the primary's location +- * if the PCMK_XA_INFLUENCE option is true or the primary is not yet active. +- */ +- return pcmk_is_set(colocation->flags, pcmk__coloc_influence) +- || (rsc->running_on == NULL); +-} ++G_GNUC_INTERNAL ++bool pcmk__colocation_has_influence(const pcmk__colocation_t *colocation, ++ const pcmk_resource_t *rsc); + + + // Ordering constraints (pcmk_sched_ordering.c) +diff --git a/lib/pacemaker/pcmk_sched_colocation.c b/lib/pacemaker/pcmk_sched_colocation.c +index 43edebc03c..ccaf1cc10f 100644 +--- a/lib/pacemaker/pcmk_sched_colocation.c ++++ b/lib/pacemaker/pcmk_sched_colocation.c +@@ -1024,6 +1024,52 @@ pcmk__unpack_colocation(xmlNode *xml_obj, pcmk_scheduler_t *scheduler) + } + } + ++/*! ++ * \internal ++ * \brief Check whether colocation's dependent preferences should be considered ++ * ++ * \param[in] colocation Colocation constraint ++ * \param[in] rsc Primary instance (normally this will be ++ * colocation->primary, which NULL will be treated as, ++ * but for clones or bundles with multiple instances ++ * this can be a particular instance) ++ * ++ * \return true if colocation influence should be effective, otherwise false ++ */ ++bool ++pcmk__colocation_has_influence(const pcmk__colocation_t *colocation, ++ const pcmk_resource_t *rsc) ++{ ++ if (rsc == NULL) { ++ rsc = colocation->primary; ++ } ++ ++ /* A bundle replica colocates its remote connection with its container, ++ * using a finite score so that the container can run on Pacemaker Remote ++ * nodes. ++ * ++ * Moving a connection is lightweight and does not interrupt the service, ++ * while moving a container is heavyweight and does interrupt the service, ++ * so don't move a clean, active container based solely on the preferences ++ * of its connection. ++ * ++ * This also avoids problematic scenarios where two containers want to ++ * perpetually swap places. ++ */ ++ if (pcmk_is_set(colocation->dependent->flags, ++ pcmk_rsc_remote_nesting_allowed) ++ && !pcmk_is_set(rsc->flags, pcmk_rsc_failed) ++ && pcmk__list_of_1(rsc->running_on)) { ++ return false; ++ } ++ ++ /* The dependent in a colocation influences the primary's location ++ * if the PCMK_XA_INFLUENCE option is true or the primary is not yet active. ++ */ ++ return pcmk_is_set(colocation->flags, pcmk__coloc_influence) ++ || (rsc->running_on == NULL); ++} ++ + /*! + * \internal + * \brief Make actions of a given type unrunnable for a given resource +-- +2.33.1.windows.1 + diff --git a/pacemaker.spec b/pacemaker.spec index f5e36c0..d59425a 100644 --- a/pacemaker.spec +++ b/pacemaker.spec @@ -17,7 +17,7 @@ ## can be incremented to build packages reliably considered "newer" ## than previously built packages with the same pcmkversion) %global pcmkversion 2.1.8 -%global specversion 3 +%global specversion 4 ## Upstream commit (full commit ID, abbreviated commit ID, or tag) to build %global commit 3980678f0372f2c7c294c01f61d63f0b2cafaad1 @@ -157,6 +157,8 @@ Patch2: backport-Feature-python-Add-a-python-wrapper-for-crm_exit_str.pat # https://github.com/ClusterLabs/pacemaker/commit/8dbd0816c84b075b02e21f733376343ec60290a6 Patch3: backport-Low-controller-libpacemaker-transition-graph-IDs-sho.patch Patch4: backport-Test-cts-scheduler-update-expected-graph-outputs-for.patch +Patch5: backport-Refactor-libpacemaker-de-inline-pcmk__colocation_has.patch +Patch6: backport-Log-various-ensure-there-are-spaces-around-CRM_XS.patch Requires: resource-agents Requires: %{pkgname_pcmk_libs} = %{version}-%{release} @@ -764,6 +766,10 @@ exit 0 %license %{nagios_name}-%{nagios_hash}/COPYING %changelog +* Mon Dec 09 2024 liupei - 2.1.8-4 +- Refactor: libpacemaker: de-inline pcmk__colocation_has_influence() +- Log: various: ensure there are spaces around CRM_XS + * Thu Dec 05 2024 liupei - 2.1.8-3 - Low: controller,libpacemaker: transition graph IDs should be positive - Test: cts-scheduler: update expected graph outputs for transition number change -- Gitee