Permalink
Browse files

Merge pull request #1256 from sashatoday/fix_start_state

Сhange starting process with PCMK_node_start_state
  • Loading branch information...
kgaillot committed Apr 10, 2017
2 parents 8179249 + 34fd2ba commit 2124e0456d632bc3678c31c68cd13af48c31d911
Showing with 29 additions and 64 deletions.
  1. +0 −1 crmd/crmd_utils.h
  2. +28 −6 crmd/join_client.c
  3. +1 −7 crmd/te_actions.c
  4. +0 −50 crmd/utils.c
View
@@ -90,7 +90,6 @@ xmlNode *create_node_state_update(crm_node_t *node, int flags,
void populate_cib_nodes(enum node_update_flags flags, const char *source);
void crm_update_quorum(gboolean quorum, gboolean force_update);
void erase_status_tag(const char *uname, const char *tag, int options);
void init_transient_attrs(const char *uname, const char *start_state, int options);
void update_attrd(const char *host, const char *name, const char *value, const char *user_name, gboolean is_remote_node);
void update_attrd_remote_node_removed(const char *host, const char *user_name);
void update_attrd_clear_failures(const char *host, const char *rsc,
View
@@ -177,6 +177,30 @@ join_query_callback(xmlNode * msg, int call_id, int rc, xmlNode * output, void *
free_xml(generation);
}
static void
set_join_state(const char * start_state)
{
if (safe_str_eq(start_state, "standby")) {
crm_notice("Forcing node %s to join in %s state per configured environment",
fsa_our_uname, start_state);
update_attr_delegate(fsa_cib_conn, cib_sync_call, XML_CIB_TAG_NODES, fsa_our_uuid,
NULL, NULL, NULL, "standby", "on", TRUE, NULL, NULL);
} else if (safe_str_eq(start_state, "online")) {
crm_notice("Forcing node %s to join in %s state per configured environment",
fsa_our_uname, start_state);
update_attr_delegate(fsa_cib_conn, cib_sync_call, XML_CIB_TAG_NODES, fsa_our_uuid,
NULL, NULL, NULL, "standby", "off", TRUE, NULL, NULL);
} else if (safe_str_eq(start_state, "default")) {
crm_debug("Not forcing a starting state on node %s", fsa_our_uname);
} else {
crm_warn("Unrecognized start state '%s', using 'default' (%s)",
start_state, fsa_our_uname);
}
}
/* A_CL_JOIN_RESULT */
/* aka. this is notification that we have (or have not) been accepted */
void
@@ -251,15 +275,13 @@ do_cl_join_finalize_respond(long long action,
*/
if (first_join && is_not_set(fsa_input_register, R_SHUTDOWN)) {
first_join = FALSE;
erase_status_tag(fsa_our_uname, XML_TAG_TRANSIENT_NODEATTRS, 0);
update_attrd(fsa_our_uname, "terminate", NULL, NULL, FALSE);
update_attrd(fsa_our_uname, XML_CIB_ATTR_SHUTDOWN, "0", NULL, FALSE);
if (start_state) {
init_transient_attrs(fsa_our_uname, start_state, 0);
} else {
erase_status_tag(fsa_our_uname, XML_TAG_TRANSIENT_NODEATTRS, 0);
set_join_state(start_state);
}
update_attrd(fsa_our_uname, "terminate", NULL, NULL, FALSE);
update_attrd(fsa_our_uname, XML_CIB_ATTR_SHUTDOWN, "0", NULL, FALSE);
}
send_cluster_message(crm_get_peer(0, fsa_our_dc), crm_msg_crmd, reply, TRUE);
View
@@ -103,8 +103,6 @@ send_stonith_update(crm_action_t * action, const char *target, const char *uuid)
/* zero out the node-status & remove all LRM status info */
xmlNode *node_state = NULL;
const char *start_state = daemon_option("node_start_state");
CRM_CHECK(target != NULL, return);
CRM_CHECK(uuid != NULL, return);
@@ -153,11 +151,7 @@ send_stonith_update(crm_action_t * action, const char *target, const char *uuid)
/* fsa_cib_conn->cmds->bump_epoch(fsa_cib_conn, cib_quorum_override|cib_scope_local); */
erase_status_tag(peer->uname, XML_CIB_TAG_LRM, cib_scope_local);
if (start_state) {
init_transient_attrs(peer->uname, start_state, cib_scope_local);
} else {
erase_status_tag(peer->uname, XML_TAG_TRANSIENT_NODEATTRS, cib_scope_local);
}
erase_status_tag(peer->uname, XML_TAG_TRANSIENT_NODEATTRS, cib_scope_local);
free_xml(node_state);
return;
View
@@ -1008,56 +1008,6 @@ erase_status_tag(const char *uname, const char *tag, int options)
}
}
static void
crm_set_join_state(const char *uname, const char *start_state)
{
if (safe_str_eq(start_state, "standby")) {
crm_notice("Forcing node %s to join in %s state per configured environment", uname, start_state);
update_attrd(uname, XML_CIB_ATTR_STANDBY, "on", NULL, FALSE);
} else if (safe_str_eq(start_state, "online")) {
crm_notice("Forcing node %s to join in %s state per configured environment", uname, start_state);
update_attrd(uname, XML_CIB_ATTR_STANDBY, "off", NULL, FALSE);
} else if (safe_str_eq(start_state, "default")) {
crm_debug("Not forcing a starting state on node %s", uname);
} else {
crm_warn("Unrecognized start state '%s', using 'default' (%s)", start_state, uname);
}
}
static void
init_attrs_callback(xmlNode * msg, int call_id, int rc, xmlNode * output, void *user_data)
{
char **data = (char**)user_data;
char *uname = data[0];
char *start_state = data[1];
char *xpath = data[2];
do_crm_log_unlikely(rc == 0 ? LOG_DEBUG : LOG_NOTICE,
"Erasing of \"%s\": %s (rc=%d)", xpath, pcmk_strerror(rc), rc);
crm_set_join_state(uname, start_state);
free(data[0]);
free(data[1]);
free(data[2]);
}
void
init_transient_attrs(const char *uname, const char *start_state, int options)
{
if (fsa_cib_conn && uname) {
int rc;
char *xpath = crm_strdup_printf("//node_state[@uname='%s']/%s", uname, XML_TAG_TRANSIENT_NODEATTRS);
int cib_opts = cib_quorum_override | cib_xpath | options;
const char **data = malloc(sizeof(char*)*3);
data[0] = strdup(uname);
data[1] = strdup(start_state);
data[2] = strdup(xpath);
crm_info("Erasing transient attributes for %s", uname);
rc = fsa_cib_conn->cmds->delete(fsa_cib_conn, xpath, NULL, cib_opts);
fsa_register_cib_callback(rc, FALSE, data, init_attrs_callback);
}
}
void crmd_peer_down(crm_node_t *peer, bool full)
{
if(full && peer->state == NULL) {

0 comments on commit 2124e04

Please sign in to comment.