f4fa43815b
- fenced: Handle fencing requested with nodeid by utilizing the membership cache of known nodes (bsc#1094208) * bsc-1094208-Refactor-fenced-Handle-fencing-requested-with-nodeid.patch - controld: able to manually confirm unseen nodes are down (bsc#1094208) * bsc-1094208-Fix-controld-able-to-manually-confirm-unseen-nodes-a.patch - Update to version 2.0.0+20180927.b67d8d0de: - logrotate: set a maximum size for logs - tools: ensure crm_resource --force-* commands get stderr messages - libcrmcommon: properly check whether resource supports parameters - tools: "return" from crm_mon after calling functions that don't - alerts: send all MIB OIDs with all SNMP alerts - resource-agents: add "s"-suffix where missing in metadata - libcommon: do not write to /proc/sys/kernel/sysrq when unneeded - pacemaker-based: drop declared, errant option never backed in tree - crm_mon: don't exit directly from cib_connect on error - scheduler: honor asymmetric orderings even when restarting OBS-URL: https://build.opensuse.org/request/show/640081 OBS-URL: https://build.opensuse.org/package/show/network:ha-clustering:Factory/pacemaker?expand=0&rev=311
228 lines
7.8 KiB
Diff
228 lines
7.8 KiB
Diff
From a3cfd279fdb88d54e325ebd46a15c1df8e16d351 Mon Sep 17 00:00:00 2001
|
|
From: "Gao,Yan" <ygao@suse.com>
|
|
Date: Mon, 1 Oct 2018 17:23:14 +0200
|
|
Subject: [PATCH 2/2] Refactor: fenced: Handle fencing requested with nodeid by
|
|
utilizing the membership cache of known nodes
|
|
|
|
This partially reverts c52267dfb.
|
|
---
|
|
daemons/fenced/fenced_commands.c | 9 +++------
|
|
daemons/fenced/fenced_history.c | 8 +++-----
|
|
daemons/fenced/fenced_remote.c | 32 ++++----------------------------
|
|
daemons/fenced/pacemaker-fenced.c | 20 +++++---------------
|
|
daemons/fenced/pacemaker-fenced.h | 4 ----
|
|
5 files changed, 15 insertions(+), 58 deletions(-)
|
|
|
|
diff --git a/daemons/fenced/fenced_commands.c b/daemons/fenced/fenced_commands.c
|
|
index 1fdcee7f4..8e6f1b634 100644
|
|
--- a/daemons/fenced/fenced_commands.c
|
|
+++ b/daemons/fenced/fenced_commands.c
|
|
@@ -2298,22 +2298,19 @@ stonith_fence(xmlNode * msg)
|
|
|
|
} else {
|
|
const char *host = crm_element_value(dev, F_STONITH_TARGET);
|
|
- char *nodename = NULL;
|
|
|
|
if (cmd->options & st_opt_cs_nodeid) {
|
|
int nodeid = crm_atoi(host, NULL);
|
|
+ crm_node_t *node = crm_find_known_peer_full(nodeid, NULL, CRM_GET_PEER_ANY);
|
|
|
|
- nodename = stonith_get_peer_name(nodeid);
|
|
- if (nodename) {
|
|
- host = nodename;
|
|
+ if (node) {
|
|
+ host = node->uname;
|
|
}
|
|
}
|
|
|
|
/* If we get to here, then self-fencing is implicitly allowed */
|
|
get_capable_devices(host, cmd->action, cmd->default_timeout,
|
|
TRUE, cmd, stonith_fence_get_devices_cb);
|
|
-
|
|
- free(nodename);
|
|
}
|
|
|
|
return -EINPROGRESS;
|
|
diff --git a/daemons/fenced/fenced_history.c b/daemons/fenced/fenced_history.c
|
|
index 7e1631fa9..767aeb337 100644
|
|
--- a/daemons/fenced/fenced_history.c
|
|
+++ b/daemons/fenced/fenced_history.c
|
|
@@ -384,17 +384,16 @@ stonith_fence_history(xmlNode *msg, xmlNode **output,
|
|
int rc = 0;
|
|
const char *target = NULL;
|
|
xmlNode *dev = get_xpath_object("//@" F_STONITH_TARGET, msg, LOG_TRACE);
|
|
- char *nodename = NULL;
|
|
xmlNode *out_history = NULL;
|
|
|
|
if (dev) {
|
|
target = crm_element_value(dev, F_STONITH_TARGET);
|
|
if (target && (options & st_opt_cs_nodeid)) {
|
|
int nodeid = crm_atoi(target, NULL);
|
|
+ crm_node_t *node = crm_find_known_peer_full(nodeid, NULL, CRM_GET_PEER_ANY);
|
|
|
|
- nodename = stonith_get_peer_name(nodeid);
|
|
- if (nodename) {
|
|
- target = nodename;
|
|
+ if (node) {
|
|
+ target = node->uname;
|
|
}
|
|
}
|
|
}
|
|
@@ -463,7 +462,6 @@ stonith_fence_history(xmlNode *msg, xmlNode **output,
|
|
stonith_remote_op_list);
|
|
*output = stonith_local_history_diff(NULL, FALSE, target);
|
|
}
|
|
- free(nodename);
|
|
free_xml(out_history);
|
|
return rc;
|
|
}
|
|
diff --git a/daemons/fenced/fenced_remote.c b/daemons/fenced/fenced_remote.c
|
|
index f1812dac2..110684473 100644
|
|
--- a/daemons/fenced/fenced_remote.c
|
|
+++ b/daemons/fenced/fenced_remote.c
|
|
@@ -931,30 +931,6 @@ stonith_manual_ack(xmlNode * msg, remote_fencing_op_t * op)
|
|
return -EINPROGRESS;
|
|
}
|
|
|
|
-char *
|
|
-stonith_get_peer_name(unsigned int nodeid)
|
|
-{
|
|
- crm_node_t *node = crm_find_peer(nodeid, NULL);
|
|
- char *nodename = NULL;
|
|
-
|
|
- if (node && node->uname) {
|
|
- return strdup(node->uname);
|
|
-
|
|
- } else if ((nodename = get_node_name(nodeid))) {
|
|
- return nodename;
|
|
-
|
|
- } else {
|
|
- const char *last_known_name = g_hash_table_lookup(known_peer_names, GUINT_TO_POINTER(nodeid));
|
|
-
|
|
- if (last_known_name) {
|
|
- crm_debug("Use the last known name %s for nodeid %u", last_known_name, nodeid);
|
|
- return strdup(last_known_name);
|
|
- }
|
|
- }
|
|
-
|
|
- return NULL;
|
|
-}
|
|
-
|
|
/*!
|
|
* \internal
|
|
* \brief Create a new remote stonith operation
|
|
@@ -1035,17 +1011,17 @@ create_remote_stonith_op(const char *client, xmlNode * request, gboolean peer)
|
|
|
|
if (op->call_options & st_opt_cs_nodeid) {
|
|
int nodeid = crm_atoi(op->target, NULL);
|
|
- char *nodename = stonith_get_peer_name(nodeid);
|
|
+ crm_node_t *node = crm_find_known_peer_full(nodeid, NULL, CRM_GET_PEER_ANY);
|
|
|
|
/* Ensure the conversion only happens once */
|
|
op->call_options &= ~st_opt_cs_nodeid;
|
|
|
|
- if (nodename) {
|
|
+ if (node && node->uname) {
|
|
free(op->target);
|
|
- op->target = nodename;
|
|
+ op->target = strdup(node->uname);
|
|
|
|
} else {
|
|
- crm_warn("Could not expand nodeid '%s' into a host name", op->target);
|
|
+ crm_warn("Could not expand nodeid '%s' into a host name (%p)", op->target, node);
|
|
}
|
|
}
|
|
|
|
diff --git a/daemons/fenced/pacemaker-fenced.c b/daemons/fenced/pacemaker-fenced.c
|
|
index 0e0ac96e1..e67580059 100644
|
|
--- a/daemons/fenced/pacemaker-fenced.c
|
|
+++ b/daemons/fenced/pacemaker-fenced.c
|
|
@@ -50,8 +50,6 @@ static gboolean stonith_shutdown_flag = FALSE;
|
|
static qb_ipcs_service_t *ipcs = NULL;
|
|
static xmlNode *local_cib = NULL;
|
|
|
|
-GHashTable *known_peer_names = NULL;
|
|
-
|
|
static cib_t *cib_api = NULL;
|
|
static void *cib_library = NULL;
|
|
|
|
@@ -1049,6 +1047,8 @@ update_cib_cache_cb(const char *event, xmlNode * msg)
|
|
stonith_enabled_saved = FALSE; /* Trigger a full refresh below */
|
|
}
|
|
|
|
+ crm_peer_caches_refresh(local_cib);
|
|
+
|
|
stonith_enabled_xml = get_xpath_object("//nvpair[@name='stonith-enabled']", local_cib, LOG_TRACE);
|
|
if (stonith_enabled_xml) {
|
|
stonith_enabled_s = crm_element_value(stonith_enabled_xml, XML_NVPAIR_ATTR_VALUE);
|
|
@@ -1103,6 +1103,8 @@ init_cib_cache_cb(xmlNode * msg, int call_id, int rc, xmlNode * output, void *us
|
|
have_cib_devices = TRUE;
|
|
local_cib = copy_xml(output);
|
|
|
|
+ crm_peer_caches_refresh(local_cib);
|
|
+
|
|
fencing_topology_init();
|
|
cib_devices_update();
|
|
}
|
|
@@ -1147,11 +1149,6 @@ stonith_cleanup(void)
|
|
qb_ipcs_destroy(ipcs);
|
|
}
|
|
|
|
- if (known_peer_names != NULL) {
|
|
- g_hash_table_destroy(known_peer_names);
|
|
- known_peer_names = NULL;
|
|
- }
|
|
-
|
|
crm_peer_destroy();
|
|
crm_client_cleanup();
|
|
free_stonith_remote_op_list();
|
|
@@ -1239,17 +1236,11 @@ static void
|
|
st_peer_update_callback(enum crm_status_type type, crm_node_t * node, const void *data)
|
|
{
|
|
if ((type != crm_status_processes) && !is_set(node->flags, crm_remote_node)) {
|
|
- xmlNode *query = NULL;
|
|
-
|
|
- if (node->id && node->uname) {
|
|
- g_hash_table_insert(known_peer_names, GUINT_TO_POINTER(node->id), strdup(node->uname));
|
|
- }
|
|
-
|
|
/*
|
|
* This is a hack until we can send to a nodeid and/or we fix node name lookups
|
|
* These messages are ignored in stonith_peer_callback()
|
|
*/
|
|
- query = create_xml_node(NULL, "stonith_command");
|
|
+ xmlNode *query = create_xml_node(NULL, "stonith_command");
|
|
|
|
crm_xml_add(query, F_XML_TAGNAME, "stonith_command");
|
|
crm_xml_add(query, F_TYPE, T_STONITH_NG);
|
|
@@ -1444,7 +1435,6 @@ main(int argc, char **argv)
|
|
mainloop_add_signal(SIGTERM, stonith_shutdown);
|
|
|
|
crm_peer_init();
|
|
- known_peer_names = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free);
|
|
|
|
if (stand_alone == FALSE) {
|
|
|
|
diff --git a/daemons/fenced/pacemaker-fenced.h b/daemons/fenced/pacemaker-fenced.h
|
|
index 7a51e95f6..3194e358c 100644
|
|
--- a/daemons/fenced/pacemaker-fenced.h
|
|
+++ b/daemons/fenced/pacemaker-fenced.h
|
|
@@ -255,14 +255,10 @@ schedule_internal_command(const char *origin,
|
|
void (*done_cb) (GPid pid, int rc, const char *output,
|
|
gpointer user_data));
|
|
|
|
-char *stonith_get_peer_name(unsigned int nodeid);
|
|
-
|
|
extern char *stonith_our_uname;
|
|
extern gboolean stand_alone;
|
|
extern GHashTable *device_list;
|
|
extern GHashTable *topology;
|
|
extern long stonith_watchdog_timeout_ms;
|
|
|
|
-extern GHashTable *known_peer_names;
|
|
-
|
|
extern GHashTable *stonith_remote_op_list;
|
|
--
|
|
2.16.4
|
|
|