From 8270e8aed46f6e672b94f00fe0bde07cd2b6ddd7 Mon Sep 17 00:00:00 2001 From: Ken Gaillot Date: Fri, 13 Dec 2019 11:38:49 -0600 Subject: [PATCH 10/18] Low: controller: don't clear shutdown locks when node rejoins Add new controld_delete_node_state() values for clearing resource history while preserving shutdown locks. This is accomplished by deleting all unlocked lrm_resource entries and all lrm_rsc_op entries, instead of the entire lrm subsection. --- daemons/controld/controld_based.c | 22 +++++++++++++++++++++- daemons/controld/controld_join_dc.c | 7 +++++-- daemons/controld/controld_remote_ra.c | 16 ++++++++++------ daemons/controld/controld_utils.h | 2 ++ 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/daemons/controld/controld_based.c b/daemons/controld/controld_based.c index f3a7c4f..0ffc1e8 100644 --- a/daemons/controld/controld_based.c +++ b/daemons/controld/controld_based.c @@ -191,12 +191,21 @@ cib_delete_callback(xmlNode *msg, int call_id, int rc, xmlNode *output, // Node's lrm section (name 1x) #define XPATH_NODE_LRM XPATH_NODE_STATE "/" XML_CIB_TAG_LRM +// Node's lrm_rsc_op entries and lrm_resource entries without lock (name 2x) +#define XPATH_NODE_LRM_UNLOCKED XPATH_NODE_STATE "//" XML_LRM_TAG_RSC_OP \ + "|" XPATH_NODE_STATE \ + "//" XML_LRM_TAG_RESOURCE \ + "[not(@" XML_CONFIG_ATTR_SHUTDOWN_LOCK ")]" + // Node's transient_attributes section (name 1x) #define XPATH_NODE_ATTRS XPATH_NODE_STATE "/" XML_TAG_TRANSIENT_NODEATTRS // Everything under node_state (name 1x) #define XPATH_NODE_ALL XPATH_NODE_STATE "/*" +// Unlocked history + transient attributes (name 3x) +#define XPATH_NODE_ALL_UNLOCKED XPATH_NODE_LRM_UNLOCKED "|" XPATH_NODE_ATTRS + /*! * \internal * \brief Delete subsection of a node's CIB node_state @@ -218,6 +227,11 @@ controld_delete_node_state(const char *uname, enum controld_section_e section, xpath = crm_strdup_printf(XPATH_NODE_LRM, uname); desc = crm_strdup_printf("resource history for node %s", uname); break; + case controld_section_lrm_unlocked: + xpath = crm_strdup_printf(XPATH_NODE_LRM_UNLOCKED, uname, uname); + desc = crm_strdup_printf("resource history (other than shutdown " + "locks) for node %s", uname); + break; case controld_section_attrs: xpath = crm_strdup_printf(XPATH_NODE_ATTRS, uname); desc = crm_strdup_printf("transient attributes for node %s", uname); @@ -226,6 +240,12 @@ controld_delete_node_state(const char *uname, enum controld_section_e section, xpath = crm_strdup_printf(XPATH_NODE_ALL, uname); desc = crm_strdup_printf("all state for node %s", uname); break; + case controld_section_all_unlocked: + xpath = crm_strdup_printf(XPATH_NODE_ALL_UNLOCKED, + uname, uname, uname); + desc = crm_strdup_printf("all state (other than shutdown locks) " + "for node %s", uname); + break; } if (fsa_cib_conn == NULL) { @@ -234,7 +254,7 @@ controld_delete_node_state(const char *uname, enum controld_section_e section, } else { int call_id; - options |= cib_quorum_override|cib_xpath; + options |= cib_quorum_override|cib_xpath|cib_multiple; call_id = fsa_cib_conn->cmds->remove(fsa_cib_conn, xpath, NULL, options); crm_info("Deleting %s (via CIB call %d) " CRM_XS " xpath=%s", desc, call_id, xpath); diff --git a/daemons/controld/controld_join_dc.c b/daemons/controld/controld_join_dc.c index 885b2a9..f0eb2a2 100644 --- a/daemons/controld/controld_join_dc.c +++ b/daemons/controld/controld_join_dc.c @@ -534,6 +534,7 @@ do_dc_join_ack(long long action, int join_id = -1; int call_id = 0; ha_msg_input_t *join_ack = fsa_typed_data(fsa_dt_ha_msg); + enum controld_section_e section = controld_section_lrm; const char *op = crm_element_value(join_ack->msg, F_CRM_TASK); const char *join_from = crm_element_value(join_ack->msg, F_CRM_HOST_FROM); @@ -583,8 +584,10 @@ do_dc_join_ack(long long action, /* Update CIB with node's current executor state. A new transition will be * triggered later, when the CIB notifies us of the change. */ - controld_delete_node_state(join_from, controld_section_lrm, - cib_scope_local); + if (controld_shutdown_lock_enabled) { + section = controld_section_lrm_unlocked; + } + controld_delete_node_state(join_from, section, cib_scope_local); if (safe_str_eq(join_from, fsa_our_uname)) { xmlNode *now_dc_lrmd_state = controld_query_executor_state(fsa_our_uname); diff --git a/daemons/controld/controld_remote_ra.c b/daemons/controld/controld_remote_ra.c index 2d3dfa7..a81c354 100644 --- a/daemons/controld/controld_remote_ra.c +++ b/daemons/controld/controld_remote_ra.c @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the Pacemaker project contributors + * Copyright 2013-2020 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -177,17 +177,21 @@ remote_node_up(const char *node_name) int call_opt, call_id = 0; xmlNode *update, *state; crm_node_t *node; + enum controld_section_e section = controld_section_all; CRM_CHECK(node_name != NULL, return); crm_info("Announcing pacemaker_remote node %s", node_name); - /* Clear node's entire state (resource history and transient attributes). - * The transient attributes should and normally will be cleared when the - * node leaves, but since remote node state has a number of corner cases, - * clear them here as well, to be sure. + /* Clear node's entire state (resource history and transient attributes) + * other than shutdown locks. The transient attributes should and normally + * will be cleared when the node leaves, but since remote node state has a + * number of corner cases, clear them here as well, to be sure. */ call_opt = crmd_cib_smart_opt(); - controld_delete_node_state(node_name, controld_section_all, call_opt); + if (controld_shutdown_lock_enabled) { + section = controld_section_all_unlocked; + } + controld_delete_node_state(node_name, section, call_opt); /* Clear node's probed attribute */ update_attrd(node_name, CRM_OP_PROBED, NULL, NULL, TRUE); diff --git a/daemons/controld/controld_utils.h b/daemons/controld/controld_utils.h index 8e31007..5549636 100644 --- a/daemons/controld/controld_utils.h +++ b/daemons/controld/controld_utils.h @@ -90,8 +90,10 @@ bool controld_action_is_recordable(const char *action); // Subsections of node_state enum controld_section_e { controld_section_lrm, + controld_section_lrm_unlocked, controld_section_attrs, controld_section_all, + controld_section_all_unlocked }; void controld_delete_node_state(const char *uname, -- 1.8.3.1