Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15-SP6
pacemaker.29727
bsc#1198767-0004-Refactor-libcrmcluster-ability...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File bsc#1198767-0004-Refactor-libcrmcluster-ability-to-search-for-a-node-.patch of Package pacemaker.29727
From 1123695ad22197bbadb1f3f2ca507716ff169b09 Mon Sep 17 00:00:00 2001 From: "Gao,Yan" <ygao@suse.com> Date: Sat, 27 May 2023 08:40:54 +0200 Subject: [PATCH 4/6] Refactor: libcrmcluster: ability to search for a node cache entry by uuid instead of id ... for future use --- daemons/attrd/attrd_commands.c | 2 +- daemons/attrd/attrd_commands.c | 3 ++- daemons/based/based_messages.c | 2 +- daemons/controld/controld_corosync.c | 3 ++- daemons/controld/controld_messages.c | 4 ++-- include/crm/cluster/internal.h | 3 ++- lib/cluster/cluster.c | 2 +- lib/cluster/cpg.c | 2 +- lib/cluster/membership.c | 21 +++++++++++++++++---- 9 files changed, 29 insertions(+), 13 deletions(-) Index: pacemaker-2.1.2+20211124.ada5c3b36/daemons/attrd/attrd_commands.c =================================================================== --- pacemaker-2.1.2+20211124.ada5c3b36.orig/daemons/attrd/attrd_commands.c +++ pacemaker-2.1.2+20211124.ada5c3b36/daemons/attrd/attrd_commands.c @@ -116,7 +116,7 @@ cache_remote_node(const char *node_name) /* If we previously assumed this node was an unseen cluster node, * remove its entry from the cluster peer cache. */ - crm_node_t *dup = pcmk__search_cluster_node_cache(0, node_name); + crm_node_t *dup = pcmk__search_cluster_node_cache(0, node_name, NULL); if (dup && (dup->uuid == NULL)) { reap_crm_member(0, node_name); @@ -236,7 +236,8 @@ attrd_client_peer_remove(pcmk__client_t crm_element_value_int(xml, PCMK__XA_ATTR_NODE_ID, &nodeid); if (nodeid > 0) { - crm_node_t *node = pcmk__search_cluster_node_cache(nodeid, NULL); + crm_node_t *node = pcmk__search_cluster_node_cache(nodeid, NULL, + NULL); char *host_alloc = NULL; if (node && node->uname) { Index: pacemaker-2.1.2+20211124.ada5c3b36/daemons/based/based_messages.c =================================================================== --- pacemaker-2.1.2+20211124.ada5c3b36.orig/daemons/based/based_messages.c +++ pacemaker-2.1.2+20211124.ada5c3b36/daemons/based/based_messages.c @@ -269,7 +269,7 @@ cib_process_upgrade_server(const char *o if (rc != pcmk_ok) { // Notify originating peer so it can notify its local clients - crm_node_t *origin = pcmk__search_cluster_node_cache(0, host); + crm_node_t *origin = pcmk__search_cluster_node_cache(0, host, NULL); crm_info("Rejecting upgrade request from %s: %s " CRM_XS " rc=%d peer=%s", host, pcmk_strerror(rc), rc, Index: pacemaker-2.1.2+20211124.ada5c3b36/daemons/controld/controld_corosync.c =================================================================== --- pacemaker-2.1.2+20211124.ada5c3b36.orig/daemons/controld/controld_corosync.c +++ pacemaker-2.1.2+20211124.ada5c3b36/daemons/controld/controld_corosync.c @@ -122,8 +122,10 @@ cpg_membership_callback(cpg_handle_t han * use by the peer callback. */ if (fsa_our_dc != NULL) { - crm_node_t *peer = pcmk__search_cluster_node_cache(0, fsa_our_dc); + crm_node_t *peer = NULL; + peer = pcmk__search_cluster_node_cache(0, fsa_our_dc, + NULL); if (peer != NULL) { for (int i = 0; i < left_list_entries; ++i) { if (left_list[i].nodeid == peer->id) { Index: pacemaker-2.1.2+20211124.ada5c3b36/daemons/controld/controld_messages.c =================================================================== --- pacemaker-2.1.2+20211124.ada5c3b36.orig/daemons/controld/controld_messages.c +++ pacemaker-2.1.2+20211124.ada5c3b36/daemons/controld/controld_messages.c @@ -456,7 +456,7 @@ relay_message(xmlNode * msg, gboolean or #endif if (host_to) { - node_to = pcmk__search_cluster_node_cache(0, host_to); + node_to = pcmk__search_cluster_node_cache(0, host_to, NULL); if (node_to == NULL) { crm_warn("Cannot route message %s: Unknown node %s", ref, host_to); @@ -971,7 +971,7 @@ handle_request(xmlNode *stored_msg, enum if (strcmp(op, CRM_OP_SHUTDOWN_REQ) == 0) { const char *from = crm_element_value(stored_msg, F_CRM_HOST_FROM); - crm_node_t *node = pcmk__search_cluster_node_cache(0, from); + crm_node_t *node = pcmk__search_cluster_node_cache(0, from, NULL); pcmk__update_peer_expected(__func__, node, CRMD_JOINSTATE_DOWN); if(AM_I_DC == FALSE) { Index: pacemaker-2.1.2+20211124.ada5c3b36/include/crm/cluster/internal.h =================================================================== --- pacemaker-2.1.2+20211124.ada5c3b36.orig/include/crm/cluster/internal.h +++ pacemaker-2.1.2+20211124.ada5c3b36/include/crm/cluster/internal.h @@ -124,7 +124,8 @@ void pcmk__corosync_quorum_connect(gbool void (*destroy) (gpointer)); crm_node_t *pcmk__search_node_caches(unsigned int id, const char *uname, uint32_t flags); -crm_node_t *pcmk__search_cluster_node_cache(unsigned int id, const char *uname); +crm_node_t *pcmk__search_cluster_node_cache(unsigned int id, const char *uname, + const char *uuid); void pcmk__refresh_node_caches_from_cib(xmlNode *cib); crm_node_t *pcmk__search_known_node_cache(unsigned int id, const char *uname, Index: pacemaker-2.1.2+20211124.ada5c3b36/lib/cluster/cluster.c =================================================================== --- pacemaker-2.1.2+20211124.ada5c3b36.orig/lib/cluster/cluster.c +++ pacemaker-2.1.2+20211124.ada5c3b36/lib/cluster/cluster.c @@ -252,7 +252,7 @@ crm_peer_uname(const char *uuid) return NULL; } - node = pcmk__search_cluster_node_cache((uint32_t) id, NULL); + node = pcmk__search_cluster_node_cache((uint32_t) id, NULL, NULL); if (node != NULL) { crm_info("Setting uuid for node %s[%u] to %s", node->uname, node->id, uuid); Index: pacemaker-2.1.2+20211124.ada5c3b36/lib/cluster/cpg.c =================================================================== --- pacemaker-2.1.2+20211124.ada5c3b36.orig/lib/cluster/cpg.c +++ pacemaker-2.1.2+20211124.ada5c3b36/lib/cluster/cpg.c @@ -628,7 +628,7 @@ node_left(const char *cpg_group_name, in size_t member_list_entries) { crm_node_t *peer = pcmk__search_cluster_node_cache(cpg_peer->nodeid, - NULL); + NULL, NULL); const struct cpg_address **rival = NULL; /* Most CPG-related Pacemaker code assumes that only one process on a node Index: pacemaker-2.1.2+20211124.ada5c3b36/lib/cluster/membership.c =================================================================== --- pacemaker-2.1.2+20211124.ada5c3b36.orig/lib/cluster/membership.c +++ pacemaker-2.1.2+20211124.ada5c3b36/lib/cluster/membership.c @@ -516,7 +516,7 @@ pcmk__search_node_caches(unsigned int id } if ((node == NULL) && pcmk_is_set(flags, CRM_GET_PEER_CLUSTER)) { - node = pcmk__search_cluster_node_cache(id, uname); + node = pcmk__search_cluster_node_cache(id, uname, NULL); } return node; } @@ -555,11 +555,14 @@ crm_get_peer_full(unsigned int id, const * * \param[in] id If not 0, cluster node ID to search for * \param[in] uname If not NULL, node name to search for + * \param[in] uuid If not NULL while id is 0, node UUID instead of cluster + * node ID to search for * * \return Cluster node cache entry if found, otherwise NULL */ crm_node_t * -pcmk__search_cluster_node_cache(unsigned int id, const char *uname) +pcmk__search_cluster_node_cache(unsigned int id, const char *uname, + const char *uuid) { GHashTableIter iter; crm_node_t *node = NULL; @@ -590,6 +593,16 @@ pcmk__search_cluster_node_cache(unsigned break; } } + + } else if (uuid != NULL) { + g_hash_table_iter_init(&iter, crm_peer_cache); + while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &node)) { + if (pcmk__str_eq(node->uuid, uuid, pcmk__str_casei)) { + crm_trace("UUID match: %s = %p", node->uuid, node); + by_id = node; + break; + } + } } node = by_id; /* Good default */ @@ -708,7 +721,7 @@ crm_get_peer(unsigned int id, const char crm_peer_init(); - node = pcmk__search_cluster_node_cache(id, uname); + node = pcmk__search_cluster_node_cache(id, uname, NULL); /* if uname wasn't provided, and find_peer did not turn up a uname based on id. * we need to do a lookup of the node name using the id in the cluster membership. */ @@ -722,7 +735,7 @@ crm_get_peer(unsigned int id, const char /* try to turn up the node one more time now that we know the uname. */ if (node == NULL) { - node = pcmk__search_cluster_node_cache(id, uname); + node = pcmk__search_cluster_node_cache(id, uname, NULL); } }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor