diff --git a/crmd/fsa.c b/crmd/fsa.c index ad4e8836d3..f66b0b2b8c 100644 --- a/crmd/fsa.c +++ b/crmd/fsa.c @@ -1,706 +1,705 @@ /* * Copyright (C) 2004 Andrew Beekhof * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include char *fsa_our_dc = NULL; cib_t *fsa_cib_conn = NULL; char *fsa_our_dc_version = NULL; ll_lrm_t *fsa_lrm_conn; char *fsa_our_uuid = NULL; char *fsa_our_uname = NULL; #if SUPPORT_HEARTBEAT ll_cluster_t *fsa_cluster_conn; #endif fsa_timer_t *wait_timer = NULL; fsa_timer_t *recheck_timer = NULL; fsa_timer_t *election_trigger = NULL; fsa_timer_t *election_timeout = NULL; fsa_timer_t *integration_timer = NULL; fsa_timer_t *finalization_timer = NULL; fsa_timer_t *shutdown_escalation_timer = NULL; volatile gboolean do_fsa_stall = FALSE; volatile long long fsa_input_register = 0; volatile long long fsa_actions = A_NOTHING; volatile enum crmd_fsa_state fsa_state = S_STARTING; extern uint highest_born_on; extern uint num_join_invites; extern GHashTable *welcomed_nodes; extern GHashTable *finalized_nodes; extern GHashTable *confirmed_nodes; extern GHashTable *integrated_nodes; extern void initialize_join(gboolean before); #define DOT_PREFIX "actions:trace: " #define do_dot_log(fmt, args...) do_crm_log_unlikely(LOG_DEBUG_2, fmt, ##args) long long do_state_transition(long long actions, enum crmd_fsa_state cur_state, enum crmd_fsa_state next_state, fsa_data_t *msg_data); void dump_rsc_info(void); void dump_rsc_info_callback(const xmlNode *msg, int call_id, int rc, xmlNode *output, void *user_data); void ghash_print_node(gpointer key, gpointer value, gpointer user_data); void s_crmd_fsa_actions(fsa_data_t *fsa_data); void log_fsa_input(fsa_data_t *stored_msg); void init_dotfile(void); void init_dotfile(void) { do_dot_log(DOT_PREFIX"digraph \"g\" {"); do_dot_log(DOT_PREFIX" size = \"30,30\""); do_dot_log(DOT_PREFIX" graph ["); do_dot_log(DOT_PREFIX" fontsize = \"12\""); do_dot_log(DOT_PREFIX" fontname = \"Times-Roman\""); do_dot_log(DOT_PREFIX" fontcolor = \"black\""); do_dot_log(DOT_PREFIX" bb = \"0,0,398.922306,478.927856\""); do_dot_log(DOT_PREFIX" color = \"black\""); do_dot_log(DOT_PREFIX" ]"); do_dot_log(DOT_PREFIX" node ["); do_dot_log(DOT_PREFIX" fontsize = \"12\""); do_dot_log(DOT_PREFIX" fontname = \"Times-Roman\""); do_dot_log(DOT_PREFIX" fontcolor = \"black\""); do_dot_log(DOT_PREFIX" shape = \"ellipse\""); do_dot_log(DOT_PREFIX" color = \"black\""); do_dot_log(DOT_PREFIX" ]"); do_dot_log(DOT_PREFIX" edge ["); do_dot_log(DOT_PREFIX" fontsize = \"12\""); do_dot_log(DOT_PREFIX" fontname = \"Times-Roman\""); do_dot_log(DOT_PREFIX" fontcolor = \"black\""); do_dot_log(DOT_PREFIX" color = \"black\""); do_dot_log(DOT_PREFIX" ]"); do_dot_log(DOT_PREFIX"// special nodes"); do_dot_log(DOT_PREFIX" \"S_PENDING\" "); do_dot_log(DOT_PREFIX" ["); do_dot_log(DOT_PREFIX" color = \"blue\""); do_dot_log(DOT_PREFIX" fontcolor = \"blue\""); do_dot_log(DOT_PREFIX" ]"); do_dot_log(DOT_PREFIX" \"S_TERMINATE\" "); do_dot_log(DOT_PREFIX" ["); do_dot_log(DOT_PREFIX" color = \"red\""); do_dot_log(DOT_PREFIX" fontcolor = \"red\""); do_dot_log(DOT_PREFIX" ]"); do_dot_log(DOT_PREFIX"// DC only nodes"); do_dot_log(DOT_PREFIX" \"S_INTEGRATION\" [ fontcolor = \"green\" ]"); do_dot_log(DOT_PREFIX" \"S_POLICY_ENGINE\" [ fontcolor = \"green\" ]"); do_dot_log(DOT_PREFIX" \"S_TRANSITION_ENGINE\" [ fontcolor = \"green\" ]"); do_dot_log(DOT_PREFIX" \"S_RELEASE_DC\" [ fontcolor = \"green\" ]"); do_dot_log(DOT_PREFIX" \"S_IDLE\" [ fontcolor = \"green\" ]"); } static void do_fsa_action(fsa_data_t *fsa_data, long long an_action, void (*function)(long long action, enum crmd_fsa_cause cause, enum crmd_fsa_state cur_state, enum crmd_fsa_input cur_input, fsa_data_t *msg_data)) { int action_log_level = LOG_DEBUG; /* The calls to fsa_action2string() is expensive, * only make it if we will use the result */ if(an_action & A_MSG_ROUTE) { action_log_level = LOG_DEBUG_2; } fsa_actions &= ~an_action; do_crm_log(action_log_level, DOT_PREFIX"\t// %s", fsa_action2string(an_action)); function(an_action, fsa_data->fsa_cause, fsa_state, fsa_data->fsa_input, fsa_data); } static long long startup_actions = A_STARTUP|A_CIB_START|A_LRM_CONNECT|A_CCM_CONNECT|A_HA_CONNECT|A_READCONFIG|A_STARTED|A_CL_JOIN_QUERY; enum crmd_fsa_state s_crmd_fsa(enum crmd_fsa_cause cause) { fsa_data_t *fsa_data = NULL; long long register_copy = fsa_input_register; long long new_actions = A_NOTHING; enum crmd_fsa_state last_state = fsa_state; crm_debug_2("FSA invoked with Cause: %s\tState: %s", fsa_cause2string(cause), fsa_state2string(fsa_state)); do_fsa_stall = FALSE; if(is_message() == FALSE && fsa_actions != A_NOTHING) { /* fake the first message so we can get into the loop */ crm_malloc0(fsa_data, sizeof(fsa_data_t)); fsa_data->fsa_input = I_NULL; fsa_data->fsa_cause = C_FSA_INTERNAL; fsa_data->origin = __FUNCTION__; fsa_data->data_type = fsa_dt_none; fsa_message_queue = g_list_append(fsa_message_queue, fsa_data); fsa_data = NULL; } while(is_message() && do_fsa_stall == FALSE) { crm_debug_2("Checking messages (%d remaining)", g_list_length(fsa_message_queue)); fsa_data = get_message(); CRM_CHECK(fsa_data != NULL, continue); log_fsa_input(fsa_data); /* add any actions back to the queue */ fsa_actions |= fsa_data->actions; /* get the next batch of actions */ new_actions = crmd_fsa_actions[fsa_data->fsa_input][fsa_state]; fsa_actions |= new_actions; if(fsa_data->fsa_input != I_NULL && fsa_data->fsa_input != I_ROUTER) { crm_debug("Processing %s: [ state=%s cause=%s origin=%s ]", fsa_input2string(fsa_data->fsa_input), fsa_state2string(fsa_state), fsa_cause2string(fsa_data->fsa_cause), fsa_data->origin); } #ifdef FSA_TRACE if(new_actions != A_NOTHING) { crm_debug_2("Adding FSA actions %.16llx for %s/%s", new_actions, fsa_input2string(fsa_data->fsa_input), fsa_state2string(fsa_state)); fsa_dump_actions(new_actions, "\tFSA scheduled"); } else if(fsa_data->fsa_input != I_NULL && new_actions == A_NOTHING) { crm_debug("No action specified for input,state (%s,%s)", fsa_input2string(fsa_data->fsa_input), fsa_state2string(fsa_state)); } if(fsa_data->actions != A_NOTHING) { crm_debug_2("Adding input actions %.16llx for %s/%s", new_actions, fsa_input2string(fsa_data->fsa_input), fsa_state2string(fsa_state)); fsa_dump_actions(fsa_data->actions,"\tInput scheduled"); } #endif /* logging : *before* the state is changed */ if(is_set(fsa_actions, A_ERROR)) { do_fsa_action(fsa_data, A_ERROR, do_log); } if(is_set(fsa_actions, A_WARN)) { do_fsa_action(fsa_data, A_WARN, do_log); } if(is_set(fsa_actions, A_LOG)) { do_fsa_action(fsa_data, A_LOG, do_log); } /* update state variables */ last_state = fsa_state; fsa_state = crmd_fsa_state[fsa_data->fsa_input][fsa_state]; /* * Remove certain actions during shutdown */ if(fsa_state == S_STOPPING || ((fsa_input_register & R_SHUTDOWN) == R_SHUTDOWN)) { clear_bit_inplace(fsa_actions, startup_actions); } /* * Hook for change of state. * Allows actions to be added or removed when entering a state */ if(last_state != fsa_state){ fsa_actions = do_state_transition( fsa_actions, last_state, fsa_state, fsa_data); } else { do_dot_log(DOT_PREFIX"\t// FSA input: State=%s \tCause=%s" " \tInput=%s \tOrigin=%s() \tid=%d", fsa_state2string(fsa_state), fsa_cause2string(fsa_data->fsa_cause), fsa_input2string(fsa_data->fsa_input), fsa_data->origin, fsa_data->id); } /* start doing things... */ s_crmd_fsa_actions(fsa_data); delete_fsa_input(fsa_data); fsa_data = NULL; } if(g_list_length(fsa_message_queue) > 0 || fsa_actions != A_NOTHING || do_fsa_stall) { crm_debug("Exiting the FSA: queue=%d, fsa_actions=0x%llx, stalled=%s", g_list_length(fsa_message_queue), fsa_actions, do_fsa_stall?"true":"false"); } else { crm_debug_2("Exiting the FSA"); } /* cleanup inputs? */ if(register_copy != fsa_input_register) { long long same = register_copy & fsa_input_register; fsa_dump_inputs(LOG_DEBUG, "Added input:", fsa_input_register ^ same); fsa_dump_inputs(LOG_DEBUG, "Removed input:", register_copy ^ same); } fsa_dump_queue(LOG_DEBUG); return fsa_state; } void s_crmd_fsa_actions(fsa_data_t *fsa_data) { /* * Process actions in order of priority but do only one * action at a time to avoid complicating the ordering. */ CRM_CHECK(fsa_data != NULL, return); while(fsa_actions != A_NOTHING && do_fsa_stall == FALSE) { /* regular action processing in order of action priority * * Make sure all actions that connect to required systems * are performed first */ if(fsa_actions & A_ERROR) { do_fsa_action(fsa_data, A_ERROR, do_log); } else if(fsa_actions & A_WARN) { do_fsa_action(fsa_data, A_WARN, do_log); } else if(fsa_actions & A_LOG) { do_fsa_action(fsa_data, A_LOG, do_log); /* get out of here NOW! before anything worse happens */ } else if(fsa_actions & A_EXIT_1) { do_fsa_action(fsa_data, A_EXIT_1, do_exit); /* essential start tasks */ } else if(fsa_actions & A_STARTUP) { do_fsa_action(fsa_data, A_STARTUP, do_startup); } else if(fsa_actions & A_CIB_START) { do_fsa_action(fsa_data, A_CIB_START, do_cib_control); } else if(fsa_actions & A_HA_CONNECT) { do_fsa_action(fsa_data, A_HA_CONNECT, do_ha_control); } else if(fsa_actions & A_READCONFIG) { do_fsa_action(fsa_data, A_READCONFIG, do_read_config); /* sub-system start/connect */ } else if(fsa_actions & A_LRM_CONNECT) { do_fsa_action(fsa_data, A_LRM_CONNECT, do_lrm_control); } else if(fsa_actions & A_CCM_CONNECT) { do_fsa_action(fsa_data, A_CCM_CONNECT, do_ccm_control); } else if(fsa_actions & A_TE_START) { do_fsa_action(fsa_data, A_TE_START, do_te_control); } else if(fsa_actions & A_PE_START) { do_fsa_action(fsa_data, A_PE_START, do_pe_control); /* sub-system restart */ } else if((fsa_actions & O_CIB_RESTART) == O_CIB_RESTART) { do_fsa_action(fsa_data, O_CIB_RESTART, do_cib_control); } else if((fsa_actions & O_PE_RESTART) == O_PE_RESTART) { do_fsa_action(fsa_data, O_PE_RESTART, do_pe_control); } else if((fsa_actions & O_TE_RESTART) == O_TE_RESTART) { do_fsa_action(fsa_data, O_TE_RESTART, do_te_control); /* Timers */ /* else if(fsa_actions & O_DC_TIMER_RESTART) { do_fsa_action(fsa_data, O_DC_TIMER_RESTART, do_timer_control) */; } else if(fsa_actions & A_DC_TIMER_STOP) { do_fsa_action(fsa_data, A_DC_TIMER_STOP, do_timer_control); } else if(fsa_actions & A_INTEGRATE_TIMER_STOP) { do_fsa_action(fsa_data, A_INTEGRATE_TIMER_STOP, do_timer_control); } else if(fsa_actions & A_INTEGRATE_TIMER_START) { do_fsa_action(fsa_data, A_INTEGRATE_TIMER_START,do_timer_control); } else if(fsa_actions & A_FINALIZE_TIMER_STOP) { do_fsa_action(fsa_data, A_FINALIZE_TIMER_STOP, do_timer_control); } else if(fsa_actions & A_FINALIZE_TIMER_START) { do_fsa_action(fsa_data, A_FINALIZE_TIMER_START, do_timer_control); /* * Highest priority actions */ } else if(fsa_actions & A_MSG_ROUTE) { do_fsa_action(fsa_data, A_MSG_ROUTE, do_msg_route); } else if(fsa_actions & A_RECOVER) { do_fsa_action(fsa_data, A_RECOVER, do_recover); } else if(fsa_actions & A_CL_JOIN_RESULT) { do_fsa_action(fsa_data, A_CL_JOIN_RESULT, do_cl_join_finalize_respond); } else if(fsa_actions & A_CL_JOIN_REQUEST) { do_fsa_action(fsa_data, A_CL_JOIN_REQUEST, do_cl_join_offer_respond); } else if(fsa_actions & A_SHUTDOWN_REQ) { do_fsa_action(fsa_data, A_SHUTDOWN_REQ, do_shutdown_req); } else if(fsa_actions & A_ELECTION_VOTE) { do_fsa_action(fsa_data, A_ELECTION_VOTE, do_election_vote); } else if(fsa_actions & A_ELECTION_COUNT) { do_fsa_action(fsa_data, A_ELECTION_COUNT, do_election_count_vote); } else if(fsa_actions & A_LRM_EVENT) { do_fsa_action(fsa_data, A_LRM_EVENT, do_lrm_event); /* * High priority actions */ } else if(fsa_actions & A_STARTED) { do_fsa_action(fsa_data, A_STARTED, do_started); } else if(fsa_actions & A_CL_JOIN_QUERY) { do_fsa_action(fsa_data, A_CL_JOIN_QUERY, do_cl_join_query); } else if(fsa_actions & A_DC_TIMER_START) { do_fsa_action(fsa_data, A_DC_TIMER_START, do_timer_control); /* * Medium priority actions */ } else if(fsa_actions & A_DC_TAKEOVER) { do_fsa_action(fsa_data, A_DC_TAKEOVER, do_dc_takeover); } else if(fsa_actions & A_DC_RELEASE) { do_fsa_action(fsa_data, A_DC_RELEASE, do_dc_release); } else if(fsa_actions & A_DC_JOIN_FINAL) { do_fsa_action(fsa_data, A_DC_JOIN_FINAL, do_dc_join_final); } else if(fsa_actions & A_ELECTION_CHECK) { do_fsa_action(fsa_data, A_ELECTION_CHECK, do_election_check); } else if(fsa_actions & A_ELECTION_START) { do_fsa_action(fsa_data, A_ELECTION_START, do_election_vote); } else if(fsa_actions & A_TE_HALT) { do_fsa_action(fsa_data, A_TE_HALT, do_te_invoke); } else if(fsa_actions & A_TE_CANCEL) { do_fsa_action(fsa_data, A_TE_CANCEL, do_te_invoke); } else if(fsa_actions & A_DC_JOIN_OFFER_ALL) { do_fsa_action(fsa_data, A_DC_JOIN_OFFER_ALL, do_dc_join_offer_all); } else if(fsa_actions & A_DC_JOIN_OFFER_ONE) { do_fsa_action(fsa_data, A_DC_JOIN_OFFER_ONE, do_dc_join_offer_all); } else if(fsa_actions & A_DC_JOIN_PROCESS_REQ) { do_fsa_action(fsa_data, A_DC_JOIN_PROCESS_REQ, do_dc_join_filter_offer); } else if(fsa_actions & A_DC_JOIN_PROCESS_ACK) { do_fsa_action(fsa_data, A_DC_JOIN_PROCESS_ACK, do_dc_join_ack); /* * Low(er) priority actions * Make sure the CIB is always updated before invoking the * PE, and the PE before the TE */ } else if(fsa_actions & A_DC_JOIN_FINALIZE) { do_fsa_action(fsa_data, A_DC_JOIN_FINALIZE, do_dc_join_finalize); } else if(fsa_actions & A_LRM_INVOKE) { do_fsa_action(fsa_data, A_LRM_INVOKE, do_lrm_invoke); } else if(fsa_actions & A_PE_INVOKE) { do_fsa_action(fsa_data, A_PE_INVOKE, do_pe_invoke); } else if(fsa_actions & A_TE_INVOKE) { do_fsa_action(fsa_data, A_TE_INVOKE, do_te_invoke); } else if(fsa_actions & A_CL_JOIN_ANNOUNCE) { do_fsa_action(fsa_data, A_CL_JOIN_ANNOUNCE, do_cl_join_announce); /* sub-system stop */ } else if(fsa_actions & A_DC_RELEASED) { do_fsa_action(fsa_data, A_DC_RELEASED, do_dc_release); } else if(fsa_actions & A_PE_STOP) { do_fsa_action(fsa_data, A_PE_STOP, do_pe_control); } else if(fsa_actions & A_TE_STOP) { do_fsa_action(fsa_data, A_TE_STOP, do_te_control); } else if(fsa_actions & A_SHUTDOWN) { do_fsa_action(fsa_data, A_SHUTDOWN, do_shutdown); } else if(fsa_actions & A_LRM_DISCONNECT) { do_fsa_action(fsa_data, A_LRM_DISCONNECT, do_lrm_control); } else if(fsa_actions & A_CCM_DISCONNECT) { do_fsa_action(fsa_data, A_CCM_DISCONNECT, do_ccm_control); } else if(fsa_actions & A_HA_DISCONNECT) { do_fsa_action(fsa_data, A_HA_DISCONNECT, do_ha_control); } else if(fsa_actions & A_CIB_STOP) { do_fsa_action(fsa_data, A_CIB_STOP, do_cib_control); } else if(fsa_actions & A_STOP) { do_fsa_action(fsa_data, A_STOP, do_stop); /* exit gracefully */ } else if(fsa_actions & A_EXIT_0) { do_fsa_action(fsa_data, A_EXIT_0, do_exit); /* Error checking and reporting */ } else { crm_err("Action %s (0x%llx) not supported ", fsa_action2string(fsa_actions), fsa_actions); register_fsa_error_adv(C_FSA_INTERNAL, I_ERROR, fsa_data, NULL, __FUNCTION__); } } } void log_fsa_input(fsa_data_t *stored_msg) { crm_debug_2("Processing queued input %d", stored_msg->id); if(stored_msg->fsa_cause == C_CCM_CALLBACK) { crm_debug_3("FSA processing CCM callback from %s", stored_msg->origin); } else if(stored_msg->fsa_cause == C_LRM_OP_CALLBACK) { crm_debug_3("FSA processing LRM callback from %s", stored_msg->origin); } else if(stored_msg->data == NULL) { crm_debug_3("FSA processing input from %s", stored_msg->origin); } else { ha_msg_input_t *ha_input = fsa_typed_data_adv( stored_msg, fsa_dt_ha_msg, __FUNCTION__); crm_debug_3("FSA processing XML message from %s", stored_msg->origin); crm_log_xml(LOG_MSG, "FSA message data", ha_input->xml); } } long long do_state_transition(long long actions, enum crmd_fsa_state cur_state, enum crmd_fsa_state next_state, fsa_data_t *msg_data) { long long tmp = actions; gboolean clear_recovery_bit = TRUE; enum crmd_fsa_cause cause = msg_data->fsa_cause; enum crmd_fsa_input current_input = msg_data->fsa_input; const char *state_from = fsa_state2string(cur_state); const char *state_to = fsa_state2string(next_state); const char *input = fsa_input2string(current_input); CRM_DEV_ASSERT(cur_state != next_state); do_dot_log(DOT_PREFIX"\t%s -> %s [ label=%s cause=%s origin=%s ]", state_from, state_to, input, fsa_cause2string(cause), msg_data->origin); crm_info("State transition %s -> %s [ input=%s cause=%s origin=%s ]", state_from, state_to, input, fsa_cause2string(cause), msg_data->origin); /* the last two clauses might cause trouble later */ if(election_timeout != NULL && next_state != S_ELECTION && cur_state != S_RELEASE_DC) { crm_timer_stop(election_timeout); /* } else { */ /* crm_timer_start(election_timeout); */ } #if 0 if((fsa_input_register & R_SHUTDOWN)){ set_bit_inplace(tmp, A_DC_TIMER_STOP); } #endif if(next_state == S_INTEGRATION) { set_bit_inplace(tmp, A_INTEGRATE_TIMER_START); } else { set_bit_inplace(tmp, A_INTEGRATE_TIMER_STOP); } if(next_state == S_FINALIZE_JOIN) { set_bit_inplace(tmp, A_FINALIZE_TIMER_START); } else { set_bit_inplace(tmp, A_FINALIZE_TIMER_STOP); } if(next_state != S_PENDING) { set_bit_inplace(tmp, A_DC_TIMER_STOP); } if(next_state != S_ELECTION) { highest_born_on = 0; } if(next_state != S_IDLE) { crm_timer_stop(recheck_timer); } if(cur_state == S_FINALIZE_JOIN && next_state == S_POLICY_ENGINE) { populate_cib_nodes(FALSE); do_update_cib_nodes(TRUE, __FUNCTION__); } switch(next_state) { case S_PENDING: fsa_cib_conn->cmds->set_slave(fsa_cib_conn, cib_scope_local); /* fall through */ case S_ELECTION: crm_debug_2("Resetting our DC to NULL on transition to %s", fsa_state2string(next_state)); update_dc(NULL); break; case S_NOT_DC: if(is_set(fsa_input_register, R_SHUTDOWN)){ crm_info("(Re)Issuing shutdown request now" " that we have a new DC"); set_bit_inplace(tmp, A_SHUTDOWN_REQ); } CRM_DEV_ASSERT(fsa_our_dc != NULL); if(fsa_our_dc == NULL) { crm_err("Reached S_NOT_DC without a DC" " being recorded"); } break; case S_RECOVERY: clear_recovery_bit = FALSE; break; case S_FINALIZE_JOIN: CRM_DEV_ASSERT(AM_I_DC); if(cause == C_TIMER_POPPED) { crm_warn("Progressed to state %s after %s", fsa_state2string(next_state), fsa_cause2string(cause)); } if(g_hash_table_size(welcomed_nodes) > 0) { char *msg = crm_strdup( " Welcome reply not received from"); crm_warn("%u cluster nodes failed to respond" " to the join offer.", g_hash_table_size(welcomed_nodes)); g_hash_table_foreach( welcomed_nodes, ghash_print_node, msg); crm_free(msg); } else { crm_info("All %d cluster nodes " "responded to the join offer.", g_hash_table_size(integrated_nodes)); } break; case S_POLICY_ENGINE: CRM_DEV_ASSERT(AM_I_DC); if(cause == C_TIMER_POPPED) { - crm_warn("Progressed to state %s after %s", + crm_info("Progressed to state %s after %s", fsa_state2string(next_state), fsa_cause2string(cause)); } if(g_hash_table_size(finalized_nodes) > 0) { - char *msg = crm_strdup( - " Confirm not received from"); + char *msg = crm_strdup(" Confirm not received from"); crm_err("%u cluster nodes failed to confirm" " their join.", g_hash_table_size(finalized_nodes)); g_hash_table_foreach( finalized_nodes, ghash_print_node, msg); crm_free(msg); } else if(g_hash_table_size(confirmed_nodes) == crm_active_members()) { crm_info("All %u cluster nodes are" " eligible to run resources.", crm_active_members()); } else if(g_hash_table_size(confirmed_nodes) > crm_active_members()) { crm_err("We have more confirmed nodes than our membership does"); register_fsa_input(C_FSA_INTERNAL, I_ELECTION, NULL); } else if(saved_ccm_membership_id != crm_peer_seq) { crm_info("Membership changed: %llu -> %llu - join restart", saved_ccm_membership_id, crm_peer_seq); register_fsa_input_before(C_FSA_INTERNAL, I_NODE_JOIN, NULL); } else { crm_warn("Only %u of %u cluster " "nodes are eligible to run resources - continue %d", g_hash_table_size(confirmed_nodes), crm_active_members(), g_hash_table_size(welcomed_nodes)); } /* initialize_join(FALSE); */ break; case S_STOPPING: case S_TERMINATE: /* possibly redundant */ set_bit_inplace(fsa_input_register, R_SHUTDOWN); break; case S_IDLE: CRM_DEV_ASSERT(AM_I_DC); dump_rsc_info(); if(is_set(fsa_input_register, R_SHUTDOWN)){ crm_info("(Re)Issuing shutdown request now" " that we are the DC"); set_bit_inplace(tmp, A_SHUTDOWN_REQ); } if(recheck_timer->period_ms > 0) { crm_info("Starting %s", get_timer_desc(recheck_timer)); crm_timer_start(recheck_timer); } break; default: break; } if(clear_recovery_bit && next_state != S_PENDING) { tmp &= ~A_RECOVER; } else if(clear_recovery_bit == FALSE) { tmp |= A_RECOVER; } if(tmp != actions) { /* fsa_dump_actions(actions ^ tmp, "New actions"); */ actions = tmp; } return actions; } void dump_rsc_info(void) { } void ghash_print_node(gpointer key, gpointer value, gpointer user_data) { const char *text = user_data; const char *uname = key; const char *value_s = value; crm_info("%s: %s %s", text, uname, value_s); } diff --git a/doc/Pacemaker_Explained/en-US/Ap-Upgrade.xml b/doc/Pacemaker_Explained/en-US/Ap-Upgrade.xml index 2357fcb393..241dfef849 100644 --- a/doc/Pacemaker_Explained/en-US/Ap-Upgrade.xml +++ b/doc/Pacemaker_Explained/en-US/Ap-Upgrade.xml @@ -1,238 +1,249 @@ Upgrading Cluster Software
Version Compatibility When releasing newer versions we take care to make sure we are backwardly compatible with older versions. While you will always be able to upgrade from version x to x+1, in order to continue to produce high quality software it may occasionally be necessary to drop compatibility with older versions. There will always be an upgrade path from any series-2 release to any other series-2 release. There are three approaches to upgrading your cluster software Complete Cluster Shutdown Rolling (node by node) Disconnect and Reattach Each method has advantages and disadvantages, some of which are listed in the table below, and you should chose the one most appropriate to your needs. Summary of Upgrade Methodologies Type Available between all software versions Service Outage During Upgrade Service Recovery During Upgrade Exercises Failover Logic/Configuration Allows change of cluster stack type For example, switching from Heartbeat to OpenAIS. Consult the Heartbeat or OpenAIS documentation to see if upgrading them to a newer version is also supported Shutdown yes always N/A no yes Rolling no always yes yes no Reattach yes only due to failure no no yes
Complete Cluster Shutdown In this scenario one shuts down all cluster nodes and resources and upgrades all the nodes before restarting the cluster.
Procedure On each node: Shutdown the cluster stack (Heartbeat or OpenAIS) Upgrade the Pacemaker software. This may also include upgrading the cluster stack and/or the underlying operating system.. Check the configuration manually or with the crm_verify tool if available. On each node: Start the cluster stack. This can be either OpenAIS or Heartbeat and does not need to be the same as the previous cluster stack.
Rolling (node by node) In this scenario each node is removed from the cluster, upgraded and then brought back online until all nodes are running the newest version. + + + This method is currently broken between Pacemaker 0.6.x and 1.0.x + + + Measures have been put into place to ensure rolling upgrades always work for versions after 1.0.0 + If there is sufficient demand, the work to repair 0.6 -> 1.0 compatibility will be carried out. + Otherwise, please try one of the other upgrade strategies. + Detach/Reattach is a particularly good option for most people. + +
Procedure On each node: Shutdown the cluster stack (Heartbeat or OpenAIS) Upgrade the Pacemaker software. This may also include upgrading the cluster stack and/or the underlying operating system. On the first node, check the configuration manually or with the crm_verify tool if available. Start the cluster stack. This must be the same type of cluster stack (OpenAIS or Heartbeat) that the rest of the cluster is using. Upgrading OpenAIS/Heartbeat may also be possible, please consult the documentation for those projects to see if the two versions will be compatible. Repeat for each node in the cluster
Version Compatibility Version Compatibility Table Version being Installed Oldest Compatible Version - Pacemaker 1.0 - Pacemaker 0.6 or Heartbeat 2.1.3 + Pacemaker 1.0.x + Pacemaker 1.0.0 - Pacemaker 0.7 + Pacemaker 0.7.x Pacemaker 0.6 or Heartbeat 2.1.3 - Pacemaker 0.6 + Pacemaker 0.6.x Heartbeat 2.0.8 Heartbeat 2.1.3 (or less) Heartbeat 2.0.4 Heartbeat 2.0.4 (or less) Heartbeat 2.0.0 Heartbeat 2.0.0 None. Use an alternate upgrade strategy.
Crossing Compatibility Boundaries - Rolling upgrades that cross compatibility boundaries must be preformed in multiple steps. For example, to perform a rolling update from Heartbeat 2.0.1 to Pacemaker 1.0.0 one must: + Rolling upgrades that cross compatibility boundaries must be preformed in multiple steps. For example, to perform a rolling update from Heartbeat 2.0.1 to Pacemaker 0.6.6 one must: Perform a rolling upgrade from Heartbeat 2.0.1 to Heartbeat 2.0.4 Perform a rolling upgrade from Heartbeat 2.0.4 to Heartbeat 2.1.3 - Perform a rolling upgrade from Heartbeat 2.1.3 to Pacemaker 1.0.0 + Perform a rolling upgrade from Heartbeat 2.1.3 to Pacemaker 0.6.6
Disconnect and Reattach A variant of a complete cluster shutdown, but the resources are left active and re-detected when the cluster is restarted.
Procedure Tell the cluster to stop managing services. This is required to allow the services to remain active after the cluster shuts down. crm_attribute -t crm_config -n is-managed-default -v false For any resource that has a value for is-managed, make sure it is set to false (so that the cluster will not stop it) crm_resource -t primitive -r <rsc_id> -p is-managed -v false On each node: Shutdown the cluster stack (Heartbeat or OpenAIS) Upgrade the cluster stack program - This may also include upgrading the underlying operating system. Check the configuration manually or with the crm_verify tool if available. On each node: Start the cluster stack. This can be either OpenAIS or Heartbeat and does not need to be the same as the previous cluster stack. Verify the cluster re-detected all resources correctly Allow the cluster to resume managing resources again crm_attribute -t crm_config -n is-managed-default -v true For any resource that has a value for is-managed reset it to true (so the cluster can recover the service if it fails) if desired crm_resource -t primitive -r <rsc_id> -p is-managed -v false
Notes Always check your existing configuration is still compatible with the version you are installing before starting the cluster. The oldest version of the CRM to support this upgrade type was in Heartbeat 2.0.4
diff --git a/doc/Pacemaker_Explained/en-US/images/Policy-Engine-big.dot b/doc/Pacemaker_Explained/en-US/images/Policy-Engine-big.dot new file mode 100644 index 0000000000..40ced22ccc --- /dev/null +++ b/doc/Pacemaker_Explained/en-US/images/Policy-Engine-big.dot @@ -0,0 +1,83 @@ +digraph "g" { +"Cancel drbd0:0_monitor_10000 frigg" -> "drbd0:0_demote_0 frigg" [ style = bold] +"Cancel drbd0:0_monitor_10000 frigg" [ style=bold color="green" fontcolor="black" ] +"Cancel drbd0:1_monitor_12000 odin" -> "drbd0:1_promote_0 odin" [ style = bold] +"Cancel drbd0:1_monitor_12000 odin" [ style=bold color="green" fontcolor="black" ] +"IPaddr0_monitor_5000 odin" [ style=bold color="green" fontcolor="black" ] +"IPaddr0_start_0 odin" -> "IPaddr0_monitor_5000 odin" [ style = bold] +"IPaddr0_start_0 odin" -> "MailTo_start_0 odin" [ style = bold] +"IPaddr0_start_0 odin" -> "group_running_0" [ style = bold] +"IPaddr0_start_0 odin" [ style=bold color="green" fontcolor="black" ] +"MailTo_start_0 odin" -> "group_running_0" [ style = bold] +"MailTo_start_0 odin" [ style=bold color="green" fontcolor="black" ] +"drbd0:0_demote_0 frigg" -> "drbd0:0_monitor_12000 frigg" [ style = bold] +"drbd0:0_demote_0 frigg" -> "ms_drbd_demoted_0" [ style = bold] +"drbd0:0_demote_0 frigg" [ style=bold color="green" fontcolor="black" ] +"drbd0:0_monitor_12000 frigg" [ style=bold color="green" fontcolor="black" ] +"drbd0:0_post_notify_demote_0 frigg" -> "ms_drbd_confirmed-post_notify_demoted_0" [ style = bold] +"drbd0:0_post_notify_demote_0 frigg" [ style=bold color="green" fontcolor="black" ] +"drbd0:0_post_notify_promote_0 frigg" -> "ms_drbd_confirmed-post_notify_promoted_0" [ style = bold] +"drbd0:0_post_notify_promote_0 frigg" [ style=bold color="green" fontcolor="black" ] +"drbd0:0_pre_notify_demote_0 frigg" -> "ms_drbd_confirmed-pre_notify_demote_0" [ style = bold] +"drbd0:0_pre_notify_demote_0 frigg" [ style=bold color="green" fontcolor="black" ] +"drbd0:0_pre_notify_promote_0 frigg" -> "ms_drbd_confirmed-pre_notify_promote_0" [ style = bold] +"drbd0:0_pre_notify_promote_0 frigg" [ style=bold color="green" fontcolor="black" ] +"drbd0:1_monitor_10000 odin" [ style=bold color="green" fontcolor="black" ] +"drbd0:1_post_notify_demote_0 odin" -> "ms_drbd_confirmed-post_notify_demoted_0" [ style = bold] +"drbd0:1_post_notify_demote_0 odin" [ style=bold color="green" fontcolor="black" ] +"drbd0:1_post_notify_promote_0 odin" -> "ms_drbd_confirmed-post_notify_promoted_0" [ style = bold] +"drbd0:1_post_notify_promote_0 odin" [ style=bold color="green" fontcolor="black" ] +"drbd0:1_pre_notify_demote_0 odin" -> "ms_drbd_confirmed-pre_notify_demote_0" [ style = bold] +"drbd0:1_pre_notify_demote_0 odin" [ style=bold color="green" fontcolor="black" ] +"drbd0:1_pre_notify_promote_0 odin" -> "ms_drbd_confirmed-pre_notify_promote_0" [ style = bold] +"drbd0:1_pre_notify_promote_0 odin" [ style=bold color="green" fontcolor="black" ] +"drbd0:1_promote_0 odin" -> "drbd0:1_monitor_10000 odin" [ style = bold] +"drbd0:1_promote_0 odin" -> "ms_drbd_promoted_0" [ style = bold] +"drbd0:1_promote_0 odin" [ style=bold color="green" fontcolor="black" ] +"group_running_0" [ style=bold color="green" fontcolor="orange" ] +"group_start_0" -> "IPaddr0_start_0 odin" [ style = bold] +"group_start_0" -> "MailTo_start_0 odin" [ style = bold] +"group_start_0" -> "group_running_0" [ style = bold] +"group_start_0" [ style=bold color="green" fontcolor="orange" ] +"ms_drbd_confirmed-post_notify_demoted_0" -> "drbd0:0_monitor_12000 frigg" [ style = bold] +"ms_drbd_confirmed-post_notify_demoted_0" -> "drbd0:1_monitor_10000 odin" [ style = bold] +"ms_drbd_confirmed-post_notify_demoted_0" -> "ms_drbd_pre_notify_promote_0" [ style = bold] +"ms_drbd_confirmed-post_notify_demoted_0" [ style=bold color="green" fontcolor="orange" ] +"ms_drbd_confirmed-post_notify_promoted_0" -> "drbd0:0_monitor_12000 frigg" [ style = bold] +"ms_drbd_confirmed-post_notify_promoted_0" -> "drbd0:1_monitor_10000 odin" [ style = bold] +"ms_drbd_confirmed-post_notify_promoted_0" -> "group_start_0" [ style = bold] +"ms_drbd_confirmed-post_notify_promoted_0" [ style=bold color="green" fontcolor="orange" ] +"ms_drbd_confirmed-pre_notify_demote_0" -> "ms_drbd_demote_0" [ style = bold] +"ms_drbd_confirmed-pre_notify_demote_0" -> "ms_drbd_post_notify_demoted_0" [ style = bold] +"ms_drbd_confirmed-pre_notify_demote_0" [ style=bold color="green" fontcolor="orange" ] +"ms_drbd_confirmed-pre_notify_promote_0" -> "ms_drbd_post_notify_promoted_0" [ style = bold] +"ms_drbd_confirmed-pre_notify_promote_0" -> "ms_drbd_promote_0" [ style = bold] +"ms_drbd_confirmed-pre_notify_promote_0" [ style=bold color="green" fontcolor="orange" ] +"ms_drbd_demote_0" -> "drbd0:0_demote_0 frigg" [ style = bold] +"ms_drbd_demote_0" -> "ms_drbd_demoted_0" [ style = bold] +"ms_drbd_demote_0" [ style=bold color="green" fontcolor="orange" ] +"ms_drbd_demoted_0" -> "ms_drbd_post_notify_demoted_0" [ style = bold] +"ms_drbd_demoted_0" -> "ms_drbd_promote_0" [ style = bold] +"ms_drbd_demoted_0" [ style=bold color="green" fontcolor="orange" ] +"ms_drbd_post_notify_demoted_0" -> "drbd0:0_post_notify_demote_0 frigg" [ style = bold] +"ms_drbd_post_notify_demoted_0" -> "drbd0:1_post_notify_demote_0 odin" [ style = bold] +"ms_drbd_post_notify_demoted_0" -> "ms_drbd_confirmed-post_notify_demoted_0" [ style = bold] +"ms_drbd_post_notify_demoted_0" [ style=bold color="green" fontcolor="orange" ] +"ms_drbd_post_notify_promoted_0" -> "drbd0:0_post_notify_promote_0 frigg" [ style = bold] +"ms_drbd_post_notify_promoted_0" -> "drbd0:1_post_notify_promote_0 odin" [ style = bold] +"ms_drbd_post_notify_promoted_0" -> "ms_drbd_confirmed-post_notify_promoted_0" [ style = bold] +"ms_drbd_post_notify_promoted_0" [ style=bold color="green" fontcolor="orange" ] +"ms_drbd_pre_notify_demote_0" -> "drbd0:0_pre_notify_demote_0 frigg" [ style = bold] +"ms_drbd_pre_notify_demote_0" -> "drbd0:1_pre_notify_demote_0 odin" [ style = bold] +"ms_drbd_pre_notify_demote_0" -> "ms_drbd_confirmed-pre_notify_demote_0" [ style = bold] +"ms_drbd_pre_notify_demote_0" [ style=bold color="green" fontcolor="orange" ] +"ms_drbd_pre_notify_promote_0" -> "drbd0:0_pre_notify_promote_0 frigg" [ style = bold] +"ms_drbd_pre_notify_promote_0" -> "drbd0:1_pre_notify_promote_0 odin" [ style = bold] +"ms_drbd_pre_notify_promote_0" -> "ms_drbd_confirmed-pre_notify_promote_0" [ style = bold] +"ms_drbd_pre_notify_promote_0" [ style=bold color="green" fontcolor="orange" ] +"ms_drbd_promote_0" -> "drbd0:1_promote_0 odin" [ style = bold] +"ms_drbd_promote_0" [ style=bold color="green" fontcolor="orange" ] +"ms_drbd_promoted_0" -> "group_start_0" [ style = bold] +"ms_drbd_promoted_0" -> "ms_drbd_post_notify_promoted_0" [ style = bold] +"ms_drbd_promoted_0" [ style=bold color="green" fontcolor="orange" ] +} diff --git a/doc/Pacemaker_Explained/en-US/images/Policy-Engine-big.svg b/doc/Pacemaker_Explained/en-US/images/Policy-Engine-big.svg new file mode 100644 index 0000000000..7964fcfd30 --- /dev/null +++ b/doc/Pacemaker_Explained/en-US/images/Policy-Engine-big.svg @@ -0,0 +1,418 @@ + + + + + + +g + + +Cancel drbd0:0_monitor_10000 frigg + +Cancel drbd0:0_monitor_10000 frigg + + +drbd0:0_demote_0 frigg + +drbd0:0_demote_0 frigg + + +Cancel drbd0:0_monitor_10000 frigg->drbd0:0_demote_0 frigg + + + + +drbd0:0_monitor_12000 frigg + +drbd0:0_monitor_12000 frigg + + +drbd0:0_demote_0 frigg->drbd0:0_monitor_12000 frigg + + + + +ms_drbd_demoted_0 + +ms_drbd_demoted_0 + + +drbd0:0_demote_0 frigg->ms_drbd_demoted_0 + + + + +Cancel drbd0:1_monitor_12000 odin + +Cancel drbd0:1_monitor_12000 odin + + +drbd0:1_promote_0 odin + +drbd0:1_promote_0 odin + + +Cancel drbd0:1_monitor_12000 odin->drbd0:1_promote_0 odin + + + + +drbd0:1_monitor_10000 odin + +drbd0:1_monitor_10000 odin + + +drbd0:1_promote_0 odin->drbd0:1_monitor_10000 odin + + + + +ms_drbd_promoted_0 + +ms_drbd_promoted_0 + + +drbd0:1_promote_0 odin->ms_drbd_promoted_0 + + + + +IPaddr0_monitor_5000 odin + +IPaddr0_monitor_5000 odin + + +IPaddr0_start_0 odin + +IPaddr0_start_0 odin + + +IPaddr0_start_0 odin->IPaddr0_monitor_5000 odin + + + + +MailTo_start_0 odin + +MailTo_start_0 odin + + +IPaddr0_start_0 odin->MailTo_start_0 odin + + + + +group_running_0 + +group_running_0 + + +IPaddr0_start_0 odin->group_running_0 + + + + +MailTo_start_0 odin->group_running_0 + + + + +ms_drbd_post_notify_demoted_0 + +ms_drbd_post_notify_demoted_0 + + +ms_drbd_demoted_0->ms_drbd_post_notify_demoted_0 + + + + +ms_drbd_promote_0 + +ms_drbd_promote_0 + + +ms_drbd_demoted_0->ms_drbd_promote_0 + + + + +drbd0:0_post_notify_demote_0 frigg + +drbd0:0_post_notify_demote_0 frigg + + +ms_drbd_confirmed-post_notify_demoted_0 + +ms_drbd_confirmed-post_notify_demoted_0 + + +drbd0:0_post_notify_demote_0 frigg->ms_drbd_confirmed-post_notify_demoted_0 + + + + +ms_drbd_confirmed-post_notify_demoted_0->drbd0:0_monitor_12000 frigg + + + + +ms_drbd_confirmed-post_notify_demoted_0->drbd0:1_monitor_10000 odin + + + + +ms_drbd_pre_notify_promote_0 + +ms_drbd_pre_notify_promote_0 + + +ms_drbd_confirmed-post_notify_demoted_0->ms_drbd_pre_notify_promote_0 + + + + +drbd0:0_post_notify_promote_0 frigg + +drbd0:0_post_notify_promote_0 frigg + + +ms_drbd_confirmed-post_notify_promoted_0 + +ms_drbd_confirmed-post_notify_promoted_0 + + +drbd0:0_post_notify_promote_0 frigg->ms_drbd_confirmed-post_notify_promoted_0 + + + + +ms_drbd_confirmed-post_notify_promoted_0->drbd0:0_monitor_12000 frigg + + + + +ms_drbd_confirmed-post_notify_promoted_0->drbd0:1_monitor_10000 odin + + + + +group_start_0 + +group_start_0 + + +ms_drbd_confirmed-post_notify_promoted_0->group_start_0 + + + + +drbd0:0_pre_notify_demote_0 frigg + +drbd0:0_pre_notify_demote_0 frigg + + +ms_drbd_confirmed-pre_notify_demote_0 + +ms_drbd_confirmed-pre_notify_demote_0 + + +drbd0:0_pre_notify_demote_0 frigg->ms_drbd_confirmed-pre_notify_demote_0 + + + + +ms_drbd_demote_0 + +ms_drbd_demote_0 + + +ms_drbd_confirmed-pre_notify_demote_0->ms_drbd_demote_0 + + + + +ms_drbd_confirmed-pre_notify_demote_0->ms_drbd_post_notify_demoted_0 + + + + +drbd0:0_pre_notify_promote_0 frigg + +drbd0:0_pre_notify_promote_0 frigg + + +ms_drbd_confirmed-pre_notify_promote_0 + +ms_drbd_confirmed-pre_notify_promote_0 + + +drbd0:0_pre_notify_promote_0 frigg->ms_drbd_confirmed-pre_notify_promote_0 + + + + +ms_drbd_post_notify_promoted_0 + +ms_drbd_post_notify_promoted_0 + + +ms_drbd_confirmed-pre_notify_promote_0->ms_drbd_post_notify_promoted_0 + + + + +ms_drbd_confirmed-pre_notify_promote_0->ms_drbd_promote_0 + + + + +drbd0:1_post_notify_demote_0 odin + +drbd0:1_post_notify_demote_0 odin + + +drbd0:1_post_notify_demote_0 odin->ms_drbd_confirmed-post_notify_demoted_0 + + + + +drbd0:1_post_notify_promote_0 odin + +drbd0:1_post_notify_promote_0 odin + + +drbd0:1_post_notify_promote_0 odin->ms_drbd_confirmed-post_notify_promoted_0 + + + + +drbd0:1_pre_notify_demote_0 odin + +drbd0:1_pre_notify_demote_0 odin + + +drbd0:1_pre_notify_demote_0 odin->ms_drbd_confirmed-pre_notify_demote_0 + + + + +drbd0:1_pre_notify_promote_0 odin + +drbd0:1_pre_notify_promote_0 odin + + +drbd0:1_pre_notify_promote_0 odin->ms_drbd_confirmed-pre_notify_promote_0 + + + + +ms_drbd_promoted_0->group_start_0 + + + + +ms_drbd_promoted_0->ms_drbd_post_notify_promoted_0 + + + + +group_start_0->IPaddr0_start_0 odin + + + + +group_start_0->MailTo_start_0 odin + + + + +group_start_0->group_running_0 + + + + +ms_drbd_pre_notify_promote_0->drbd0:0_pre_notify_promote_0 frigg + + + + +ms_drbd_pre_notify_promote_0->ms_drbd_confirmed-pre_notify_promote_0 + + + + +ms_drbd_pre_notify_promote_0->drbd0:1_pre_notify_promote_0 odin + + + + +ms_drbd_demote_0->drbd0:0_demote_0 frigg + + + + +ms_drbd_demote_0->ms_drbd_demoted_0 + + + + +ms_drbd_post_notify_demoted_0->drbd0:0_post_notify_demote_0 frigg + + + + +ms_drbd_post_notify_demoted_0->ms_drbd_confirmed-post_notify_demoted_0 + + + + +ms_drbd_post_notify_demoted_0->drbd0:1_post_notify_demote_0 odin + + + + +ms_drbd_post_notify_promoted_0->drbd0:0_post_notify_promote_0 frigg + + + + +ms_drbd_post_notify_promoted_0->ms_drbd_confirmed-post_notify_promoted_0 + + + + +ms_drbd_post_notify_promoted_0->drbd0:1_post_notify_promote_0 odin + + + + +ms_drbd_promote_0->drbd0:1_promote_0 odin + + + + +ms_drbd_pre_notify_demote_0 + +ms_drbd_pre_notify_demote_0 + + +ms_drbd_pre_notify_demote_0->drbd0:0_pre_notify_demote_0 frigg + + + + +ms_drbd_pre_notify_demote_0->ms_drbd_confirmed-pre_notify_demote_0 + + + + +ms_drbd_pre_notify_demote_0->drbd0:1_pre_notify_demote_0 odin + + + + + diff --git a/doc/Pacemaker_Explained/en-US/images/Policy-Engine-small.dot b/doc/Pacemaker_Explained/en-US/images/Policy-Engine-small.dot new file mode 100644 index 0000000000..3fef81e789 --- /dev/null +++ b/doc/Pacemaker_Explained/en-US/images/Policy-Engine-small.dot @@ -0,0 +1,31 @@ + digraph "g" { +"rsc1_monitor_0 pcmk-2" -> "probe_complete pcmk-2" [ style = bold] +"rsc1_monitor_0 pcmk-2" [ style=bold color="green" fontcolor="black" ] +"rsc1_stop_0 pcmk-1" [ style=dashed color="red" fontcolor="black" ] +"rsc1_start_0 pcmk-2" [ style=dashed color="red" fontcolor="black" ] +"rsc1_stop_0 pcmk-1" -> "rsc1_start_0 pcmk-2" [ style = dashed ] +"rsc1_stop_0 pcmk-1" -> "all_stopped" [ style = dashed ] +"probe_complete" -> "rsc1_start_0 pcmk-2" [ style = dashed ] + +"rsc2_monitor_0 pcmk-2" -> "probe_complete pcmk-2" [ style = bold] +"rsc2_monitor_0 pcmk-2" [ style=bold color="green" fontcolor="black" ] +"rsc2_stop_0 pcmk-1" [ style=dashed color="red" fontcolor="black" ] +"rsc2_start_0 pcmk-2" [ style=dashed color="red" fontcolor="black" ] +"rsc2_stop_0 pcmk-1" -> "rsc2_start_0 pcmk-2" [ style = dashed ] +"rsc2_stop_0 pcmk-1" -> "all_stopped" [ style = dashed ] +"probe_complete" -> "rsc2_start_0 pcmk-2" [ style = dashed ] + +"rsc3_monitor_0 pcmk-2" -> "probe_complete pcmk-2" [ style = bold] +"rsc3_monitor_0 pcmk-2" [ style=bold color="green" fontcolor="black" ] +"rsc3_stop_0 pcmk-1" [ style=dashed color="blue" fontcolor="orange" ] +"rsc3_start_0 pcmk-2" [ style=dashed color="blue" fontcolor="black" ] +"rsc3_stop_0 pcmk-1" -> "all_stopped" [ style = dashed ] +"probe_complete" -> "rsc3_start_0 pcmk-2" [ style = dashed ] + +"probe_complete pcmk-2" -> "probe_complete" [ style = bold] +"probe_complete pcmk-2" [ style=bold color="green" fontcolor="black" ] +"probe_complete" [ style=bold color="green" fontcolor="orange" ] + +"all_stopped" [ style=dashed color="red" fontcolor="orange" ] + +} diff --git a/doc/Pacemaker_Explained/en-US/images/Policy-Engine-small.svg b/doc/Pacemaker_Explained/en-US/images/Policy-Engine-small.svg new file mode 100644 index 0000000000..a020d564f8 --- /dev/null +++ b/doc/Pacemaker_Explained/en-US/images/Policy-Engine-small.svg @@ -0,0 +1,133 @@ + + + + + + +g + + +rsc1_monitor_0 pcmk-2 + +rsc1_monitor_0 pcmk-2 + + +probe_complete pcmk-2 + +probe_complete pcmk-2 + + +rsc1_monitor_0 pcmk-2->probe_complete pcmk-2 + + + + +probe_complete + +probe_complete + + +probe_complete pcmk-2->probe_complete + + + + +rsc1_stop_0 pcmk-1 + +rsc1_stop_0 pcmk-1 + + +rsc1_start_0 pcmk-2 + +rsc1_start_0 pcmk-2 + + +rsc1_stop_0 pcmk-1->rsc1_start_0 pcmk-2 + + + + +all_stopped + +all_stopped + + +rsc1_stop_0 pcmk-1->all_stopped + + + + +probe_complete->rsc1_start_0 pcmk-2 + + + + +rsc2_start_0 pcmk-2 + +rsc2_start_0 pcmk-2 + + +probe_complete->rsc2_start_0 pcmk-2 + + + + +rsc3_start_0 pcmk-2 + +rsc3_start_0 pcmk-2 + + +probe_complete->rsc3_start_0 pcmk-2 + + + + +rsc2_monitor_0 pcmk-2 + +rsc2_monitor_0 pcmk-2 + + +rsc2_monitor_0 pcmk-2->probe_complete pcmk-2 + + + + +rsc2_stop_0 pcmk-1 + +rsc2_stop_0 pcmk-1 + + +rsc2_stop_0 pcmk-1->all_stopped + + + + +rsc2_stop_0 pcmk-1->rsc2_start_0 pcmk-2 + + + + +rsc3_monitor_0 pcmk-2 + +rsc3_monitor_0 pcmk-2 + + +rsc3_monitor_0 pcmk-2->probe_complete pcmk-2 + + + + +rsc3_stop_0 pcmk-1 + +rsc3_stop_0 pcmk-1 + + +rsc3_stop_0 pcmk-1->all_stopped + + + + + diff --git a/include/crm/ais.h b/include/crm/ais.h index 73fe34a4a9..c5cc3d29d6 100644 --- a/include/crm/ais.h +++ b/include/crm/ais.h @@ -1,434 +1,435 @@ /* * Copyright (C) 2004 Andrew Beekhof * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef CRM_AIS__H #define CRM_AIS__H #include #include #include #include #include #define AIS_IPC_MESSAGE_SIZE 8192*128 #if SUPPORT_AIS # ifdef AIS_COROSYNC # include # include # include # endif # ifdef AIS_WHITETANK /* cheap hacks for building against the stable series of openais */ # include enum service_types { EVS_SERVICE = 0, CLM_SERVICE = 1, AMF_SERVICE = 2, CKPT_SERVICE = 3, EVT_SERVICE = 4, LCK_SERVICE = 5, MSG_SERVICE = 6, CFG_SERVICE = 7, CPG_SERVICE = 8 }; typedef struct { int size; __attribute__((aligned(8))) int id __attribute__((aligned(8))); SaAisErrorT error __attribute__((aligned(8))); } coroipc_response_header_t __attribute__((aligned(8))); typedef struct { int size __attribute__((aligned(8))); int id __attribute__((aligned(8))); } coroipc_request_header_t __attribute__((aligned(8))); # ifdef TRADITIONAL_AIS_IPC extern SaAisErrorT saRecvRetry (int s, void *msg, size_t len); extern SaAisErrorT saServiceConnect (int *responseOut, int *callbackOut, enum service_types service); extern SaAisErrorT saSendReceiveReply (int s, void *requestMessage, int requestLen, void *responseMessage, int responseLen); # else extern int openais_fd_get(void *ipc_context); extern int openais_dispatch_recv (void *ipc_context, void *buf, int timeout); extern SaAisErrorT openais_service_disconnect (void *ipc_context); extern SaAisErrorT openais_service_connect (enum service_types service, void **ipc_context); extern SaAisErrorT openais_msg_send_reply_receive (void *ipc_context, struct iovec *iov, int iov_len, void *res_msg, int res_len); # endif #define CS_OK SA_AIS_OK #define CS_ERR_LIBRARY SA_AIS_ERR_LIBRARY #define CS_ERR_VERSION SA_AIS_ERR_VERSION #define CS_ERR_INIT SA_AIS_ERR_INIT #define CS_ERR_TIMEOUT SA_AIS_ERR_TIMEOUT #define CS_ERR_TRY_AGAIN SA_AIS_ERR_TRY_AGAIN #define CS_ERR_INVALID_PARAM SA_AIS_ERR_INVALID_PARAM #define CS_ERR_NO_MEMORY SA_AIS_ERR_NO_MEMORY #define CS_ERR_BAD_HANDLE SA_AIS_ERR_BAD_HANDLE #define CS_ERR_BUSY SA_AIS_ERR_BUSY #define CS_ERR_ACCESS SA_AIS_ERR_ACCESS #define CS_ERR_NOT_EXIST SA_AIS_ERR_NOT_EXIST #define CS_ERR_NAME_TOO_LONG SA_AIS_ERR_NAME_TOO_LONG #define CS_ERR_EXIST SA_AIS_ERR_EXIST #define CS_ERR_NO_SPACE SA_AIS_ERR_NO_SPACE #define CS_ERR_INTERRUPT SA_AIS_ERR_INTERRUPT #define CS_ERR_NAME_NOT_FOUND SA_AIS_ERR_NAME_NOT_FOUND #define CS_ERR_NO_RESOURCES SA_AIS_ERR_NO_RESOURCES #define CS_ERR_NOT_SUPPORTED SA_AIS_ERR_NOT_SUPPORTED #define CS_ERR_BAD_OPERATION SA_AIS_ERR_BAD_OPERATION #define CS_ERR_FAILED_OPERATION SA_AIS_ERR_FAILED_OPERATION #define CS_ERR_MESSAGE_ERROR SA_AIS_ERR_MESSAGE_ERROR #define CS_ERR_QUEUE_FULL SA_AIS_ERR_QUEUE_FULL #define CS_ERR_QUEUE_NOT_AVAILABLE SA_AIS_ERR_QUEUE_NOT_AVAILABLE #define CS_ERR_BAD_FLAGS SA_AIS_ERR_BAD_FLAGS #define CS_ERR_TOO_BIG SA_AIS_ERR_TOO_BIG #define CS_ERR_NO_SECTIONS SA_AIS_ERR_NO_SECTIONS # endif #else typedef struct { int size __attribute__((aligned(8))); int id __attribute__((aligned(8))); } coroipc_request_header_t __attribute__((aligned(8))); typedef struct { int size; __attribute__((aligned(8))) int id __attribute__((aligned(8))); int error __attribute__((aligned(8))); } coroipc_response_header_t __attribute__((aligned(8))); #endif #define PCMK_SERVICE_ID 9 #define CRM_MESSAGE_IPC_ACK 0 #ifndef CRM_SERVICE #define CRM_SERVICE PCMK_SERVICE_ID #endif #define MAX_NAME 256 #define AIS_IPC_NAME "ais-crm-ipc" #define CRM_NODE_LOST "lost" #define CRM_NODE_MEMBER "member" #define CRM_NODE_ACTIVE CRM_NODE_MEMBER #define CRM_NODE_INACTIVE CRM_NODE_LOST #define CRM_NODE_EVICTED "evicted" typedef struct crm_ais_host_s AIS_Host; typedef struct crm_ais_msg_s AIS_Message; enum crm_ais_msg_class { crm_class_cluster = 0, crm_class_members = 1, crm_class_notify = 2, crm_class_nodeid = 3, crm_class_rmpeer = 4, crm_class_quorum = 5, }; /* order here matters - its used to index into the crm_children array */ enum crm_ais_msg_types { crm_msg_none = 0, crm_msg_ais = 1, crm_msg_lrmd = 2, crm_msg_cib = 3, crm_msg_crmd = 4, crm_msg_attrd = 5, crm_msg_stonithd = 6, crm_msg_te = 7, crm_msg_pe = 8, crm_msg_stonith_ng = 9, }; enum crm_proc_flag { crm_proc_none = 0x00000001, crm_proc_ais = 0x00000002, crm_proc_lrmd = 0x00000010, crm_proc_cib = 0x00000100, crm_proc_crmd = 0x00000200, crm_proc_attrd = 0x00001000, crm_proc_stonithd = 0x00002000, crm_proc_pe = 0x00010000, crm_proc_te = 0x00020000, crm_proc_mgmtd = 0x00040000, crm_proc_stonith_ng = 0x00100000, }; typedef struct crm_peer_node_s { uint32_t id; uint64_t born; uint64_t last_seen; int32_t votes; uint32_t processes; char *uname; char *state; char *uuid; char *addr; char *version; } crm_node_t; struct crm_ais_host_s { uint32_t id; uint32_t pid; gboolean local; enum crm_ais_msg_types type; uint32_t size; char uname[MAX_NAME]; } __attribute__((packed)); struct crm_ais_msg_s { coroipc_response_header_t header __attribute__((aligned(8))); uint32_t id; gboolean is_compressed; AIS_Host host; AIS_Host sender; uint32_t size; uint32_t compressed_size; /* 584 bytes */ char data[0]; } __attribute__((packed)); struct crm_ais_nodeid_resp_s { coroipc_response_header_t header __attribute__((aligned(8))); uint32_t id; uint32_t counter; char uname[MAX_NAME]; + char cname[MAX_NAME]; } __attribute__((packed)); struct crm_ais_quorum_resp_s { coroipc_response_header_t header __attribute__((aligned(8))); uint64_t id; uint32_t votes; uint32_t expected_votes; uint32_t quorate; } __attribute__((packed)); static inline const char *msg_type2text(enum crm_ais_msg_types type) { const char *text = "unknown"; switch(type) { case crm_msg_none: text = "unknown"; break; case crm_msg_ais: text = "ais"; break; case crm_msg_cib: text = "cib"; break; case crm_msg_crmd: text = "crmd"; break; case crm_msg_pe: text = "pengine"; break; case crm_msg_te: text = "tengine"; break; case crm_msg_lrmd: text = "lrmd"; break; case crm_msg_attrd: text = "attrd"; break; case crm_msg_stonithd: text = "stonithd"; break; case crm_msg_stonith_ng: text = "stonith-ng"; break; } return text; } static inline const char *peer2text(enum crm_proc_flag proc) { const char *text = "unknown"; switch(proc) { case crm_proc_none: text = "unknown"; break; case crm_proc_ais: text = "ais"; break; case crm_proc_cib: text = "cib"; break; case crm_proc_crmd: text = "crmd"; break; case crm_proc_pe: text = "pengine"; break; case crm_proc_te: text = "tengine"; break; case crm_proc_lrmd: text = "lrmd"; break; case crm_proc_attrd: text = "attrd"; break; case crm_proc_stonithd: text = "stonithd"; break; case crm_proc_stonith_ng: text = "stonith-ng"; break; case crm_proc_mgmtd: text = "mgmtd"; break; } return text; } static inline const char *ais_dest(const struct crm_ais_host_s *host) { if(host->local) { return "local"; } else if(host->size > 0) { return host->uname; } else { return ""; } } #define ais_data_len(msg) (msg->is_compressed?msg->compressed_size:msg->size) static inline AIS_Message *ais_msg_copy(const AIS_Message *source) { AIS_Message *target = malloc(sizeof(AIS_Message) + ais_data_len(source)); memcpy(target, source, sizeof(AIS_Message)); memcpy(target->data, source->data, ais_data_len(target)); return target; } static inline const char *ais_error2text(int error) { const char *text = "unknown"; # if SUPPORT_AIS switch(error) { case CS_OK: text = "None"; break; case CS_ERR_LIBRARY: text = "Library error"; break; case CS_ERR_VERSION: text = "Version error"; break; case CS_ERR_INIT: text = "Initialization error"; break; case CS_ERR_TIMEOUT: text = "Timeout"; break; case CS_ERR_TRY_AGAIN: text = "Try again"; break; case CS_ERR_INVALID_PARAM: text = "Invalid parameter"; break; case CS_ERR_NO_MEMORY: text = "No memory"; break; case CS_ERR_BAD_HANDLE: text = "Bad handle"; break; case CS_ERR_BUSY: text = "Busy"; break; case CS_ERR_ACCESS: text = "Access error"; break; case CS_ERR_NOT_EXIST: text = "Doesn't exist"; break; case CS_ERR_NAME_TOO_LONG: text = "Name too long"; break; case CS_ERR_EXIST: text = "Exists"; break; case CS_ERR_NO_SPACE: text = "No space"; break; case CS_ERR_INTERRUPT: text = "Interrupt"; break; case CS_ERR_NAME_NOT_FOUND: text = "Name not found"; break; case CS_ERR_NO_RESOURCES: text = "No resources"; break; case CS_ERR_NOT_SUPPORTED: text = "Not supported"; break; case CS_ERR_BAD_OPERATION: text = "Bad operation"; break; case CS_ERR_FAILED_OPERATION: text = "Failed operation"; break; case CS_ERR_MESSAGE_ERROR: text = "Message error"; break; case CS_ERR_QUEUE_FULL: text = "Queue full"; break; case CS_ERR_QUEUE_NOT_AVAILABLE: text = "Queue not available"; break; case CS_ERR_BAD_FLAGS: text = "Bad flags"; break; case CS_ERR_TOO_BIG: text = "To big"; break; case CS_ERR_NO_SECTIONS: text = "No sections"; break; } # endif return text; } extern enum crm_ais_msg_types crm_system_type; extern enum crm_ais_msg_types text2msg_type(const char *text); extern char *get_ais_data(const AIS_Message *msg); extern gboolean check_message_sanity(const AIS_Message *msg, const char *data); #endif diff --git a/include/crm/common/cluster.h b/include/crm/common/cluster.h index fa74c2de62..2f698122ca 100644 --- a/include/crm/common/cluster.h +++ b/include/crm/common/cluster.h @@ -1,105 +1,106 @@ /* * Copyright (C) 2004 Andrew Beekhof * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef CRM_COMMON_CLUSTER__H #define CRM_COMMON_CLUSTER__H #include #include #include #include #if SUPPORT_HEARTBEAT # include # include #endif extern gboolean crm_have_quorum; extern GHashTable *crm_peer_cache; extern GHashTable *crm_peer_id_cache; extern unsigned long long crm_peer_seq; extern void crm_peer_init(void); extern void crm_peer_destroy(void); extern gboolean crm_cluster_connect( char **our_uname, char **our_uuid, void *dispatch, void *destroy, #if SUPPORT_HEARTBEAT ll_cluster_t **hb_conn #else void **unused #endif ); extern gboolean send_cluster_message( const char *node, enum crm_ais_msg_types service, xmlNode *data, gboolean ordered); extern void destroy_crm_node(gpointer data); extern crm_node_t *crm_get_peer(unsigned int id, const char *uname); extern crm_node_t *crm_update_ais_node(xmlNode *member, long long seq); extern void crm_update_peer_proc( const char *uname, uint32_t flag, const char *status); extern crm_node_t *crm_update_peer( unsigned int id, uint64_t born, uint64_t seen, int32_t votes, uint32_t children, const char *uuid, const char *uname, const char *addr, const char *state); extern gboolean crm_is_member_active(const crm_node_t *node); extern guint crm_active_members(void); extern guint reap_crm_member(uint32_t id); extern guint crm_active_members(void); extern guint crm_active_peers(uint32_t peer); extern gboolean crm_calculate_quorum(void); extern int crm_terminate_member(int nodeid, const char *uname, IPC_Channel *cluster); extern int crm_terminate_member_no_mainloop(int nodeid, const char *uname, int *connection); +extern gboolean crm_get_cluster_name(char **cname); #if SUPPORT_HEARTBEAT extern gboolean ccm_have_quorum(oc_ed_t event); extern const char *ccm_event_name(oc_ed_t event); extern crm_node_t *crm_update_ccm_node( const oc_ev_membership_t *oc, int offset, const char *state, uint64_t seq); #endif #if SUPPORT_AIS extern int ais_fd_sync; extern GFDSource *ais_source; extern gboolean send_ais_text( int class, const char *data, gboolean local, const char *node, enum crm_ais_msg_types dest); extern gboolean get_ais_nodeid(uint32_t *id, char **uname); extern gboolean ais_dispatch(int sender, gpointer user_data); #endif extern void empty_uuid_cache(void); extern const char *get_uuid(const char *uname); extern const char *get_uname(const char *uuid); extern void set_uuid(xmlNode *node, const char *attr, const char *uname); extern void unget_uuid(const char *uname); enum crm_status_type { crm_status_uname, crm_status_nstate, crm_status_processes, }; enum crm_ais_msg_types text2msg_type(const char *text); extern void crm_set_status_callback( void (*dispatch)(enum crm_status_type, crm_node_t*, const void*)); #endif diff --git a/lib/ais/plugin.c b/lib/ais/plugin.c index e638fd3196..9339baf19a 100644 --- a/lib/ais/plugin.c +++ b/lib/ais/plugin.c @@ -1,1605 +1,1612 @@ /* * Copyright (C) 2004 Andrew Beekhof * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef AIS_COROSYNC # include # include # include #endif #include #include #include "plugin.h" #include "utils.h" #include #include #include #include #include #include #include #include #include struct corosync_api_v1 *pcmk_api = NULL; uint32_t plugin_has_votes = 0; uint32_t plugin_expected_votes = 1024; int use_mgmtd = 0; int plugin_log_level = LOG_DEBUG; char *local_uname = NULL; int local_uname_len = 0; +char *local_cname = NULL; +int local_cname_len = 0; uint32_t local_nodeid = 0; char *ipc_channel_name = NULL; static uint64_t local_born_on = 0; uint64_t membership_seq = 0; pthread_t pcmk_wait_thread; gboolean wait_active = TRUE; gboolean have_reliable_membership_id = FALSE; GHashTable *ipc_client_list = NULL; GHashTable *membership_list = NULL; GHashTable *membership_notify_list = NULL; #define MAX_RESPAWN 100 #define LOOPBACK_ID 16777343 #define crm_flag_none 0x00000000 #define crm_flag_members 0x00000001 struct crm_identify_msg_s { coroipc_request_header_t header __attribute__((aligned(8))); uint32_t id; uint32_t pid; int32_t votes; uint32_t processes; char uname[256]; char version[256]; uint64_t born_on; } __attribute__((packed)); static crm_child_t pcmk_children[] = { { 0, crm_proc_none, crm_flag_none, 0, 0, FALSE, "none", NULL, NULL, NULL, NULL }, { 0, crm_proc_ais, crm_flag_none, 0, 0, FALSE, "ais", NULL, NULL, NULL, NULL }, { 0, crm_proc_lrmd, crm_flag_none, 3, 0, TRUE, "lrmd", NULL, CRM_DAEMON_DIR"/lrmd", NULL, NULL }, { 0, crm_proc_cib, crm_flag_members, 2, 0, TRUE, "cib", CRM_DAEMON_USER, CRM_DAEMON_DIR"/cib", NULL, NULL }, { 0, crm_proc_crmd, crm_flag_members, 6, 0, TRUE, "crmd", CRM_DAEMON_USER, CRM_DAEMON_DIR"/crmd", NULL, NULL }, { 0, crm_proc_attrd, crm_flag_none, 4, 0, TRUE, "attrd", CRM_DAEMON_USER, CRM_DAEMON_DIR"/attrd", NULL, NULL }, { 0, crm_proc_stonithd, crm_flag_none, 0, 0, TRUE, "stonithd", NULL, "/bin/false", NULL, NULL }, { 0, crm_proc_pe, crm_flag_none, 5, 0, TRUE, "pengine", CRM_DAEMON_USER, CRM_DAEMON_DIR"/pengine", NULL, NULL }, { 0, crm_proc_mgmtd, crm_flag_none, 7, 0, TRUE, "mgmtd", NULL, CRM_DAEMON_DIR"/mgmtd", NULL, NULL }, { 0, crm_proc_stonith_ng, crm_flag_none, 1, 0, TRUE, "stonith-ng", NULL, CRM_DAEMON_DIR"/stonithd", NULL, NULL }, }; void send_cluster_id(void); int send_cluster_msg_raw(const AIS_Message *ais_msg); char *pcmk_generate_membership_data(void); gboolean check_message_sanity(const AIS_Message *msg, const char *data); #ifdef AIS_COROSYNC typedef const void ais_void_ptr; int pcmk_shutdown(void); void pcmk_peer_update(enum totem_configuration_type configuration_type, const unsigned int *member_list, size_t member_list_entries, const unsigned int *left_list, size_t left_list_entries, const unsigned int *joined_list, size_t joined_list_entries, const struct memb_ring_id *ring_id); #else typedef void ais_void_ptr; extern totempg_groups_handle openais_group_handle; int pcmk_shutdown(struct objdb_iface_ver0 *objdb); void pcmk_peer_update(enum totem_configuration_type configuration_type, unsigned int *member_list, int member_list_entries, unsigned int *left_list, int left_list_entries, unsigned int *joined_list, int joined_list_entries, struct memb_ring_id *ring_id); #endif int pcmk_startup (struct corosync_api_v1 *corosync_api); int pcmk_config_init(struct corosync_api_v1 *corosync_api); int pcmk_ipc_exit (void *conn); int pcmk_ipc_connect (void *conn); void pcmk_ipc(void *conn, ais_void_ptr *msg); void pcmk_exec_dump(void); void pcmk_cluster_swab(void *msg); void pcmk_cluster_callback(ais_void_ptr *message, unsigned int nodeid); void pcmk_nodeid(void *conn, ais_void_ptr *msg); void pcmk_nodes(void *conn, ais_void_ptr *msg); void pcmk_notify(void *conn, ais_void_ptr *msg); void pcmk_remove_member(void *conn, ais_void_ptr *msg); void pcmk_quorum(void *conn, ais_void_ptr *msg); void pcmk_cluster_id_swab(void *msg); void pcmk_cluster_id_callback(ais_void_ptr *message, unsigned int nodeid); void ais_remove_peer(char *node_id); static struct corosync_lib_handler pcmk_lib_service[] = { { /* 0 */ .lib_handler_fn = pcmk_ipc, .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED, #ifdef AIS_WHITETANK .response_size = sizeof (coroipc_response_header_t), .response_id = CRM_MESSAGE_IPC_ACK, #endif }, { /* 1 */ .lib_handler_fn = pcmk_nodes, .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED, #ifdef AIS_WHITETANK .response_size = sizeof (coroipc_response_header_t), .response_id = CRM_MESSAGE_IPC_ACK, #endif }, { /* 2 */ .lib_handler_fn = pcmk_notify, .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED, #ifdef AIS_WHITETANK .response_size = sizeof (coroipc_response_header_t), .response_id = CRM_MESSAGE_IPC_ACK, #endif }, { /* 3 */ .lib_handler_fn = pcmk_nodeid, .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED, #ifdef AIS_WHITETANK .response_size = sizeof (struct crm_ais_nodeid_resp_s), .response_id = crm_class_nodeid, #endif }, { /* 4 */ .lib_handler_fn = pcmk_remove_member, .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED, #ifdef AIS_WHITETANK .response_size = sizeof (coroipc_response_header_t), .response_id = CRM_MESSAGE_IPC_ACK, #endif }, { /* 5 */ .lib_handler_fn = pcmk_quorum, .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED, #ifdef AIS_WHITETANK .response_size = sizeof (coroipc_response_header_t), .response_id = CRM_MESSAGE_IPC_ACK, #endif }, }; static struct corosync_exec_handler pcmk_exec_service[] = { { /* 0 */ .exec_handler_fn = pcmk_cluster_callback, .exec_endian_convert_fn = pcmk_cluster_swab }, { /* 1 */ .exec_handler_fn = pcmk_cluster_id_callback, .exec_endian_convert_fn = pcmk_cluster_id_swab } }; /* * Exports the interface for the service */ struct corosync_service_engine pcmk_service_handler = { .name = (unsigned char *)"Pacemaker Cluster Manager "PACKAGE_VERSION, .id = PCMK_SERVICE_ID, .private_data_size = 0, .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED, .lib_init_fn = pcmk_ipc_connect, .lib_exit_fn = pcmk_ipc_exit, .exec_init_fn = pcmk_startup, .exec_exit_fn = pcmk_shutdown, .config_init_fn = pcmk_config_init, #ifdef AIS_COROSYNC .priority = 50, .lib_engine = pcmk_lib_service, .lib_engine_count = sizeof (pcmk_lib_service) / sizeof (struct corosync_lib_handler), .exec_engine = pcmk_exec_service, .exec_engine_count = sizeof (pcmk_exec_service) / sizeof (struct corosync_exec_handler), #else .lib_service = pcmk_lib_service, .lib_service_count = sizeof (pcmk_lib_service) / sizeof (struct corosync_lib_handler), .exec_service = pcmk_exec_service, .exec_service_count = sizeof (pcmk_exec_service) / sizeof (struct corosync_exec_handler), #endif .confchg_fn = pcmk_peer_update, .exec_dump_fn = pcmk_exec_dump, /* void (*sync_init) (void); */ /* int (*sync_process) (void); */ /* void (*sync_activate) (void); */ /* void (*sync_abort) (void); */ }; /* * Dynamic Loader definition */ struct corosync_service_engine *pcmk_get_handler_ver0 (void); #ifdef AIS_COROSYNC struct corosync_service_engine_iface_ver0 pcmk_service_handler_iface = { .corosync_get_service_engine_ver0 = pcmk_get_handler_ver0 }; #else struct openais_service_handler_iface_ver0 pcmk_service_handler_iface = { .openais_get_service_handler_ver0 = pcmk_get_handler_ver0 }; #endif static struct lcr_iface openais_pcmk_ver0[1] = { { .name = "pacemaker", .version = 0, .versions_replace = 0, .versions_replace_count = 0, .dependencies = 0, .dependency_count = 0, .constructor = NULL, .destructor = NULL, .interfaces = NULL } }; static struct lcr_comp pcmk_comp_ver0 = { .iface_count = 1, .ifaces = openais_pcmk_ver0 }; struct corosync_service_engine *pcmk_get_handler_ver0 (void) { return (&pcmk_service_handler); } __attribute__ ((constructor)) static void register_this_component (void) { lcr_interfaces_set (&openais_pcmk_ver0[0], &pcmk_service_handler_iface); lcr_component_register (&pcmk_comp_ver0); } static int plugin_has_quorum(void) { if((plugin_expected_votes >> 1) < plugin_has_votes) { return 1; } return 0; } static void update_expected_votes(int value) { if(value > 0 && plugin_expected_votes != value) { ais_info("Expected quorum votes %d -> %d", plugin_expected_votes, value); plugin_expected_votes = value; } } /* Create our own local copy of the config so we can navigate it */ static void process_ais_conf(void) { char *value = NULL; hdb_handle_t top_handle = 0; hdb_handle_t local_handle = 0; ais_info("Reading configure"); top_handle = config_find_init(pcmk_api, "logging"); local_handle = config_find_next(pcmk_api, "logging", top_handle); get_config_opt(pcmk_api, local_handle, "debug", &value, "on"); if(ais_get_boolean(value)) { plugin_log_level = LOG_DEBUG; setenv("HA_debug", "1", 1); } else { plugin_log_level = LOG_INFO; setenv("HA_debug", "0", 1); } get_config_opt(pcmk_api, local_handle, "to_file", &value, "off"); if(ais_get_boolean(value)) { get_config_opt(pcmk_api, local_handle, "to_syslog", &value, "on"); if(ais_get_boolean(value) == FALSE) { ais_err("The use of 'to_file: on' is not a replacement for 'to_syslog: on' and is not supported."); ais_err("Using to_file results in most logs being lost as several of the daemons do not run as root"); ais_err("If you really wish to disable syslog, set 'syslog_facility: none'"); } get_config_opt(pcmk_api, local_handle, "logfile", &value, NULL); if(value == NULL) { ais_err("Logging to a file requested but no log file specified"); } else { setenv("HA_logfile", value, 1); } } get_config_opt(pcmk_api, local_handle, "syslog_facility", &value, "daemon"); setenv("HA_logfacility", value, 1); setenv("HA_LOGFACILITY", value, 1); config_find_done(pcmk_api, local_handle); top_handle = config_find_init(pcmk_api, "service"); local_handle = config_find_next(pcmk_api, "service", top_handle); while(local_handle) { value = NULL; pcmk_api->object_key_get(local_handle, "name", strlen("name"), (void**)&value, NULL); if(ais_str_eq("pacemaker", value)) { break; } local_handle = config_find_next(pcmk_api, "service", top_handle); } + get_config_opt(pcmk_api, local_handle, "clustername", &local_cname, "pcmk"); + local_cname_len = strlen(local_cname); + get_config_opt(pcmk_api, local_handle, "use_logd", &value, "no"); setenv("HA_use_logd", value, 1); get_config_opt(pcmk_api, local_handle, "use_mgmtd", &value, "no"); if(ais_get_boolean(value) == FALSE) { int lpc = 0; for (; lpc < SIZEOF(pcmk_children); lpc++) { if(crm_proc_mgmtd & pcmk_children[lpc].flag) { /* Disable mgmtd startup */ pcmk_children[lpc].start_seq = 0; break; } } } config_find_done(pcmk_api, local_handle); } int pcmk_config_init(struct corosync_api_v1 *unused) { return 0; } static void *pcmk_wait_dispatch (void *arg) { struct timespec waitsleep = { .tv_sec = 1, .tv_nsec = 0 }; while(wait_active) { int lpc = 0; for (; lpc < SIZEOF(pcmk_children); lpc++) { if(pcmk_children[lpc].pid > 0) { int status; pid_t pid = wait4( pcmk_children[lpc].pid, &status, WNOHANG, NULL); if(pid == 0) { continue; } else if(pid < 0) { ais_perror("Call to wait4(%s) failed", pcmk_children[lpc].name); continue; } /* cleanup */ pcmk_children[lpc].pid = 0; pcmk_children[lpc].conn = NULL; pcmk_children[lpc].async_conn = NULL; if(WIFSIGNALED(status)) { int sig = WTERMSIG(status); ais_err("Child process %s terminated with signal %d" " (pid=%d, core=%s)", pcmk_children[lpc].name, sig, pid, WCOREDUMP(status)?"true":"false"); } else if (WIFEXITED(status)) { int rc = WEXITSTATUS(status); do_ais_log(rc==0?LOG_NOTICE:LOG_ERR, "Child process %s exited (pid=%d, rc=%d)", pcmk_children[lpc].name, pid, rc); if(rc == 100) { ais_notice("Child process %s no longer wishes" " to be respawned", pcmk_children[lpc].name); pcmk_children[lpc].respawn = FALSE; } } pcmk_children[lpc].respawn_count += 1; if(pcmk_children[lpc].respawn_count > MAX_RESPAWN) { ais_err("Child respawn count exceeded by %s", pcmk_children[lpc].name); pcmk_children[lpc].respawn = FALSE; } if(pcmk_children[lpc].respawn) { ais_notice("Respawning failed child process: %s", pcmk_children[lpc].name); spawn_child(&(pcmk_children[lpc])); } else { send_cluster_id(); } } } sched_yield (); nanosleep (&waitsleep, 0); } return 0; } static uint32_t pcmk_update_nodeid(void) { int last = local_nodeid; #if AIS_COROSYNC local_nodeid = pcmk_api->totem_nodeid_get(); #else local_nodeid = totempg_my_nodeid_get(); #endif if(last != local_nodeid) { if(last == 0) { ais_info("Local node id: %u", local_nodeid); } else { char *last_s = NULL; ais_malloc0(last_s, 32); ais_warn("Detected local node id change: %u -> %u", last, local_nodeid); snprintf(last_s, 31, "%u", last); ais_remove_peer(last_s); ais_free(last_s); } update_member(local_nodeid, 0, 0, 1, 0, local_uname, CRM_NODE_MEMBER, NULL); } return local_nodeid; } int pcmk_startup(struct corosync_api_v1 *init_with) { int rc = 0; int lpc = 0; int start_seq = 1; struct utsname us; struct rlimit cores; static int max = SIZEOF(pcmk_children); struct passwd *pwentry = getpwnam(CRM_DAEMON_USER); pcmk_api = init_with; #ifdef AIS_WHITETANK log_init ("crm"); #endif process_ais_conf(); membership_list = g_hash_table_new_full( g_direct_hash, g_direct_equal, NULL, destroy_ais_node); membership_notify_list = g_hash_table_new(g_direct_hash, g_direct_equal); ipc_client_list = g_hash_table_new(g_direct_hash, g_direct_equal); setenv("HA_COMPRESSION", "bz2", 1); setenv("HA_cluster_type", "openais", 1); ais_info("CRM: Initialized"); log_printf(LOG_INFO, "Logging: Initialized %s\n", __PRETTY_FUNCTION__); rc = getrlimit(RLIMIT_CORE, &cores); if(rc < 0) { ais_perror("Cannot determine current maximum core size."); } if(cores.rlim_max <= 0) { cores.rlim_max = RLIM_INFINITY; rc = setrlimit(RLIMIT_CORE, &cores); if(rc < 0) { ais_perror("Core file generation will remain disabled." " Core files are an important diagnositic tool," " please consider enabling them by default."); } } else { ais_info("Maximum core file size is: %lu", cores.rlim_max); if(system("echo 1 > /proc/sys/kernel/core_uses_pid") != 0) { ais_perror("Could not enable /proc/sys/kernel/core_uses_pid"); } } AIS_CHECK(pwentry != NULL, ais_err("Cluster user %s does not exist", CRM_DAEMON_USER); return TRUE); mkdir(CRM_STATE_DIR, 0750); chown(CRM_STATE_DIR, pwentry->pw_uid, pwentry->pw_gid); mkdir(HA_STATE_DIR"/heartbeat", 0755); /* Used by RAs - Leave owned by root */ mkdir(HA_STATE_DIR"/heartbeat/rsctmp", 0755); /* Used by RAs - Leave owned by root */ rc = uname(&us); AIS_ASSERT(rc == 0); local_uname = ais_strdup(us.nodename); local_uname_len = strlen(local_uname); ais_info("Service: %d", PCMK_SERVICE_ID); ais_info("Local hostname: %s", local_uname); pcmk_update_nodeid(); pthread_create (&pcmk_wait_thread, NULL, pcmk_wait_dispatch, NULL); for (start_seq = 1; start_seq < max; start_seq++) { /* dont start anything with start_seq < 1 */ for (lpc = 0; lpc < max; lpc++) { if(start_seq == pcmk_children[lpc].start_seq) { spawn_child(&(pcmk_children[lpc])); } } } return 0; } /* static void ais_print_node(const char *prefix, struct totem_ip_address *host) { int len = 0; char *buffer = NULL; ais_malloc0(buffer, INET6_ADDRSTRLEN+1); inet_ntop(host->family, host->addr, buffer, INET6_ADDRSTRLEN); len = strlen(buffer); ais_info("%s: %.*s", prefix, len, buffer); ais_free(buffer); } */ #if 0 /* copied here for reference from exec/totempg.c */ char *totempg_ifaces_print (unsigned int nodeid) { static char iface_string[256 * INTERFACE_MAX]; char one_iface[64]; struct totem_ip_address interfaces[INTERFACE_MAX]; char **status; unsigned int iface_count; unsigned int i; int res; iface_string[0] = '\0'; res = totempg_ifaces_get (nodeid, interfaces, &status, &iface_count); if (res == -1) { return ("no interface found for nodeid"); } for (i = 0; i < iface_count; i++) { sprintf (one_iface, "r(%d) ip(%s), ", i, totemip_print (&interfaces[i])); strcat (iface_string, one_iface); } return (iface_string); } #endif static void ais_mark_unseen_peer_dead( gpointer key, gpointer value, gpointer user_data) { int *changed = user_data; crm_node_t *node = value; if(node->last_seen != membership_seq && ais_str_eq(CRM_NODE_LOST, node->state) == FALSE) { ais_info("Node %s was not seen in the previous transition", node->uname); *changed += update_member(node->id, 0, membership_seq, node->votes, node->processes, node->uname, CRM_NODE_LOST, NULL); } } void pcmk_peer_update ( enum totem_configuration_type configuration_type, #ifdef AIS_COROSYNC const unsigned int *member_list, size_t member_list_entries, const unsigned int *left_list, size_t left_list_entries, const unsigned int *joined_list, size_t joined_list_entries, const struct memb_ring_id *ring_id #else unsigned int *member_list, int member_list_entries, unsigned int *left_list, int left_list_entries, unsigned int *joined_list, int joined_list_entries, struct memb_ring_id *ring_id #endif ) { int lpc = 0; int changed = 0; int do_update = 0; AIS_ASSERT(ring_id != NULL); switch(configuration_type) { case TOTEM_CONFIGURATION_REGULAR: do_update = 1; break; case TOTEM_CONFIGURATION_TRANSITIONAL: break; } membership_seq = ring_id->seq; ais_notice("%s membership event on ring %lld: memb=%ld, new=%ld, lost=%ld", do_update?"Stable":"Transitional", ring_id->seq, (long)member_list_entries, (long)joined_list_entries, (long)left_list_entries); if(do_update == 0) { for(lpc = 0; lpc < joined_list_entries; lpc++) { const char *prefix = "new: "; uint32_t nodeid = joined_list[lpc]; ais_info("%s %s %u", prefix, member_uname(nodeid), nodeid); } for(lpc = 0; lpc < member_list_entries; lpc++) { const char *prefix = "memb:"; uint32_t nodeid = member_list[lpc]; ais_info("%s %s %u", prefix, member_uname(nodeid), nodeid); } for(lpc = 0; lpc < left_list_entries; lpc++) { const char *prefix = "lost:"; uint32_t nodeid = left_list[lpc]; ais_info("%s %s %u", prefix, member_uname(nodeid), nodeid); } return; } for(lpc = 0; lpc < joined_list_entries; lpc++) { const char *prefix = "NEW: "; uint32_t nodeid = joined_list[lpc]; crm_node_t *node = NULL; changed += update_member( nodeid, 0, membership_seq, -1, 0, NULL, CRM_NODE_MEMBER, NULL); ais_info("%s %s %u", prefix, member_uname(nodeid), nodeid); node = g_hash_table_lookup(membership_list, GUINT_TO_POINTER(nodeid)); if(node->addr == NULL) { const char *addr = totempg_ifaces_print(nodeid); node->addr = ais_strdup(addr); ais_debug("Node %u has address %s", nodeid, node->addr); } } plugin_has_votes = 0; for(lpc = 0; lpc < member_list_entries; lpc++) { const char *prefix = "MEMB:"; uint32_t nodeid = member_list[lpc]; plugin_has_votes++; changed += update_member( nodeid, 0, membership_seq, -1, 0, NULL, CRM_NODE_MEMBER, NULL); ais_info("%s %s %u", prefix, member_uname(nodeid), nodeid); } for(lpc = 0; lpc < left_list_entries; lpc++) { const char *prefix = "LOST:"; uint32_t nodeid = left_list[lpc]; changed += update_member( nodeid, 0, membership_seq, -1, 0, NULL, CRM_NODE_LOST, NULL); ais_info("%s %s %u", prefix, member_uname(nodeid), nodeid); } if(changed && joined_list_entries == 0 && left_list_entries == 0) { ais_err("Something strange happened: %d", changed); changed = 0; } ais_debug_2("Reaping unseen nodes..."); g_hash_table_foreach(membership_list, ais_mark_unseen_peer_dead, &changed); if(plugin_has_votes > plugin_expected_votes) { update_expected_votes(plugin_has_votes); changed = 1; } if(member_list_entries > 1) { /* Used to set born-on in send_cluster_id()) * We need to wait until we have at least one peer since first * membership id is based on the one before we stopped and isn't reliable */ have_reliable_membership_id = TRUE; } if(changed) { ais_debug("%d nodes changed", changed); pcmk_update_nodeid(); send_member_notification(); } send_cluster_id(); } int pcmk_ipc_exit (void *conn) { int lpc = 0; const char *client = NULL; void *async_conn = conn; for (; lpc < SIZEOF(pcmk_children); lpc++) { if(pcmk_children[lpc].conn == conn) { if(wait_active == FALSE) { /* Make sure the shutdown loop exits */ pcmk_children[lpc].pid = 0; } pcmk_children[lpc].conn = NULL; pcmk_children[lpc].async_conn = NULL; client = pcmk_children[lpc].name; break; } } g_hash_table_remove(membership_notify_list, async_conn); g_hash_table_remove(ipc_client_list, async_conn); do_ais_log(client?LOG_INFO:(LOG_DEBUG+1), "Client %s (conn=%p, async-conn=%p) left", client?client:"unknown-transient", conn, async_conn); return (0); } int pcmk_ipc_connect (void *conn) { /* OpenAIS hasn't finished setting up the connection at this point * Sending messages now messes up the protocol! */ return (0); } /* * Executive message handlers */ void pcmk_cluster_swab(void *msg) { AIS_Message *ais_msg = msg; ais_debug_3("Performing endian conversion..."); ais_msg->id = swab32 (ais_msg->id); ais_msg->size = swab32 (ais_msg->size); ais_msg->is_compressed = swab32 (ais_msg->is_compressed); ais_msg->compressed_size = swab32 (ais_msg->compressed_size); ais_msg->host.id = swab32 (ais_msg->host.id); ais_msg->host.pid = swab32 (ais_msg->host.pid); ais_msg->host.type = swab32 (ais_msg->host.type); ais_msg->host.size = swab32 (ais_msg->host.size); ais_msg->host.local = swab32 (ais_msg->host.local); ais_msg->sender.id = swab32 (ais_msg->sender.id); ais_msg->sender.pid = swab32 (ais_msg->sender.pid); ais_msg->sender.type = swab32 (ais_msg->sender.type); ais_msg->sender.size = swab32 (ais_msg->sender.size); ais_msg->sender.local = swab32 (ais_msg->sender.local); } void pcmk_cluster_callback ( ais_void_ptr *message, unsigned int nodeid) { const AIS_Message *ais_msg = message; ais_debug_2("Message from node %u (%s)", nodeid, nodeid==local_nodeid?"local":"remote"); /* Shouldn't be required... update_member( ais_msg->sender.id, membership_seq, -1, 0, ais_msg->sender.uname, NULL); */ if(ais_msg->host.size == 0 || ais_str_eq(ais_msg->host.uname, local_uname)) { route_ais_message(ais_msg, FALSE); } else { ais_debug_3("Discarding Msg[%d] (dest=%s:%s, from=%s:%s)", ais_msg->id, ais_dest(&(ais_msg->host)), msg_type2text(ais_msg->host.type), ais_dest(&(ais_msg->sender)), msg_type2text(ais_msg->sender.type)); } } void pcmk_cluster_id_swab(void *msg) { struct crm_identify_msg_s *ais_msg = msg; ais_debug_3("Performing endian conversion..."); ais_msg->id = swab32 (ais_msg->id); ais_msg->pid = swab32 (ais_msg->pid); ais_msg->votes = swab32 (ais_msg->votes); ais_msg->processes = swab32 (ais_msg->processes); } void pcmk_cluster_id_callback (ais_void_ptr *message, unsigned int nodeid) { int changed = 0; const struct crm_identify_msg_s *msg = message; if(nodeid != msg->id) { ais_err("Invalid message: Node %u claimed to be node %d", nodeid, msg->id); return; } ais_debug("Node update: %s (%s)", msg->uname, msg->version); changed = update_member( nodeid, msg->born_on, membership_seq, msg->votes, msg->processes, msg->uname, NULL, msg->version); if(changed) { send_member_notification(); } } struct res_overlay { coroipc_response_header_t header __attribute((aligned(8))); char buf[4096]; }; struct res_overlay *res_overlay = NULL; static void send_ipc_ack(void *conn) { if(res_overlay == NULL) { ais_malloc0(res_overlay, sizeof(struct res_overlay)); } res_overlay->header.id = CRM_MESSAGE_IPC_ACK; res_overlay->header.size = sizeof (coroipc_response_header_t); res_overlay->header.error = CS_OK; #ifdef AIS_COROSYNC pcmk_api->ipc_response_send (conn, res_overlay, res_overlay->header.size); #else openais_response_send (conn, res_overlay, res_overlay->header.size); #endif } /* local callbacks */ void pcmk_ipc(void *conn, ais_void_ptr *msg) { AIS_Message *mutable; int type = 0, size = 0; gboolean transient = TRUE; const AIS_Message *ais_msg = (const AIS_Message*)msg; void *async_conn = conn; ais_debug_2("Message from client %p", conn); if(check_message_sanity(msg, ((const AIS_Message*)msg)->data) == FALSE) { /* The message is corrupted - ignore */ send_ipc_ack(conn); msg = NULL; return; } /* Make a copy of the message here and ACK it * The message is only valid until a response is sent * but the response must also be sent _before_ we send anything else */ mutable = ais_msg_copy(ais_msg); AIS_ASSERT(check_message_sanity(mutable, mutable->data)); size = mutable->header.size; /* ais_malloc0(ais_msg, size); */ /* memcpy(ais_msg, msg, size); */ type = mutable->sender.type; ais_debug_3("type: %d local: %d conn: %p host type: %d ais: %d sender pid: %d child pid: %d size: %d", type, mutable->host.local, pcmk_children[type].conn, mutable->host.type, crm_msg_ais, mutable->sender.pid, pcmk_children[type].pid, ((int)SIZEOF(pcmk_children))); if(type > crm_msg_none && type < SIZEOF(pcmk_children)) { /* known child process */ transient = FALSE; } /* If this check fails, the order of pcmk_children probably * doesn't match that of the crm_ais_msg_types enum */ AIS_CHECK(transient || mutable->sender.pid == pcmk_children[type].pid, ais_err("Sender: %d, child[%d]: %d", mutable->sender.pid, type, pcmk_children[type].pid); return); if(transient == FALSE && type > crm_msg_none && mutable->host.local && pcmk_children[type].conn == NULL && mutable->host.type == crm_msg_ais) { AIS_CHECK(mutable->sender.type != mutable->sender.pid, ais_err("Pid=%d, type=%d", mutable->sender.pid, mutable->sender.type)); ais_info("Recorded connection %p for %s/%d", conn, pcmk_children[type].name, pcmk_children[type].pid); pcmk_children[type].conn = conn; pcmk_children[type].async_conn = async_conn; /* Make sure they have the latest membership */ if(pcmk_children[type].flags & crm_flag_members) { char *update = pcmk_generate_membership_data(); g_hash_table_replace(membership_notify_list, async_conn, async_conn); ais_info("Sending membership update "U64T" to %s", membership_seq, pcmk_children[type].name); send_client_msg(async_conn, crm_class_members, crm_msg_none,update); } } else if(transient) { AIS_CHECK(mutable->sender.type == mutable->sender.pid, ais_err("Pid=%d, type=%d", mutable->sender.pid, mutable->sender.type)); g_hash_table_replace(ipc_client_list, async_conn, GUINT_TO_POINTER(mutable->sender.pid)); } mutable->sender.id = local_nodeid; mutable->sender.size = local_uname_len; memset(mutable->sender.uname, 0, MAX_NAME); memcpy(mutable->sender.uname, local_uname, mutable->sender.size); route_ais_message(mutable, TRUE); send_ipc_ack(conn); msg = NULL; ais_free(mutable); } int pcmk_shutdown ( #ifdef AIS_COROSYNC void #else struct objdb_iface_ver0 *objdb #endif ) { int lpc = 0; static int phase = 0; static time_t next_log = 0; static int max = SIZEOF(pcmk_children); if(phase == 0) { ais_notice("Shuting down Pacemaker"); phase = max; } wait_active = FALSE; /* stop the wait loop */ for (; phase > 0; phase--) { /* dont stop anything with start_seq < 1 */ for (lpc = max - 1; lpc >= 0; lpc--) { if(phase != pcmk_children[lpc].start_seq) { continue; } #ifdef AIS_WHITETANK retry: #endif if(pcmk_children[lpc].pid) { pid_t pid = 0; int status = 0; time_t now = time(NULL); if(pcmk_children[lpc].respawn) { next_log = now + 30; pcmk_children[lpc].respawn = FALSE; stop_child(&(pcmk_children[lpc]), SIGTERM); } pid = wait4(pcmk_children[lpc].pid, &status, WNOHANG, NULL); if(pid < 0) { ais_perror("Call to wait4(%s/%d) failed - treating it as stopped", pcmk_children[lpc].name, pcmk_children[lpc].pid); } else if(pid == 0) { if(now >= next_log) { next_log = now + 30; ais_notice("Still waiting for %s (pid=%d, seq=%d) to terminate...", pcmk_children[lpc].name, pcmk_children[lpc].pid, pcmk_children[lpc].start_seq); } #ifdef AIS_WHITETANK { struct timespec waitsleep = { .tv_sec = 1, .tv_nsec = 0 }; sched_yield (); nanosleep (&waitsleep, 0); goto retry; } #else /* Return control to corosync */ return -1; #endif } } /* cleanup */ ais_notice("%s confirmed stopped", pcmk_children[lpc].name); pcmk_children[lpc].async_conn = NULL; pcmk_children[lpc].conn = NULL; pcmk_children[lpc].pid = 0; } } send_cluster_id(); ais_notice("Shutdown complete"); /* TODO: Add back the logsys flush call once its written */ #ifdef AIS_WHITETANK /* Bug bnc#482847, bnc#482905 * * All cluster services are now down, we could allow OpenAIS to continue * unloading plugins, but its kinda new at that and there are a bunch of * race conditions that get exercised. * * Take the easy way out for now (on whitetank) and eventually fix for * CoroSync which is where everyone wants to be eventually anyway */ ais_notice("Forcing clean exit of OpenAIS"); exit(0); #endif return 0; } struct member_loop_data { char *string; }; void member_loop_fn(gpointer key, gpointer value, gpointer user_data) { crm_node_t *node = value; struct member_loop_data *data = user_data; ais_debug_2("Dumping node %u", node->id); data->string = append_member(data->string, node); } char *pcmk_generate_membership_data(void) { int size = 0; struct member_loop_data data; size = 256; ais_malloc0(data.string, size); snprintf(data.string, size, "", membership_seq, plugin_has_quorum()?"true":"false", plugin_expected_votes, plugin_has_votes); g_hash_table_foreach(membership_list, member_loop_fn, &data); size = strlen(data.string); data.string = realloc(data.string, size + 9) ;/* 9 = + nul */ sprintf(data.string + size, ""); return data.string; } void pcmk_nodes(void *conn, ais_void_ptr *msg) { char *data = pcmk_generate_membership_data(); void *async_conn = conn; /* send the ACK before we send any other messages * - but after we no longer need to access the message */ send_ipc_ack(conn); msg = NULL; if(async_conn) { send_client_msg(async_conn, crm_class_members, crm_msg_none, data); } ais_free(data); } void pcmk_remove_member(void *conn, ais_void_ptr *msg) { const AIS_Message *ais_msg = msg; char *data = get_ais_data(ais_msg); send_ipc_ack(conn); msg = NULL; if(data != NULL) { char *bcast = ais_concat("remove-peer", data, ':'); send_cluster_msg(crm_msg_ais, NULL, bcast); ais_info("Sent: %s", bcast); ais_free(bcast); } ais_free(data); } static void send_quorum_details(void *conn) { int size = 256; char *data = NULL; ais_malloc0(data, size); snprintf(data, size, "", membership_seq, plugin_has_quorum()?"true":"false", plugin_expected_votes, plugin_has_votes); send_client_msg(conn, crm_class_quorum, crm_msg_none, data); ais_free(data); } void pcmk_quorum(void *conn, ais_void_ptr *msg) { const AIS_Message *ais_msg = msg; char *data = get_ais_data(ais_msg); send_ipc_ack(conn); msg = NULL; if(data != NULL) { int value = 0; value = ais_get_int(data, NULL); update_expected_votes(value); } send_quorum_details(conn); ais_free(data); } void pcmk_notify(void *conn, ais_void_ptr *msg) { const AIS_Message *ais_msg = msg; char *data = get_ais_data(ais_msg); void *async_conn = conn; int enable = 0; int sender = ais_msg->sender.pid; send_ipc_ack(conn); msg = NULL; if(ais_str_eq("true", data)) { enable = 1; } ais_info("%s node notifications for child %d (%p)", enable?"Enabling":"Disabling", sender, async_conn); if(enable) { g_hash_table_replace(membership_notify_list, async_conn, async_conn); } else { g_hash_table_remove(membership_notify_list, async_conn); } ais_free(data); } void pcmk_nodeid(void *conn, ais_void_ptr *msg) { static int counter = 0; struct crm_ais_nodeid_resp_s resp; ais_debug_2("Sending local nodeid: %d to %p[%d]", local_nodeid, conn, counter); resp.header.id = crm_class_nodeid; resp.header.size = sizeof (struct crm_ais_nodeid_resp_s); resp.header.error = CS_OK; resp.id = local_nodeid; resp.counter = counter++; - memset(resp.uname, 0, 256); + memset(resp.uname, 0, MAX_NAME); memcpy(resp.uname, local_uname, local_uname_len); + memset(resp.cname, 0, MAX_NAME); + memcpy(resp.cname, local_cname, local_cname_len); #ifdef AIS_COROSYNC pcmk_api->ipc_response_send (conn, &resp, resp.header.size); #else openais_response_send (conn, &resp, resp.header.size); #endif } static gboolean ghash_send_update(gpointer key, gpointer value, gpointer data) { if(send_client_msg(value, crm_class_members, crm_msg_none, data) != 0) { /* remove it */ return TRUE; } return FALSE; } void send_member_notification(void) { char *update = pcmk_generate_membership_data(); ais_info("Sending membership update "U64T" to %d children", membership_seq, g_hash_table_size(membership_notify_list)); g_hash_table_foreach_remove(membership_notify_list, ghash_send_update, update); ais_free(update); } gboolean check_message_sanity(const AIS_Message *msg, const char *data) { gboolean sane = TRUE; gboolean repaired = FALSE; int dest = msg->host.type; int tmp_size = msg->header.size - sizeof(AIS_Message); if(sane && msg->header.size == 0) { ais_err("Message with no size"); sane = FALSE; } if(sane && msg->header.error != CS_OK) { ais_err("Message header contains an error: %d", msg->header.error); sane = FALSE; } AIS_CHECK(msg->header.size > sizeof(AIS_Message), ais_err("Message %d size too small: %d < %zu", msg->header.id, msg->header.size, sizeof(AIS_Message)); return FALSE); if(sane && ais_data_len(msg) != tmp_size) { ais_warn("Message payload size is incorrect: expected %d, got %d", ais_data_len(msg), tmp_size); sane = TRUE; } if(sane && ais_data_len(msg) == 0) { ais_err("Message with no payload"); sane = FALSE; } if(sane && data && msg->is_compressed == FALSE) { int str_size = strlen(data) + 1; if(ais_data_len(msg) != str_size) { int lpc = 0; ais_err("Message payload is corrupted: expected %d bytes, got %d", ais_data_len(msg), str_size); sane = FALSE; for(lpc = (str_size - 10); lpc < msg->size; lpc++) { if(lpc < 0) { lpc = 0; } ais_debug_2("bad_data[%d]: %d / '%c'", lpc, data[lpc], data[lpc]); } } } if(sane == FALSE) { AIS_CHECK(sane, ais_err("Invalid message %d: (dest=%s:%s, from=%s:%s.%d, compressed=%d, size=%d, total=%d)", msg->id, ais_dest(&(msg->host)), msg_type2text(dest), ais_dest(&(msg->sender)), msg_type2text(msg->sender.type), msg->sender.pid, msg->is_compressed, ais_data_len(msg), msg->header.size)); } else if(repaired) { ais_err("Repaired message %d: (dest=%s:%s, from=%s:%s.%d, compressed=%d, size=%d, total=%d)", msg->id, ais_dest(&(msg->host)), msg_type2text(dest), ais_dest(&(msg->sender)), msg_type2text(msg->sender.type), msg->sender.pid, msg->is_compressed, ais_data_len(msg), msg->header.size); } else { ais_debug_3("Verified message %d: (dest=%s:%s, from=%s:%s.%d, compressed=%d, size=%d, total=%d)", msg->id, ais_dest(&(msg->host)), msg_type2text(dest), ais_dest(&(msg->sender)), msg_type2text(msg->sender.type), msg->sender.pid, msg->is_compressed, ais_data_len(msg), msg->header.size); } return sane; } static int delivered_transient = 0; static void deliver_transient_msg(gpointer key, gpointer value, gpointer user_data) { int pid = GPOINTER_TO_INT(value); AIS_Message *mutable = user_data; if(pid == mutable->host.type) { int rc = send_client_ipc(key, mutable); delivered_transient++; ais_info("Sent message to %s.%d (rc=%d)", ais_dest(&(mutable->host)), pid, rc); if(rc != 0) { ais_warn("Sending message to %s.%d failed (rc=%d)", ais_dest(&(mutable->host)), pid, rc); log_ais_message(LOG_DEBUG, mutable); } } } gboolean route_ais_message(const AIS_Message *msg, gboolean local_origin) { int rc = 0; int dest = msg->host.type; const char *reason = "unknown"; AIS_Message *mutable = ais_msg_copy(msg); static int service_id = SERVICE_ID_MAKE(PCMK_SERVICE_ID, 0); ais_debug_3("Msg[%d] (dest=%s:%s, from=%s:%s.%d, remote=%s, size=%d)", mutable->id, ais_dest(&(mutable->host)), msg_type2text(dest), ais_dest(&(mutable->sender)), msg_type2text(mutable->sender.type), mutable->sender.pid, local_origin?"false":"true", ais_data_len((mutable))); if(local_origin == FALSE) { if(mutable->host.size == 0 || ais_str_eq(local_uname, mutable->host.uname)) { mutable->host.local = TRUE; } } if(check_message_sanity(mutable, mutable->data) == FALSE) { /* Dont send this message to anyone */ rc = 1; goto bail; } if(mutable->host.local) { void *conn = NULL; const char *lookup = NULL; if(dest == crm_msg_ais) { process_ais_message(mutable); goto bail; } else if(dest == crm_msg_lrmd) { /* lrmd messages are routed via the crm */ dest = crm_msg_crmd; } else if(dest == crm_msg_te) { /* te messages are routed via the crm */ dest = crm_msg_crmd; } else if(dest >= SIZEOF(pcmk_children)) { /* Transient client */ delivered_transient = 0; g_hash_table_foreach(ipc_client_list, deliver_transient_msg, mutable); if(delivered_transient) { ais_debug_2("Sent message to %d transient clients: %d", delivered_transient, dest); goto bail; } else { /* try the crmd */ ais_debug_2("Sending message to transient client %d via crmd", dest); dest = crm_msg_crmd; } } else if(dest == 0) { ais_err("Invalid destination: %d", dest); log_ais_message(LOG_ERR, mutable); log_printf(LOG_ERR, "%s", get_ais_data(mutable)); rc = 1; goto bail; } lookup = msg_type2text(dest); conn = pcmk_children[dest].async_conn; /* the cluster fails in weird and wonderfully obscure ways when this is not true */ AIS_ASSERT(ais_str_eq(lookup, pcmk_children[dest].name)); if(mutable->header.id == service_id) { mutable->header.id = 0; /* reset this back to zero for IPC messages */ } else if(mutable->header.id != 0) { ais_err("reset header id back to zero from %d", mutable->header.id); mutable->header.id = 0; /* reset this back to zero for IPC messages */ } reason = "ipc delivery failed"; rc = send_client_ipc(conn, mutable); } else if(local_origin) { /* forward to other hosts */ ais_debug_3("Forwarding to cluster"); reason = "cluster delivery failed"; rc = send_cluster_msg_raw(mutable); } if(rc != 0) { ais_warn("Sending message to %s.%s failed: %s (rc=%d)", ais_dest(&(mutable->host)), msg_type2text(dest), reason, rc); log_ais_message(LOG_DEBUG, mutable); } bail: ais_free(mutable); return rc==0?TRUE:FALSE; } int send_cluster_msg_raw(const AIS_Message *ais_msg) { int rc = 0; struct iovec iovec; static uint32_t msg_id = 0; AIS_Message *mutable = ais_msg_copy(ais_msg); AIS_ASSERT(local_nodeid != 0); AIS_ASSERT(ais_msg->header.size == (sizeof(AIS_Message) + ais_data_len(ais_msg))); if(mutable->id == 0) { msg_id++; AIS_CHECK(msg_id != 0 /* detect wrap-around */, msg_id++; ais_err("Message ID wrapped around")); mutable->id = msg_id; } mutable->header.error = CS_OK; mutable->header.id = SERVICE_ID_MAKE(PCMK_SERVICE_ID, 0); mutable->sender.id = local_nodeid; mutable->sender.size = local_uname_len; memset(mutable->sender.uname, 0, MAX_NAME); memcpy(mutable->sender.uname, local_uname, mutable->sender.size); iovec.iov_base = (char *)mutable; iovec.iov_len = mutable->header.size; ais_debug_3("Sending message (size=%u)", (unsigned int)iovec.iov_len); #if AIS_COROSYNC rc = pcmk_api->totem_mcast(&iovec, 1, TOTEMPG_SAFE); #else rc = totempg_groups_mcast_joined(openais_group_handle, &iovec, 1, TOTEMPG_SAFE); #endif if(rc == 0 && mutable->is_compressed == FALSE) { ais_debug_2("Message sent: %.80s", mutable->data); } AIS_CHECK(rc == 0, ais_err("Message not sent (%d): %.120s", rc, mutable->data)); ais_free(mutable); return rc; } #define min(x,y) (x)<(y)?(x):(y) void send_cluster_id(void) { int rc = 0; int lpc = 0; int len = 0; struct iovec iovec; struct crm_identify_msg_s *msg = NULL; AIS_ASSERT(local_nodeid != 0); if(local_born_on == 0 && have_reliable_membership_id) { local_born_on = membership_seq; } ais_malloc0(msg, sizeof(struct crm_identify_msg_s)); msg->header.size = sizeof(struct crm_identify_msg_s); msg->id = local_nodeid; /* msg->header.error = CS_OK; */ msg->header.id = SERVICE_ID_MAKE(PCMK_SERVICE_ID, 1); len = min(local_uname_len, MAX_NAME-1); memset(msg->uname, 0, MAX_NAME); memcpy(msg->uname, local_uname, len); len = min(strlen(VERSION), MAX_NAME-1); memset(msg->version, 0, MAX_NAME); memcpy(msg->version, VERSION, len); msg->votes = 1; msg->pid = getpid(); msg->processes = crm_proc_ais; msg->born_on = local_born_on; for (lpc = 0; lpc < SIZEOF(pcmk_children); lpc++) { if(pcmk_children[lpc].pid != 0) { msg->processes |= pcmk_children[lpc].flag; } } ais_debug("Local update: id=%u, born="U64T", seq="U64T"", local_nodeid, local_born_on, membership_seq); update_member( local_nodeid, local_born_on, membership_seq, msg->votes, msg->processes, NULL, NULL, VERSION); iovec.iov_base = (char *)msg; iovec.iov_len = msg->header.size; #if AIS_COROSYNC rc = pcmk_api->totem_mcast(&iovec, 1, TOTEMPG_SAFE); #else rc = totempg_groups_mcast_joined(openais_group_handle, &iovec, 1, TOTEMPG_SAFE); #endif AIS_CHECK(rc == 0, ais_err("Message not sent (%d)", rc)); ais_free(msg); } static gboolean ghash_send_removal(gpointer key, gpointer value, gpointer data) { send_quorum_details(value); if(send_client_msg(value, crm_class_rmpeer, crm_msg_none, data) != 0) { /* remove it */ return TRUE; } return FALSE; } void ais_remove_peer(char *node_id) { uint32_t id = ais_get_int(node_id, NULL); crm_node_t *node = g_hash_table_lookup(membership_list, GUINT_TO_POINTER(id)); if(node == NULL) { ais_info("Peer %u is unknown", id); } else if(ais_str_eq(CRM_NODE_MEMBER, node->state)) { ais_warn("Peer %u/%s is still active", id, node->uname); } else if(g_hash_table_remove(membership_list, GUINT_TO_POINTER(id))) { plugin_expected_votes--; ais_notice("Removed dead peer %u from the membership list", id); ais_info("Sending removal of %u to %d children", id, g_hash_table_size(membership_notify_list)); g_hash_table_foreach_remove(membership_notify_list, ghash_send_removal, node_id); } else { ais_warn("Peer %u/%s was not removed", id, node->uname); } } gboolean process_ais_message(const AIS_Message *msg) { int len = ais_data_len(msg); char *data = get_ais_data(msg); do_ais_log(LOG_DEBUG, "Msg[%d] (dest=%s:%s, from=%s:%s.%d, remote=%s, size=%d): %.90s", msg->id, ais_dest(&(msg->host)), msg_type2text(msg->host.type), ais_dest(&(msg->sender)), msg_type2text(msg->sender.type), msg->sender.pid, msg->sender.uname==local_uname?"false":"true", ais_data_len(msg), data); if(data && len > 12 && strncmp("remove-peer:", data, 12) == 0) { char *node = data+12; ais_remove_peer(node); } ais_free(data); return TRUE; } static void member_dump_fn(gpointer key, gpointer value, gpointer user_data) { crm_node_t *node = value; ais_info(" node id:%u, uname=%s state=%s processes=%.16x born="U64T" seen="U64T" addr=%s version=%s", node->id, node->uname?node->uname:"-unknown-", node->state, node->processes, node->born, node->last_seen, node->addr?node->addr:"-unknown-", node->version?node->version:"-unknown-"); } void pcmk_exec_dump(void) { /* Called after SIG_USR2 */ process_ais_conf(); ais_info("Local id: %u, uname: %s, born: "U64T, local_nodeid, local_uname, local_born_on); ais_info("Membership id: "U64T", quorate: %s, expected: %u, actual: %u", membership_seq, plugin_has_quorum()?"true":"false", plugin_expected_votes, plugin_has_votes); g_hash_table_foreach(membership_list, member_dump_fn, NULL); } diff --git a/lib/cib/cib_utils.c b/lib/cib/cib_utils.c index 4847354a80..71d6a2f5cd 100644 --- a/lib/cib/cib_utils.c +++ b/lib/cib/cib_utils.c @@ -1,894 +1,894 @@ /* * Copyright (c) 2004 International Business Machines * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include #include #include #include #include #include #include #include #include #include #include #include #include struct config_root_s { const char *name; const char *parent; const char *path; }; /* * "//crm_config" will also work in place of "/cib/configuration/crm_config" * The / prefix means find starting from the root, whereas the // prefix means * find anywhere and risks multiple matches */ struct config_root_s known_paths[] = { { NULL, NULL, "//cib" }, { XML_TAG_CIB, NULL, "//cib" }, { XML_CIB_TAG_STATUS, "/cib", "//cib/status" }, { XML_CIB_TAG_CONFIGURATION,"/cib", "//cib/configuration" }, { XML_CIB_TAG_CRMCONFIG, "/cib/configuration", "//cib/configuration/crm_config" }, { XML_CIB_TAG_NODES, "/cib/configuration", "//cib/configuration/nodes" }, { XML_CIB_TAG_RESOURCES, "/cib/configuration", "//cib/configuration/resources" }, { XML_CIB_TAG_CONSTRAINTS, "/cib/configuration", "//cib/configuration/constraints" }, { XML_CIB_TAG_OPCONFIG, "/cib/configuration", "//cib/configuration/op_defaults" }, { XML_CIB_TAG_RSCCONFIG, "/cib/configuration", "//cib/configuration/rsc_defaults" }, { XML_CIB_TAG_SECTION_ALL, NULL, "//cib" }, }; const char * cib_error2string(enum cib_errors return_code) { const char *error_msg = NULL; switch(return_code) { case cib_bad_permissions: error_msg = "bad permissions for the on-disk configuration. shutdown heartbeat and repair."; break; case cib_bad_digest: error_msg = "the on-disk configuration was manually altered. shutdown heartbeat and repair."; break; case cib_bad_config: error_msg = "the on-disk configuration is not valid"; break; case cib_msg_field_add: error_msg = "failed adding field to cib message"; break; case cib_id_check: error_msg = "missing id or id-collision detected"; break; case cib_operation: error_msg = "invalid operation"; break; case cib_create_msg: error_msg = "couldnt create cib message"; break; case cib_client_gone: error_msg = "client left before we could send reply"; break; case cib_not_connected: error_msg = "not connected"; break; case cib_not_authorized: error_msg = "not authorized"; break; case cib_send_failed: error_msg = "send failed"; break; case cib_reply_failed: error_msg = "reply failed"; break; case cib_return_code: error_msg = "no return code"; break; case cib_output_ptr: error_msg = "nowhere to store output"; break; case cib_output_data: error_msg = "corrupt output data"; break; case cib_connection: error_msg = "connection failed"; break; case cib_callback_register: error_msg = "couldnt register callback channel"; break; case cib_authentication: error_msg = ""; break; case cib_registration_msg: error_msg = "invalid registration msg"; break; case cib_callback_token: error_msg = "callback token not found"; break; case cib_missing: error_msg = "cib object missing"; break; case cib_variant: error_msg = "unknown/corrupt cib variant"; break; case CIBRES_MISSING_ID: error_msg = "The id field is missing"; break; case CIBRES_MISSING_TYPE: error_msg = "The type field is missing"; break; case CIBRES_MISSING_FIELD: error_msg = "A required field is missing"; break; case CIBRES_OBJTYPE_MISMATCH: error_msg = "CIBRES_OBJTYPE_MISMATCH"; break; case cib_EXISTS: error_msg = "The object already exists"; break; case cib_NOTEXISTS: error_msg = "The object/attribute does not exist"; break; case CIBRES_CORRUPT: error_msg = "The CIB is corrupt"; break; case cib_NOOBJECT: error_msg = "The update was empty"; break; case cib_NOPARENT: error_msg = "The parent object does not exist"; break; case cib_NODECOPY: error_msg = "Failed while copying update"; break; case CIBRES_OTHER: error_msg = "CIBRES_OTHER"; break; case cib_ok: error_msg = "ok"; break; case cib_unknown: error_msg = "Unknown error"; break; case cib_STALE: error_msg = "Discarded old update"; break; case cib_ACTIVATION: error_msg = "Activation Failed"; break; case cib_NOSECTION: error_msg = "Required section was missing"; break; case cib_NOTSUPPORTED: error_msg = "The action/feature is not supported"; break; case cib_not_master: error_msg = "Local service is not the master instance"; break; case cib_client_corrupt: error_msg = "Service client not valid"; break; case cib_remote_timeout: error_msg = "Remote node did not respond"; break; case cib_master_timeout: error_msg = "No master service is currently active"; break; case cib_revision_unsupported: error_msg = "The required CIB revision number is not supported"; break; case cib_revision_unknown: error_msg = "The CIB revision number could not be determined"; break; case cib_missing_data: error_msg = "Required data for this CIB API call not found"; break; case cib_no_quorum: error_msg = "Write requires quorum"; break; case cib_diff_failed: error_msg = "Application of an update diff failed"; break; case cib_diff_resync: error_msg = "Application of an update diff failed, requesting a full refresh"; break; case cib_bad_section: error_msg = "Invalid CIB section specified"; break; case cib_old_data: error_msg = "Update was older than existing configuration"; break; case cib_dtd_validation: error_msg = "Update does not conform to the configured schema/DTD"; break; case cib_invalid_argument: error_msg = "Invalid argument"; break; case cib_transform_failed: error_msg = "Schema transform failed"; break; } if(error_msg == NULL) { crm_err("Unknown CIB Error Code: %d", return_code); error_msg = ""; } return error_msg; } int cib_section2enum(const char *a_section) { if(a_section == NULL || strcasecmp(a_section, "all") == 0) { return cib_section_all; } else if(strcasecmp(a_section, XML_CIB_TAG_NODES) == 0) { return cib_section_nodes; } else if(strcasecmp(a_section, XML_CIB_TAG_STATUS) == 0) { return cib_section_status; } else if(strcasecmp(a_section, XML_CIB_TAG_CONSTRAINTS) == 0) { return cib_section_constraints; } else if(strcasecmp(a_section, XML_CIB_TAG_RESOURCES) == 0) { return cib_section_resources; } else if(strcasecmp(a_section, XML_CIB_TAG_CRMCONFIG) == 0) { return cib_section_crmconfig; } crm_err("Unknown CIB section: %s", a_section); return cib_section_none; } int cib_compare_generation(xmlNode *left, xmlNode *right) { int lpc = 0; const char *attributes[] = { XML_ATTR_GENERATION_ADMIN, XML_ATTR_GENERATION, XML_ATTR_NUMUPDATES, }; crm_log_xml_debug_3(left, "left"); crm_log_xml_debug_3(right, "right"); for(lpc = 0; lpc < DIMOF(attributes); lpc++) { int int_elem_l = -1; int int_elem_r = -1; const char *elem_r = NULL; const char *elem_l = crm_element_value(left, attributes[lpc]); if(right != NULL) { elem_r = crm_element_value(right, attributes[lpc]); } if(elem_l != NULL) { int_elem_l = crm_parse_int(elem_l, NULL); } if(elem_r != NULL) { int_elem_r = crm_parse_int(elem_r, NULL); } if(int_elem_l < int_elem_r) { crm_debug_2("%s (%s < %s)", attributes[lpc], crm_str(elem_l), crm_str(elem_r)); return -1; } else if(int_elem_l > int_elem_r) { crm_debug_2("%s (%s > %s)", attributes[lpc], crm_str(elem_l), crm_str(elem_r)); return 1; } } return 0; } xmlNode* get_cib_copy(cib_t *cib) { xmlNode *xml_cib; int options = cib_scope_local|cib_sync_call; if(cib->cmds->query(cib, NULL, &xml_cib, options) != cib_ok) { crm_err("Couldnt retrieve the CIB"); return NULL; } else if(xml_cib == NULL) { crm_err("The CIB result was empty"); return NULL; } if(safe_str_eq(crm_element_name(xml_cib), XML_TAG_CIB)) { return xml_cib; } free_xml(xml_cib); return NULL; } xmlNode* cib_get_generation(cib_t *cib) { xmlNode *the_cib = get_cib_copy(cib); xmlNode *generation = create_xml_node( NULL, XML_CIB_TAG_GENERATION_TUPPLE); if(the_cib != NULL) { copy_in_properties(generation, the_cib); free_xml(the_cib); } return generation; } void log_cib_diff(int log_level, xmlNode *diff, const char *function) { int add_updates = 0; int add_epoch = 0; int add_admin_epoch = 0; int del_updates = 0; int del_epoch = 0; int del_admin_epoch = 0; if(diff == NULL) { return; } cib_diff_version_details( diff, &add_admin_epoch, &add_epoch, &add_updates, &del_admin_epoch, &del_epoch, &del_updates); if(add_updates != del_updates) { do_crm_log(log_level, "%s: Diff: --- %d.%d.%d", function, del_admin_epoch, del_epoch, del_updates); do_crm_log(log_level, "%s: Diff: +++ %d.%d.%d", function, add_admin_epoch, add_epoch, add_updates); } else if(diff != NULL) { do_crm_log(log_level, "%s: Local-only Change: %d.%d.%d", function, add_admin_epoch, add_epoch, add_updates); } log_xml_diff(log_level, diff, function); } gboolean cib_version_details( xmlNode *cib, int *admin_epoch, int *epoch, int *updates) { if(cib == NULL) { *admin_epoch = -1; *epoch = -1; *updates = -1; return FALSE; } else { crm_element_value_int(cib, XML_ATTR_GENERATION, epoch); crm_element_value_int(cib, XML_ATTR_NUMUPDATES, updates); crm_element_value_int(cib, XML_ATTR_GENERATION_ADMIN, admin_epoch); } return TRUE; } gboolean cib_diff_version_details( xmlNode *diff, int *admin_epoch, int *epoch, int *updates, int *_admin_epoch, int *_epoch, int *_updates) { xmlNode *tmp = NULL; tmp = find_xml_node(diff, "diff-added", FALSE); cib_version_details(tmp, admin_epoch, epoch, updates); tmp = find_xml_node(diff, "diff-removed", FALSE); cib_version_details(tmp, _admin_epoch, _epoch, _updates); return TRUE; } /* * The caller should never free the return value */ const char *get_object_path(const char *object_type) { int lpc = 0; int max = DIMOF(known_paths); for(; lpc < max; lpc++) { if((object_type == NULL && known_paths[lpc].name == NULL) || safe_str_eq(object_type, known_paths[lpc].name)) { return known_paths[lpc].path; } } return NULL; } const char *get_object_parent(const char *object_type) { int lpc = 0; int max = DIMOF(known_paths); for(; lpc < max; lpc++) { if(safe_str_eq(object_type, known_paths[lpc].name)) { return known_paths[lpc].parent; } } return NULL; } xmlNode* get_object_root(const char *object_type, xmlNode *the_root) { const char *xpath = get_object_path(object_type); if(xpath == NULL) { return the_root; /* or return NULL? */ } return get_xpath_object(xpath, the_root, LOG_DEBUG_2); } xmlNode* create_cib_fragment_adv( xmlNode *update, const char *update_section, const char *source) { xmlNode *cib = NULL; gboolean whole_cib = FALSE; xmlNode *object_root = NULL; char *local_section = NULL; /* crm_debug("Creating a blank fragment: %s", update_section); */ if(update == NULL && update_section == NULL) { crm_debug_3("Creating a blank fragment"); update = createEmptyCib(); crm_xml_add(cib, XML_ATTR_ORIGIN, source); return update; } else if(update == NULL) { crm_err("No update to create a fragment for"); return NULL; } CRM_CHECK(update_section != NULL, return NULL); if(safe_str_eq(crm_element_name(update), XML_TAG_CIB)) { whole_cib = TRUE; } if(whole_cib == FALSE) { cib = createEmptyCib(); crm_xml_add(cib, XML_ATTR_ORIGIN, source); object_root = get_object_root(update_section, cib); add_node_copy(object_root, update); } else { cib = copy_xml(update); crm_xml_add(cib, XML_ATTR_ORIGIN, source); } crm_free(local_section); crm_debug_3("Verifying created fragment"); return cib; } /* * It is the callers responsibility to free both the new CIB (output) * and the new CIB (input) */ xmlNode* createEmptyCib(void) { xmlNode *cib_root = NULL, *config = NULL, *status = NULL; cib_root = create_xml_node(NULL, XML_TAG_CIB); config = create_xml_node(cib_root, XML_CIB_TAG_CONFIGURATION); status = create_xml_node(cib_root, XML_CIB_TAG_STATUS); /* crm_xml_add(cib_root, "version", "1"); */ create_xml_node(config, XML_CIB_TAG_CRMCONFIG); create_xml_node(config, XML_CIB_TAG_NODES); create_xml_node(config, XML_CIB_TAG_RESOURCES); create_xml_node(config, XML_CIB_TAG_CONSTRAINTS); return cib_root; } static unsigned int dtd_throttle = 0; enum cib_errors cib_perform_op(const char *op, int call_options, cib_op_t *fn, gboolean is_query, const char *section, xmlNode *req, xmlNode *input, gboolean manage_counters, gboolean *config_changed, xmlNode *current_cib, xmlNode **result_cib, xmlNode **diff, xmlNode **output) { int rc = cib_ok; gboolean check_dtd = TRUE; xmlNode *scratch = NULL; xmlNode *local_diff = NULL; const char *current_dtd = "unknown"; CRM_CHECK(output != NULL, return cib_output_data); CRM_CHECK(result_cib != NULL, return cib_output_data); CRM_CHECK(config_changed != NULL, return cib_output_data); *output = NULL; *result_cib = NULL; *config_changed = FALSE; if(fn == NULL) { return cib_operation; } if(is_query) { rc = (*fn)(op, call_options, section, req, input, current_cib, result_cib, output); return rc; } scratch = copy_xml(current_cib); rc = (*fn)(op, call_options, section, req, input, current_cib, &scratch, output); CRM_CHECK(current_cib != scratch, return cib_unknown); if(rc == cib_ok && scratch == NULL) { rc = cib_unknown; } if(rc == cib_ok && current_cib) { int old = 0; int new = 0; crm_element_value_int(scratch, XML_ATTR_GENERATION_ADMIN, &new); crm_element_value_int(current_cib, XML_ATTR_GENERATION_ADMIN, &old); if(old > new) { crm_err("%s went backwards: %d -> %d (Opts: 0x%x)", XML_ATTR_GENERATION_ADMIN, old, new, call_options); crm_log_xml_warn(req, "Bad Op"); crm_log_xml_warn(input, "Bad Data"); rc = cib_old_data; } else if(old == new) { crm_element_value_int(scratch, XML_ATTR_GENERATION, &new); crm_element_value_int(current_cib, XML_ATTR_GENERATION, &old); if(old > new) { crm_err("%s went backwards: %d -> %d (Opts: 0x%x)", XML_ATTR_GENERATION, old, new, call_options); crm_log_xml_warn(req, "Bad Op"); crm_log_xml_warn(input, "Bad Data"); rc = cib_old_data; } } } if(rc == cib_ok) { fix_plus_plus_recursive(scratch); current_dtd = crm_element_value(scratch, XML_ATTR_VALIDATION); if(manage_counters) { local_diff = diff_xml_object(current_cib, scratch, FALSE); *config_changed = cib_config_changed(local_diff); if(*config_changed) { cib_update_counter(scratch, XML_ATTR_NUMUPDATES, TRUE); cib_update_counter(scratch, XML_ATTR_GENERATION, FALSE); } else if(local_diff != NULL){ cib_update_counter(scratch, XML_ATTR_NUMUPDATES, FALSE); if(dtd_throttle++ % 20) { check_dtd = FALSE; /* Throttle the amount of costly validation we perform due to status updates * a) we don't really care whats in the status section * b) we don't validate any of it's contents at the moment anyway */ } } } } if(diff != NULL && local_diff != NULL) { /* Only fix the diff if we'll return it... */ xmlNode *cib = NULL; xmlNode *diff_child = NULL; const char *tag = NULL; const char *value = NULL; tag = "diff-removed"; diff_child = find_xml_node(local_diff, tag, FALSE); if(diff_child == NULL) { diff_child = create_xml_node(local_diff, tag); } tag = XML_TAG_CIB; cib = find_xml_node(diff_child, tag, FALSE); if(cib == NULL) { cib = create_xml_node(diff_child, tag); } tag = XML_ATTR_GENERATION_ADMIN; value = crm_element_value(current_cib, tag); crm_xml_add(diff_child, tag, value); if(*config_changed) { crm_xml_add(cib, tag, value); } tag = XML_ATTR_GENERATION; value = crm_element_value(current_cib, tag); crm_xml_add(diff_child, tag, value); if(*config_changed) { crm_xml_add(cib, tag, value); } tag = XML_ATTR_NUMUPDATES; value = crm_element_value(current_cib, tag); crm_xml_add(cib, tag, value); crm_xml_add(diff_child, tag, value); tag = "diff-added"; diff_child = find_xml_node(local_diff, tag, FALSE); if(diff_child == NULL) { diff_child = create_xml_node(local_diff, tag); } tag = XML_TAG_CIB; cib = find_xml_node(diff_child, tag, FALSE); if(cib == NULL) { cib = create_xml_node(diff_child, tag); } tag = XML_ATTR_GENERATION_ADMIN; value = crm_element_value(scratch, tag); crm_xml_add(diff_child, tag, value); if(*config_changed) { crm_xml_add(cib, tag, value); } tag = XML_ATTR_GENERATION; value = crm_element_value(scratch, tag); crm_xml_add(diff_child, tag, value); if(*config_changed) { crm_xml_add(cib, tag, value); } tag = XML_ATTR_NUMUPDATES; value = crm_element_value(scratch, tag); crm_xml_add(cib, tag, value); crm_xml_add(diff_child, tag, value); *diff = local_diff; local_diff = NULL; } if(rc == cib_ok && check_dtd && validate_xml(scratch, NULL, TRUE) == FALSE) { crm_warn("Updated CIB does not validate against %s schema/dtd", crm_str(current_dtd)); rc = cib_dtd_validation; } *result_cib = scratch; free_xml(local_diff); return rc; } int get_channel_token(IPC_Channel *ch, char **token) { int rc = cib_ok; xmlNode *reg_msg = NULL; const char *msg_type = NULL; const char *tmp_ticket = NULL; CRM_CHECK(ch != NULL, return cib_missing); CRM_CHECK(token != NULL, return cib_output_ptr); crm_debug_4("Waiting for msg on command channel"); reg_msg = xmlfromIPC(ch, MAX_IPC_DELAY); if(ch->ops->get_chan_status(ch) != IPC_CONNECT) { crm_err("No reply message - disconnected"); free_xml(reg_msg); return cib_not_connected; } else if(reg_msg == NULL) { crm_err("No reply message - empty"); return cib_reply_failed; } msg_type = crm_element_value(reg_msg, F_CIB_OPERATION); tmp_ticket = crm_element_value(reg_msg, F_CIB_CLIENTID); if(safe_str_neq(msg_type, CRM_OP_REGISTER) ) { crm_err("Invalid registration message: %s", msg_type); rc = cib_registration_msg; } else if(tmp_ticket == NULL) { rc = cib_callback_token; } else { *token = crm_strdup(tmp_ticket); } free_xml(reg_msg); - return cib_ok; + return rc; } xmlNode * cib_create_op( int call_id, const char *token, const char *op, const char *host, const char *section, xmlNode *data, int call_options) { int rc = HA_OK; xmlNode *op_msg = create_xml_node(NULL, "cib_command"); CRM_CHECK(op_msg != NULL, return NULL); CRM_CHECK(token != NULL, return NULL); crm_xml_add(op_msg, F_XML_TAGNAME, "cib_command"); crm_xml_add(op_msg, F_TYPE, T_CIB); crm_xml_add(op_msg, F_CIB_CALLBACK_TOKEN, token); crm_xml_add(op_msg, F_CIB_OPERATION, op); crm_xml_add(op_msg, F_CIB_HOST, host); crm_xml_add(op_msg, F_CIB_SECTION, section); crm_xml_add_int(op_msg, F_CIB_CALLID, call_id); crm_debug_4("Sending call options: %.8lx, %d", (long)call_options, call_options); crm_xml_add_int(op_msg, F_CIB_CALLOPTS, call_options); if(data != NULL) { add_message_xml(op_msg, F_CIB_CALLDATA, data); } if (rc != HA_OK) { crm_err("Failed to create CIB operation message"); crm_log_xml(LOG_ERR, "op", op_msg); free_xml(op_msg); return NULL; } if(call_options & cib_inhibit_bcast) { CRM_CHECK((call_options & cib_scope_local), return NULL); } return op_msg; } void cib_native_callback(cib_t *cib, xmlNode *msg, int call_id, int rc) { xmlNode *output = NULL; cib_callback_client_t *blob = NULL; cib_callback_client_t local_blob; local_blob.id = NULL; local_blob.callback = NULL; local_blob.user_data = NULL; local_blob.only_success = FALSE; if(msg != NULL) { crm_element_value_int(msg, F_CIB_RC, &rc); crm_element_value_int(msg, F_CIB_CALLID, &call_id); output = get_message_xml(msg, F_CIB_CALLDATA); } blob = g_hash_table_lookup( cib_op_callback_table, GINT_TO_POINTER(call_id)); if(blob != NULL) { local_blob = *blob; blob = NULL; remove_cib_op_callback(call_id, FALSE); } else { crm_debug_2("No callback found for call %d", call_id); local_blob.callback = NULL; } if(cib == NULL) { crm_debug("No cib object supplied"); } if(rc == cib_diff_resync) { /* This is an internal value that clients do not and should not care about */ rc = cib_ok; } if(local_blob.callback != NULL && (rc == cib_ok || local_blob.only_success == FALSE)) { crm_debug_2("Invoking callback %s for call %d", crm_str(local_blob.id), call_id); local_blob.callback(msg, call_id, rc, output, local_blob.user_data); } else if(cib && cib->op_callback == NULL && rc != cib_ok) { crm_warn("CIB command failed: %s", cib_error2string(rc)); crm_log_xml(LOG_DEBUG, "Failed CIB Update", msg); } if(cib && cib->op_callback != NULL) { crm_debug_2("Invoking global callback for call %d", call_id); cib->op_callback(msg, call_id, rc, output); } crm_debug_4("OP callback activated."); } void cib_native_notify(gpointer data, gpointer user_data) { xmlNode *msg = user_data; cib_notify_client_t *entry = data; const char *event = NULL; if(msg == NULL) { crm_warn("Skipping callback - NULL message"); return; } event = crm_element_value(msg, F_SUBTYPE); if(entry == NULL) { crm_warn("Skipping callback - NULL callback client"); return; } else if(entry->callback == NULL) { crm_warn("Skipping callback - NULL callback"); return; } else if(safe_str_neq(entry->event, event)) { crm_debug_4("Skipping callback - event mismatch %p/%s vs. %s", entry, entry->event, event); return; } crm_debug_4("Invoking callback for %p/%s event...", entry, event); entry->callback(event, msg); crm_debug_4("Callback invoked..."); } gboolean determine_host(cib_t *cib_conn, char **node_uname, char **node_uuid) { CRM_CHECK(node_uname != NULL, return FALSE); if(*node_uname == NULL) { struct utsname name; if(uname(&name) < 0) { crm_perror(LOG_ERR,"uname(2) call failed"); return FALSE; } *node_uname = crm_strdup(name.nodename); crm_info("Detected uname: %s", *node_uname); } if(cib_conn && *node_uname != NULL && node_uuid != NULL && *node_uuid == NULL) { int rc = query_node_uuid(cib_conn, *node_uname, node_uuid); if(rc != cib_ok) { fprintf(stderr,"Could not map uname=%s to a UUID: %s\n", *node_uname, cib_error2string(rc)); return FALSE; } crm_info("Mapped %s to %s", *node_uname, crm_str(*node_uuid)); } return TRUE; } diff --git a/lib/common/ais.c b/lib/common/ais.c index d75aff2a07..df4b25fac6 100644 --- a/lib/common/ais.c +++ b/lib/common/ais.c @@ -1,738 +1,752 @@ /* * Copyright (C) 2004 Andrew Beekhof * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include "stack.h" #ifdef AIS_COROSYNC # include #endif enum crm_ais_msg_types text2msg_type(const char *text) { int type = crm_msg_none; CRM_CHECK(text != NULL, return type); if(safe_str_eq(text, "ais")) { type = crm_msg_ais; } else if(safe_str_eq(text, "crm_plugin")) { type = crm_msg_ais; } else if(safe_str_eq(text, CRM_SYSTEM_CIB)) { type = crm_msg_cib; } else if(safe_str_eq(text, CRM_SYSTEM_CRMD)) { type = crm_msg_crmd; } else if(safe_str_eq(text, CRM_SYSTEM_DC)) { type = crm_msg_crmd; } else if(safe_str_eq(text, CRM_SYSTEM_TENGINE)) { type = crm_msg_te; } else if(safe_str_eq(text, CRM_SYSTEM_PENGINE)) { type = crm_msg_pe; } else if(safe_str_eq(text, CRM_SYSTEM_LRMD)) { type = crm_msg_lrmd; } else if(safe_str_eq(text, CRM_SYSTEM_STONITHD)) { type = crm_msg_stonithd; } else if(safe_str_eq(text, "stonith-ng")) { type = crm_msg_stonith_ng; } else if(safe_str_eq(text, "attrd")) { type = crm_msg_attrd; } else { /* This will normally be a transient client rather than * a cluster daemon. Set the type to the pid of the client */ int scan_rc = sscanf(text, "%d", &type); if(scan_rc != 1) { /* Ensure its sane */ type = crm_msg_none; } } return type; } char *get_ais_data(const AIS_Message *msg) { int rc = BZ_OK; char *uncompressed = NULL; unsigned int new_size = msg->size + 1; if(msg->is_compressed == FALSE) { crm_debug_2("Returning uncompressed message data"); uncompressed = strdup(msg->data); } else { crm_debug_2("Decompressing message data"); crm_malloc0(uncompressed, new_size); rc = BZ2_bzBuffToBuffDecompress( uncompressed, &new_size, (char*)msg->data, msg->compressed_size, 1, 0); CRM_ASSERT(rc = BZ_OK); CRM_ASSERT(new_size == msg->size); } return uncompressed; } #if SUPPORT_AIS int ais_fd_sync = -1; int ais_fd_async = -1; /* never send messages via this channel */ void *ais_ipc_ctx = NULL; #ifdef AIS_COROSYNC # ifndef TRADITIONAL_AIS_IPC hdb_handle_t ais_ipc_handle = 0; # endif #endif GFDSource *ais_source = NULL; GFDSource *ais_source_sync = NULL; +static char *ais_cluster_name = NULL; gboolean get_ais_nodeid(uint32_t *id, char **uname) { struct iovec iov; int retries = 0; int rc = CS_OK; coroipc_response_header_t header; struct crm_ais_nodeid_resp_s answer; header.error = CS_OK; header.id = crm_class_nodeid; header.size = sizeof(coroipc_response_header_t); CRM_CHECK(id != NULL, return FALSE); CRM_CHECK(uname != NULL, return FALSE); iov.iov_base = &header; iov.iov_len = header.size; retry: errno = 0; #ifdef TRADITIONAL_AIS_IPC rc = saSendReceiveReply(ais_fd_sync, &header, header.size, &answer, sizeof (struct crm_ais_nodeid_resp_s)); #else # ifdef AIS_WHITETANK rc = openais_msg_send_reply_receive( ais_ipc_ctx, &iov, 1, &answer, sizeof (answer)); # else rc = coroipcc_msg_send_reply_receive( ais_ipc_handle, &iov, 1, &answer, sizeof (answer)); # endif #endif if(rc == CS_OK) { CRM_CHECK(answer.header.size == sizeof (struct crm_ais_nodeid_resp_s), crm_err("Odd message: id=%d, size=%d, error=%d", answer.header.id, answer.header.size, answer.header.error)); CRM_CHECK(answer.header.id == crm_class_nodeid, crm_err("Bad response id: %d", answer.header.id)); } if(rc == CS_ERR_TRY_AGAIN && retries < 20) { retries++; crm_info("Peer overloaded: Re-sending message (Attempt %d of 20)", retries); sleep(retries); /* Proportional back off */ goto retry; } if(rc != CS_OK) { crm_err("Sending nodeid request: FAILED (rc=%d): %s", rc, ais_error2text(rc)); return FALSE; } else if(answer.header.error != CS_OK) { crm_err("Bad response from peer: (rc=%d): %s", rc, ais_error2text(rc)); return FALSE; } - crm_info("Server details: id=%u uname=%s", answer.id, answer.uname); + crm_info("Server details: id=%u uname=%s cname=%s", + answer.id, answer.uname, answer.cname); *id = answer.id; *uname = crm_strdup(answer.uname); + ais_cluster_name = crm_strdup(answer.cname); + return TRUE; } +gboolean crm_get_cluster_name(char **cname) +{ + CRM_CHECK(cname != NULL, return FALSE); + if(ais_cluster_name) { + *cname = crm_strdup(ais_cluster_name); + return TRUE; + } + return FALSE; +} + gboolean send_ais_text(int class, const char *data, gboolean local, const char *node, enum crm_ais_msg_types dest) { static int msg_id = 0; static int local_pid = 0; int retries = 0; int rc = CS_OK; int buf_len = sizeof(coroipc_response_header_t); char *buf = NULL; struct iovec iov; coroipc_response_header_t *header; AIS_Message *ais_msg = NULL; enum crm_ais_msg_types sender = text2msg_type(crm_system_name); /* There are only 6 handlers registered to crm_lib_service in plugin.c */ CRM_CHECK(class < 6, crm_err("Invalid message class: %d", class); return FALSE); if(data == NULL) { data = ""; } if(local_pid == 0) { local_pid = getpid(); } if(sender == crm_msg_none) { sender = local_pid; } crm_malloc0(ais_msg, sizeof(AIS_Message)); ais_msg->id = msg_id++; ais_msg->header.id = class; ais_msg->header.error = CS_OK; ais_msg->host.type = dest; ais_msg->host.local = local; if(node) { ais_msg->host.size = strlen(node); memset(ais_msg->host.uname, 0, MAX_NAME); memcpy(ais_msg->host.uname, node, ais_msg->host.size); ais_msg->host.id = 0; } else { ais_msg->host.size = 0; memset(ais_msg->host.uname, 0, MAX_NAME); ais_msg->host.id = 0; } ais_msg->sender.type = sender; ais_msg->sender.pid = local_pid; ais_msg->sender.size = 0; memset(ais_msg->sender.uname, 0, MAX_NAME); ais_msg->sender.id = 0; ais_msg->size = 1 + strlen(data); if(ais_msg->size < CRM_BZ2_THRESHOLD) { failback: crm_realloc(ais_msg, sizeof(AIS_Message) + ais_msg->size); memcpy(ais_msg->data, data, ais_msg->size); } else { char *compressed = NULL; char *uncompressed = crm_strdup(data); unsigned int len = (ais_msg->size * 1.1) + 600; /* recomended size */ crm_debug_5("Compressing message payload"); crm_malloc(compressed, len); rc = BZ2_bzBuffToBuffCompress( compressed, &len, uncompressed, ais_msg->size, CRM_BZ2_BLOCKS, 0, CRM_BZ2_WORK); crm_free(uncompressed); if(rc != BZ_OK) { crm_err("Compression failed: %d", rc); crm_free(compressed); goto failback; } crm_realloc(ais_msg, sizeof(AIS_Message) + len + 1); memcpy(ais_msg->data, compressed, len); ais_msg->data[len] = 0; crm_free(compressed); ais_msg->is_compressed = TRUE; ais_msg->compressed_size = len; crm_debug_2("Compression details: %d -> %d", ais_msg->size, ais_data_len(ais_msg)); } ais_msg->header.size = sizeof(AIS_Message) + ais_data_len(ais_msg); crm_debug_3("Sending%s message %d to %s.%s (data=%d, total=%d)", ais_msg->is_compressed?" compressed":"", ais_msg->id, ais_dest(&(ais_msg->host)), msg_type2text(dest), ais_data_len(ais_msg), ais_msg->header.size); iov.iov_base = ais_msg; iov.iov_len = ais_msg->header.size; retry: errno = 0; crm_realloc(buf, buf_len); #ifdef TRADITIONAL_AIS_IPC rc = saSendReceiveReply(ais_fd_sync, ais_msg, ais_msg->header.size, buf, buf_len); #else # ifdef AIS_WHITETANK rc = openais_msg_send_reply_receive(ais_ipc_ctx, &iov, 1, buf, buf_len); # else rc = coroipcc_msg_send_reply_receive(ais_ipc_handle, &iov, 1, buf, buf_len); # endif #endif header = (coroipc_response_header_t *)buf; if(rc == CS_ERR_TRY_AGAIN && retries < 20) { retries++; crm_info("Peer overloaded: Re-sending message (Attempt %d of 20)", retries); sleep(retries); /* Proportional back off */ goto retry; } else if(rc == CS_OK) { CRM_CHECK_AND_STORE(header->size == sizeof (coroipc_response_header_t), crm_err("Odd message: id=%d, size=%d, class=%d, error=%d", header->id, header->size, class, header->error)); if(buf_len < header->size) { crm_err("Increasing buffer length to %d and retrying", header->size); buf_len = header->size + 1; goto retry; } else if(header->id == crm_class_nodeid && header->size == sizeof (struct crm_ais_nodeid_resp_s)){ struct crm_ais_nodeid_resp_s *answer = (struct crm_ais_nodeid_resp_s *)header; crm_err("Server details: id=%u uname=%s counter=%u", answer->id, answer->uname, answer->counter); } else { CRM_CHECK_AND_STORE(header->id == CRM_MESSAGE_IPC_ACK, crm_err("Bad response id (%d) for request (%d)", header->id, ais_msg->header.id)); CRM_CHECK(header->error == CS_OK, rc = header->error); } } if(rc != CS_OK) { crm_perror(LOG_ERR,"Sending message %d: FAILED (rc=%d): %s", ais_msg->id, rc, ais_error2text(rc)); ais_fd_async = -1; } else { crm_debug_4("Message %d: sent", ais_msg->id); } crm_free(buf); crm_free(ais_msg); return (rc == CS_OK); } gboolean send_ais_message(xmlNode *msg, gboolean local, const char *node, enum crm_ais_msg_types dest) { gboolean rc = TRUE; char *data = NULL; if(ais_fd_async < 0 || ais_source == NULL) { crm_err("Not connected to AIS"); return FALSE; } data = dump_xml_unformatted(msg); rc = send_ais_text(0, data, local, node, dest); crm_free(data); return rc; } void terminate_ais_connection(void) { #ifndef TRADITIONAL_AIS_IPC if(ais_ipc_ctx) { # ifdef AIS_WHITETANK openais_service_disconnect(ais_ipc_ctx); # else coroipcc_service_disconnect(ais_ipc_handle); # endif } #else if(ais_fd_sync > 0) { close(ais_fd_sync); } if(ais_fd_async > 0) { close(ais_fd_async); } #endif crm_notice("Disconnected from AIS"); /* G_main_del_fd(ais_source); */ /* G_main_del_fd(ais_source_sync); */ } int ais_membership_timer = 0; gboolean ais_membership_force = FALSE; gboolean ais_dispatch(int sender, gpointer user_data) { char *data = NULL; char *buffer = NULL; char *uncompressed = NULL; int rc = CS_OK; xmlNode *xml = NULL; AIS_Message *msg = NULL; gboolean (*dispatch)(AIS_Message*,char*,int) = user_data; #ifdef TRADITIONAL_AIS_IPC coroipc_response_header_t *header = NULL; static int header_len = sizeof(coroipc_response_header_t); crm_malloc0(header, header_len); buffer = (char*)header; errno = 0; rc = saRecvRetry(sender, header, header_len); if (rc != CS_OK) { crm_perror(LOG_ERR, "Receiving message header failed: (%d/%d) %s", rc, errno, ais_error2text(rc)); goto bail; } else if(header->size == header_len) { crm_err("Empty message: id=%d, size=%d, error=%d, header_len=%d", header->id, header->size, header->error, header_len); goto done; } else if(header->size == 0 || header->size < header_len) { crm_err("Mangled header: size=%d, header=%d, error=%d", header->size, header_len, header->error); goto done; } else if(header->error != CS_OK) { crm_err("Header contined error: %d", header->error); } crm_debug_2("Looking for %d (%d - %d) more bytes", header->size - header_len, header->size, header_len); crm_realloc(header, header->size); /* Use a char* so we can store the remainder into an offset */ buffer = (char*)header; errno = 0; rc = saRecvRetry(sender, buffer+header_len, header->size - header_len); #else # ifdef AIS_WHITETANK crm_malloc0(buffer, 1000000); rc = openais_dispatch_recv (ais_ipc_ctx, buffer, 0); # else rc = coroipcc_dispatch_get (ais_ipc_handle, (void**)&buffer, 0); # endif #endif if (rc == 0) { /* Zero is a legal "no message afterall" value */ goto done; } else if (rc != CS_OK) { crm_perror(LOG_ERR,"Receiving message body failed: (%d) %s", rc, ais_error2text(rc)); goto bail; } msg = (AIS_Message*)buffer; crm_debug_3("Got new%s message (size=%d, %d, %d)", msg->is_compressed?" compressed":"", ais_data_len(msg), msg->size, msg->compressed_size); data = msg->data; if(msg->is_compressed && msg->size > 0) { int rc = BZ_OK; unsigned int new_size = msg->size + 1; if(check_message_sanity(msg, NULL) == FALSE) { goto badmsg; } crm_debug_5("Decompressing message data"); crm_malloc0(uncompressed, new_size); rc = BZ2_bzBuffToBuffDecompress( uncompressed, &new_size, data, msg->compressed_size, 1, 0); if(rc != BZ_OK) { crm_err("Decompression failed: %d", rc); goto badmsg; } CRM_ASSERT(rc == BZ_OK); CRM_ASSERT(new_size == msg->size); data = uncompressed; } else if(check_message_sanity(msg, data) == FALSE) { goto badmsg; } else if(safe_str_eq("identify", data)) { int pid = getpid(); char *pid_s = crm_itoa(pid); send_ais_text(0, pid_s, TRUE, NULL, crm_msg_ais); crm_free(pid_s); goto done; } if(msg->header.id != crm_class_members) { crm_update_peer(msg->sender.id, 0,0,0,0, msg->sender.uname, msg->sender.uname, NULL, NULL); } if(msg->header.id == crm_class_rmpeer) { uint32_t id = crm_int_helper(data, NULL); crm_info("Removing peer %s/%u", data, id); reap_crm_member(id); goto done; } else if(msg->header.id == crm_class_members || msg->header.id == crm_class_quorum) { const char *value = NULL; gboolean quorate = FALSE; xml = string2xml(data); if(xml == NULL) { crm_err("Invalid membership update: %s", data); goto badmsg; } value = crm_element_value(xml, "quorate"); CRM_CHECK(value != NULL, crm_log_xml_err(xml, "No quorum value:"); goto badmsg); if(crm_is_true(value)) { quorate = TRUE; } value = crm_element_value(xml, "id"); CRM_CHECK(value != NULL, crm_log_xml_err(xml, "No membership id"); goto badmsg); crm_peer_seq = crm_int_helper(value, NULL); if(quorate != crm_have_quorum) { crm_notice("Membership %s: quorum %s", value, quorate?"acquired":"lost"); crm_have_quorum = quorate; } else { crm_info("Membership %s: quorum %s", value, quorate?"retained":"still lost"); } xml_child_iter(xml, node, crm_update_ais_node(node, crm_peer_seq)); } if(dispatch != NULL) { dispatch(msg, data, sender); } done: crm_free(uncompressed); free_xml(xml); #ifdef AIS_COROSYNC # ifndef TRADITIONAL_AIS_IPC coroipcc_dispatch_put (ais_ipc_handle); buffer = NULL; # endif #endif crm_free(buffer); return TRUE; badmsg: crm_err("Invalid message (id=%d, dest=%s:%s, from=%s:%s.%d):" " min=%d, total=%d, size=%d, bz2_size=%d", msg->id, ais_dest(&(msg->host)), msg_type2text(msg->host.type), ais_dest(&(msg->sender)), msg_type2text(msg->sender.type), msg->sender.pid, (int)sizeof(AIS_Message), msg->header.size, msg->size, msg->compressed_size); goto done; bail: crm_err("AIS connection failed"); #ifdef AIS_COROSYNC # ifndef TRADITIONAL_AIS_IPC buffer = NULL; # endif #endif crm_free(buffer); return FALSE; } static void ais_destroy(gpointer user_data) { crm_err("AIS connection terminated"); ais_fd_sync = -1; exit(1); } gboolean init_ais_connection( gboolean (*dispatch)(AIS_Message*,char*,int), void (*destroy)(gpointer), char **our_uuid, char **our_uname, int *nodeid) { int pid = 0; int retries = 0; int rc = CS_OK; char *pid_s = NULL; struct utsname name; uint32_t local_nodeid = 0; char *local_uname = NULL; retry: crm_info("Creating connection to our AIS plugin"); #ifdef TRADITIONAL_AIS_IPC rc = saServiceConnect (&ais_fd_sync, &ais_fd_async, PCMK_SERVICE_ID); #else # ifdef AIS_WHITETANK rc = openais_service_connect(PCMK_SERVICE_ID, &ais_ipc_ctx); if(ais_ipc_ctx) { ais_fd_async = openais_fd_get(ais_ipc_ctx); } # else rc = coroipcc_service_connect( COROSYNC_SOCKET_NAME, PCMK_SERVICE_ID, AIS_IPC_MESSAGE_SIZE, AIS_IPC_MESSAGE_SIZE, AIS_IPC_MESSAGE_SIZE, &ais_ipc_handle); if(ais_ipc_handle) { coroipcc_fd_get(ais_ipc_handle, &ais_fd_async); } # endif #endif if(ais_fd_async <= 0 && rc == CS_OK) { crm_err("No context created, but connection reported 'ok'"); rc = CS_ERR_LIBRARY; } if (rc != CS_OK) { crm_info("Connection to our AIS plugin (%d) failed: %s (%d)", PCMK_SERVICE_ID, ais_error2text(rc), rc); } switch(rc) { case CS_OK: break; case CS_ERR_TRY_AGAIN: if(retries < 30) { sleep(1); retries++; goto retry; } crm_err("Retry count exceeded"); return FALSE; default: return FALSE; } if(destroy == NULL) { destroy = ais_destroy; } crm_info("AIS connection established"); pid = getpid(); pid_s = crm_itoa(pid); send_ais_text(0, pid_s, TRUE, NULL, crm_msg_ais); crm_free(pid_s); crm_peer_init(); get_ais_nodeid(&local_nodeid, &local_uname); if(uname(&name) < 0) { crm_perror(LOG_ERR,"uname(2) call failed"); exit(100); } if(safe_str_neq(name.nodename, local_uname)) { crm_crit("Node name mismatch! OpenAIS supplied %s, our lookup returned %s", local_uname, name.nodename); crm_notice("Node name mismatches usually occur when assigned automatically by DHCP servers"); crm_notice("If this node was part of the cluster with a different name," " you will need to remove the old entry with crm_node --remove"); } if(our_uuid != NULL) { *our_uuid = crm_strdup(local_uname); } if(our_uname != NULL) { *our_uname = local_uname; } if(nodeid != NULL) { *nodeid = local_nodeid; } if(local_nodeid != 0) { /* Ensure the local node always exists */ crm_update_peer(local_nodeid, 0, 0, 0, 0, local_uname, local_uname, NULL, NULL); } if(dispatch) { ais_source = G_main_add_fd( G_PRIORITY_HIGH, ais_fd_async, FALSE, ais_dispatch, dispatch, destroy); } return TRUE; } gboolean check_message_sanity(const AIS_Message *msg, const char *data) { gboolean sane = TRUE; gboolean repaired = FALSE; int dest = msg->host.type; int tmp_size = msg->header.size - sizeof(AIS_Message); if(sane && msg->header.size == 0) { crm_warn("Message with no size"); sane = FALSE; } if(sane && msg->header.error != CS_OK) { crm_warn("Message header contains an error: %d", msg->header.error); sane = FALSE; } if(sane && ais_data_len(msg) != tmp_size) { crm_warn("Message payload size is incorrect: expected %d, got %d", ais_data_len(msg), tmp_size); sane = TRUE; } if(sane && ais_data_len(msg) == 0) { crm_warn("Message with no payload"); sane = FALSE; } if(sane && data && msg->is_compressed == FALSE) { int str_size = strlen(data) + 1; if(ais_data_len(msg) != str_size) { int lpc = 0; crm_warn("Message payload is corrupted: expected %d bytes, got %d", ais_data_len(msg), str_size); sane = FALSE; for(lpc = (str_size - 10); lpc < msg->size; lpc++) { if(lpc < 0) { lpc = 0; } crm_debug("bad_data[%d]: %d / '%c'", lpc, data[lpc], data[lpc]); } } } if(sane == FALSE) { crm_err("Invalid message %d: (dest=%s:%s, from=%s:%s.%d, compressed=%d, size=%d, total=%d)", msg->id, ais_dest(&(msg->host)), msg_type2text(dest), ais_dest(&(msg->sender)), msg_type2text(msg->sender.type), msg->sender.pid, msg->is_compressed, ais_data_len(msg), msg->header.size); } else if(repaired) { crm_err("Repaired message %d: (dest=%s:%s, from=%s:%s.%d, compressed=%d, size=%d, total=%d)", msg->id, ais_dest(&(msg->host)), msg_type2text(dest), ais_dest(&(msg->sender)), msg_type2text(msg->sender.type), msg->sender.pid, msg->is_compressed, ais_data_len(msg), msg->header.size); } else { crm_debug_3("Verfied message %d: (dest=%s:%s, from=%s:%s.%d, compressed=%d, size=%d, total=%d)", msg->id, ais_dest(&(msg->host)), msg_type2text(dest), ais_dest(&(msg->sender)), msg_type2text(msg->sender.type), msg->sender.pid, msg->is_compressed, ais_data_len(msg), msg->header.size); } return sane; } #endif diff --git a/lib/pengine/unpack.c b/lib/pengine/unpack.c index dcaa638029..a21f328380 100644 --- a/lib/pengine/unpack.c +++ b/lib/pengine/unpack.c @@ -1,1717 +1,1716 @@ /* * Copyright (C) 2004 Andrew Beekhof * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #define set_config_flag(data_set, option, flag) do { \ const char *tmp = pe_pref(data_set->config_hash, option); \ if(tmp) { \ if(crm_is_true(tmp)) { \ set_bit_inplace(data_set->flags, flag); \ } else { \ clear_bit_inplace(data_set->flags, flag); \ } \ } \ } while(0) gboolean unpack_rsc_op( resource_t *rsc, node_t *node, xmlNode *xml_op, enum action_fail_response *failed, pe_working_set_t *data_set); gboolean unpack_config(xmlNode *config, pe_working_set_t *data_set) { const char *value = NULL; GHashTable *config_hash = g_hash_table_new_full( g_str_hash,g_str_equal, g_hash_destroy_str,g_hash_destroy_str); data_set->config_hash = config_hash; unpack_instance_attributes( data_set->input, config, XML_CIB_TAG_PROPSET, NULL, config_hash, CIB_OPTIONS_FIRST, FALSE, data_set->now); verify_pe_options(data_set->config_hash); value = pe_pref(data_set->config_hash, "stonith-timeout"); data_set->stonith_timeout = crm_get_msec(value); crm_debug("STONITH timeout: %d", data_set->stonith_timeout); set_config_flag(data_set, "stonith-enabled", pe_flag_stonith_enabled); crm_debug("STONITH of failed nodes is %s", is_set(data_set->flags, pe_flag_stonith_enabled)?"enabled":"disabled"); data_set->stonith_action = pe_pref(data_set->config_hash, "stonith-action"); crm_debug_2("STONITH will %s nodes", data_set->stonith_action); set_config_flag(data_set, "stop-all-resources", pe_flag_stop_everything); crm_debug("Stop all active resources: %s", is_set(data_set->flags, pe_flag_stop_everything)?"true":"false"); set_config_flag(data_set, "symmetric-cluster", pe_flag_symmetric_cluster); if(is_set(data_set->flags, pe_flag_symmetric_cluster)) { crm_debug("Cluster is symmetric" " - resources can run anywhere by default"); } value = pe_pref(data_set->config_hash, "default-resource-stickiness"); data_set->default_resource_stickiness = char2score(value); crm_debug("Default stickiness: %d", data_set->default_resource_stickiness); value = pe_pref(data_set->config_hash, "no-quorum-policy"); if(safe_str_eq(value, "ignore")) { data_set->no_quorum_policy = no_quorum_ignore; } else if(safe_str_eq(value, "freeze")) { data_set->no_quorum_policy = no_quorum_freeze; } else if(safe_str_eq(value, "suicide")) { gboolean do_panic = FALSE; crm_element_value_int(data_set->input, XML_ATTR_QUORUM_PANIC, &do_panic); if(is_set(data_set->flags, pe_flag_stonith_enabled) == FALSE){ crm_config_err("Setting no-quorum-policy=suicide makes no sense if stonith-enabled=false"); } if(do_panic && is_set(data_set->flags, pe_flag_stonith_enabled)) { data_set->no_quorum_policy = no_quorum_suicide; } else if(is_set(data_set->flags, pe_flag_have_quorum) == FALSE && do_panic == FALSE) { crm_notice("Resetting no-quorum-policy to 'stop': The cluster has never had quorum"); data_set->no_quorum_policy = no_quorum_stop; } } else { data_set->no_quorum_policy = no_quorum_stop; } switch (data_set->no_quorum_policy) { case no_quorum_freeze: crm_debug("On loss of CCM Quorum: Freeze resources"); break; case no_quorum_stop: crm_debug("On loss of CCM Quorum: Stop ALL resources"); break; case no_quorum_suicide: crm_notice("On loss of CCM Quorum: Fence all remaining nodes"); break; case no_quorum_ignore: crm_notice("On loss of CCM Quorum: Ignore"); break; } set_config_flag(data_set, "stop-orphan-resources", pe_flag_stop_rsc_orphans); crm_debug_2("Orphan resources are %s", is_set(data_set->flags, pe_flag_stop_rsc_orphans)?"stopped":"ignored"); set_config_flag(data_set, "stop-orphan-actions", pe_flag_stop_action_orphans); crm_debug_2("Orphan resource actions are %s", is_set(data_set->flags, pe_flag_stop_action_orphans)?"stopped":"ignored"); set_config_flag(data_set, "remove-after-stop", pe_flag_remove_after_stop); crm_debug_2("Stopped resources are removed from the status section: %s", is_set(data_set->flags, pe_flag_remove_after_stop)?"true":"false"); set_config_flag(data_set, "maintenance-mode", pe_flag_maintenance_mode); crm_debug_2("Maintenance mode: %s", is_set(data_set->flags, pe_flag_maintenance_mode)?"true":"false"); if(is_set(data_set->flags, pe_flag_maintenance_mode)) { clear_bit(data_set->flags, pe_flag_is_managed_default); } else { set_config_flag(data_set, "is-managed-default", pe_flag_is_managed_default); } crm_debug_2("By default resources are %smanaged", is_set(data_set->flags, pe_flag_is_managed_default)?"":"not "); set_config_flag(data_set, "start-failure-is-fatal", pe_flag_start_failure_fatal); crm_debug_2("Start failures are %s", is_set(data_set->flags, pe_flag_start_failure_fatal)?"always fatal":"handled by failcount"); node_score_red = char2score(pe_pref(data_set->config_hash, "node-health-red")); node_score_green = char2score(pe_pref(data_set->config_hash, "node-health-green")); node_score_yellow = char2score(pe_pref(data_set->config_hash, "node-health-yellow")); crm_info("Node scores: 'red' = %s, 'yellow' = %s, 'green' = %s", score2char(node_score_red),score2char(node_score_yellow), score2char(node_score_green)); return TRUE; } gboolean unpack_nodes(xmlNode * xml_nodes, pe_working_set_t *data_set) { node_t *new_node = NULL; const char *id = NULL; const char *uname = NULL; const char *type = NULL; gboolean unseen_are_unclean = TRUE; const char *blind_faith = pe_pref( data_set->config_hash, "startup-fencing"); if(crm_is_true(blind_faith) == FALSE) { unseen_are_unclean = FALSE; crm_warn("Blind faith: not fencing unseen nodes"); } xml_child_iter_filter( xml_nodes, xml_obj, XML_CIB_TAG_NODE, new_node = NULL; id = crm_element_value(xml_obj, XML_ATTR_ID); uname = crm_element_value(xml_obj, XML_ATTR_UNAME); type = crm_element_value(xml_obj, XML_ATTR_TYPE); crm_debug_3("Processing node %s/%s", uname, id); if(id == NULL) { crm_config_err("Must specify id tag in "); continue; } if(type == NULL) { crm_config_err("Must specify type tag in "); continue; } if(pe_find_node(data_set->nodes, uname) != NULL) { crm_config_warn("Detected multiple node entries with uname=%s" " - this is rarely intended", uname); } crm_malloc0(new_node, sizeof(node_t)); if(new_node == NULL) { return FALSE; } new_node->weight = 0; new_node->fixed = FALSE; crm_malloc0(new_node->details, sizeof(struct node_shared_s)); if(new_node->details == NULL) { crm_free(new_node); return FALSE; } crm_debug_3("Creaing node for entry %s/%s", uname, id); new_node->details->id = id; new_node->details->uname = uname; new_node->details->type = node_ping; new_node->details->online = FALSE; new_node->details->shutdown = FALSE; new_node->details->running_rsc = NULL; new_node->details->attrs = g_hash_table_new_full( g_str_hash, g_str_equal, g_hash_destroy_str, g_hash_destroy_str); /* if(data_set->have_quorum == FALSE */ /* && data_set->no_quorum_policy == no_quorum_stop) { */ /* /\* start shutting resources down *\/ */ /* new_node->weight = -INFINITY; */ /* } */ if(is_set(data_set->flags, pe_flag_stonith_enabled) == FALSE || unseen_are_unclean == FALSE) { /* blind faith... */ new_node->details->unclean = FALSE; } else { /* all nodes are unclean until we've seen their * status entry */ new_node->details->unclean = TRUE; } if(type == NULL || safe_str_eq(type, "member") || safe_str_eq(type, NORMALNODE)) { new_node->details->type = node_member; } add_node_attrs(xml_obj, new_node, FALSE, data_set); data_set->nodes = g_list_append(data_set->nodes, new_node); crm_debug_3("Done with node %s", crm_element_value(xml_obj, XML_ATTR_UNAME)); ); return TRUE; } gboolean unpack_resources(xmlNode * xml_resources, pe_working_set_t *data_set) { xml_child_iter( xml_resources, xml_obj, resource_t *new_rsc = NULL; crm_debug_3("Begining unpack... <%s id=%s... >", crm_element_name(xml_obj), ID(xml_obj)); if(common_unpack(xml_obj, &new_rsc, NULL, data_set)) { data_set->resources = g_list_append( data_set->resources, new_rsc); print_resource(LOG_DEBUG_3, "Added", new_rsc, FALSE); } else { crm_config_err("Failed unpacking %s %s", crm_element_name(xml_obj), crm_element_value(xml_obj, XML_ATTR_ID)); if(new_rsc != NULL && new_rsc->fns != NULL) { new_rsc->fns->free(new_rsc); } } ); data_set->resources = g_list_sort( data_set->resources, sort_rsc_priority); if(is_set(data_set->flags, pe_flag_stonith_enabled) && is_set(data_set->flags, pe_flag_have_stonith_resource) == FALSE) { crm_config_err("Resource start-up disabled since no STONITH resources have been defined"); crm_config_err("Either configure some or disable STONITH with the stonith-enabled option"); crm_config_err("NOTE: Clusters with shared data need STONITH to ensure data integrity"); } return TRUE; } /* remove nodes that are down, stopping */ /* create +ve rsc_to_node constraints between resources and the nodes they are running on */ /* anything else? */ gboolean unpack_status(xmlNode * status, pe_working_set_t *data_set) { const char *id = NULL; const char *uname = NULL; xmlNode * lrm_rsc = NULL; xmlNode * attrs = NULL; node_t *this_node = NULL; crm_debug_3("Begining unpack"); xml_child_iter_filter( status, node_state, XML_CIB_TAG_STATE, id = crm_element_value(node_state, XML_ATTR_ID); uname = crm_element_value(node_state, XML_ATTR_UNAME); attrs = find_xml_node( node_state, XML_TAG_TRANSIENT_NODEATTRS, FALSE); lrm_rsc = find_xml_node(node_state, XML_CIB_TAG_LRM, FALSE); lrm_rsc = find_xml_node(lrm_rsc, XML_LRM_TAG_RESOURCES, FALSE); crm_debug_3("Processing node %s", uname); this_node = pe_find_node_id(data_set->nodes, id); if(uname == NULL) { /* error */ continue; } else if(this_node == NULL) { crm_config_warn("Node %s in status section no longer exists", uname); continue; } /* Mark the node as provisionally clean * - at least we have seen it in the current cluster's lifetime */ this_node->details->unclean = FALSE; add_node_attrs(attrs, this_node, TRUE, data_set); if(crm_is_true(g_hash_table_lookup(this_node->details->attrs, "standby"))) { crm_info("Node %s is in standby-mode", this_node->details->uname); this_node->details->standby = TRUE; } crm_debug_3("determining node state"); determine_online_status(node_state, this_node, data_set); if(this_node->details->online && data_set->no_quorum_policy == no_quorum_suicide) { /* Everything else should flow from this automatically * At least until the PE becomes able to migrate off healthy resources */ crm_notice("Marking node %s for STONITH: The cluster does not have quorum", this_node->details->uname); this_node->details->unclean = TRUE; } if(this_node->details->online || is_set(data_set->flags, pe_flag_stonith_enabled)) { /* offline nodes run no resources... * unless stonith is enabled in which case we need to * make sure rsc start events happen after the stonith */ crm_debug_3("Processing lrm resource entries"); unpack_lrm_resources(this_node, lrm_rsc, data_set); } ); return TRUE; } static gboolean determine_online_status_no_fencing(xmlNode * node_state, node_t *this_node) { gboolean online = FALSE; const char *join_state = crm_element_value(node_state, XML_CIB_ATTR_JOINSTATE); const char *crm_state = crm_element_value(node_state, XML_CIB_ATTR_CRMDSTATE); const char *ccm_state = crm_element_value(node_state, XML_CIB_ATTR_INCCM); const char *ha_state = crm_element_value(node_state, XML_CIB_ATTR_HASTATE); const char *exp_state = crm_element_value(node_state, XML_CIB_ATTR_EXPSTATE); if(ha_state == NULL) { ha_state = DEADSTATUS; } if(!crm_is_true(ccm_state) || safe_str_eq(ha_state, DEADSTATUS)){ crm_debug_2("Node is down: ha_state=%s, ccm_state=%s", crm_str(ha_state), crm_str(ccm_state)); } else if(!crm_is_true(ccm_state) || safe_str_eq(ha_state, DEADSTATUS)) { } else if(safe_str_eq(crm_state, ONLINESTATUS)) { if(safe_str_eq(join_state, CRMD_JOINSTATE_MEMBER)) { online = TRUE; } else { crm_debug("Node is not ready to run resources: %s", join_state); } } else if(this_node->details->expected_up == FALSE) { crm_debug_2("CRMd is down: ha_state=%s, ccm_state=%s", crm_str(ha_state), crm_str(ccm_state)); crm_debug_2("\tcrm_state=%s, join_state=%s, expected=%s", crm_str(crm_state), crm_str(join_state), crm_str(exp_state)); } else { /* mark it unclean */ this_node->details->unclean = TRUE; crm_warn("Node %s is partially & un-expectedly down", this_node->details->uname); crm_info("\tha_state=%s, ccm_state=%s," " crm_state=%s, join_state=%s, expected=%s", crm_str(ha_state), crm_str(ccm_state), crm_str(crm_state), crm_str(join_state), crm_str(exp_state)); } return online; } static gboolean determine_online_status_fencing(xmlNode * node_state, node_t *this_node) { gboolean online = FALSE; gboolean do_terminate = FALSE; const char *join_state = crm_element_value(node_state, XML_CIB_ATTR_JOINSTATE); const char *crm_state = crm_element_value(node_state, XML_CIB_ATTR_CRMDSTATE); const char *ccm_state = crm_element_value(node_state, XML_CIB_ATTR_INCCM); const char *ha_state = crm_element_value(node_state, XML_CIB_ATTR_HASTATE); const char *exp_state = crm_element_value(node_state, XML_CIB_ATTR_EXPSTATE); const char *terminate = g_hash_table_lookup(this_node->details->attrs, "terminate"); if(ha_state == NULL) { ha_state = DEADSTATUS; } if(crm_is_true(terminate)) { do_terminate = TRUE; } else if(terminate != NULL && strlen(terminate) > 0) { /* could be a time() value */ char t = terminate[0]; if(t != '0' && isdigit(t)) { do_terminate = TRUE; } } if(crm_is_true(ccm_state) && safe_str_eq(ha_state, ACTIVESTATUS) && safe_str_eq(crm_state, ONLINESTATUS)) { if(safe_str_eq(join_state, CRMD_JOINSTATE_MEMBER)) { online = TRUE; if(do_terminate) { crm_notice("Forcing node %s to be terminated", this_node->details->uname); this_node->details->unclean = TRUE; this_node->details->shutdown = TRUE; } } else if(join_state == exp_state /* == NULL */) { crm_info("Node %s is coming up", this_node->details->uname); crm_debug("\tha_state=%s, ccm_state=%s," " crm_state=%s, join_state=%s, expected=%s", crm_str(ha_state), crm_str(ccm_state), crm_str(crm_state), crm_str(join_state), crm_str(exp_state)); } else if(safe_str_eq(join_state, CRMD_JOINSTATE_PENDING)) { crm_info("Node %s is not ready to run resources", this_node->details->uname); this_node->details->standby = TRUE; this_node->details->pending = TRUE; online = TRUE; } else if(safe_str_eq(join_state, CRMD_JOINSTATE_NACK)) { crm_warn("Node %s is not part of the cluster", this_node->details->uname); this_node->details->standby = TRUE; this_node->details->pending = TRUE; online = TRUE; } else { crm_warn("Node %s (%s) is un-expectedly down", this_node->details->uname, this_node->details->id); crm_info("\tha_state=%s, ccm_state=%s," " crm_state=%s, join_state=%s, expected=%s", crm_str(ha_state), crm_str(ccm_state), crm_str(crm_state), crm_str(join_state), crm_str(exp_state)); this_node->details->unclean = TRUE; } } else if(crm_is_true(ccm_state) == FALSE && safe_str_eq(ha_state, DEADSTATUS) && safe_str_eq(crm_state, OFFLINESTATUS) && this_node->details->expected_up == FALSE) { crm_debug("Node %s is down: join_state=%s, expected=%s", this_node->details->uname, crm_str(join_state), crm_str(exp_state)); #if 0 /* While a nice optimization, it causes the cluster to block until the node * comes back online. Which is a serious problem if the cluster software * is not configured to start at boot or stonith is configured to merely * stop the node instead of restart it. * Easily triggered by setting terminate=true for the DC */ } else if(do_terminate) { crm_info("Node %s is %s after forced termination", this_node->details->uname, crm_is_true(ccm_state)?"coming up":"going down"); crm_debug("\tha_state=%s, ccm_state=%s," " crm_state=%s, join_state=%s, expected=%s", crm_str(ha_state), crm_str(ccm_state), crm_str(crm_state), crm_str(join_state), crm_str(exp_state)); if(crm_is_true(ccm_state) == FALSE) { this_node->details->standby = TRUE; this_node->details->pending = TRUE; online = TRUE; } #endif } else if(this_node->details->expected_up) { /* mark it unclean */ this_node->details->unclean = TRUE; crm_warn("Node %s (%s) is un-expectedly down", this_node->details->uname, this_node->details->id); crm_info("\tha_state=%s, ccm_state=%s," " crm_state=%s, join_state=%s, expected=%s", crm_str(ha_state), crm_str(ccm_state), crm_str(crm_state), crm_str(join_state), crm_str(exp_state)); } else { crm_info("Node %s is down", this_node->details->uname); crm_debug("\tha_state=%s, ccm_state=%s," " crm_state=%s, join_state=%s, expected=%s", crm_str(ha_state), crm_str(ccm_state), crm_str(crm_state), crm_str(join_state), crm_str(exp_state)); } return online; } gboolean determine_online_status( xmlNode * node_state, node_t *this_node, pe_working_set_t *data_set) { gboolean online = FALSE; const char *shutdown = NULL; const char *exp_state = crm_element_value(node_state, XML_CIB_ATTR_EXPSTATE); if(this_node == NULL) { crm_config_err("No node to check"); return online; } this_node->details->shutdown = FALSE; this_node->details->expected_up = FALSE; shutdown = g_hash_table_lookup(this_node->details->attrs, XML_CIB_ATTR_SHUTDOWN); if(shutdown != NULL && safe_str_neq("0", shutdown)) { this_node->details->shutdown = TRUE; } else if(safe_str_eq(exp_state, CRMD_JOINSTATE_MEMBER)) { this_node->details->expected_up = TRUE; } if(is_set(data_set->flags, pe_flag_stonith_enabled) == FALSE) { online = determine_online_status_no_fencing( node_state, this_node); } else { online = determine_online_status_fencing( node_state, this_node); } if(online) { this_node->details->online = TRUE; } else { /* remove node from contention */ this_node->fixed = TRUE; this_node->weight = -INFINITY; } if(online && this_node->details->shutdown) { /* dont run resources here */ this_node->fixed = TRUE; this_node->weight = -INFINITY; } if(this_node->details->unclean) { pe_proc_warn("Node %s is unclean", this_node->details->uname); } else if(this_node->details->online) { crm_info("Node %s is %s", this_node->details->uname, this_node->details->shutdown?"shutting down": this_node->details->pending?"pending": this_node->details->standby?"standby":"online"); } else { crm_debug_2("Node %s is offline", this_node->details->uname); } return online; } #define set_char(x) last_rsc_id[lpc] = x; complete = TRUE; -static char * +char * clone_zero(const char *last_rsc_id) { int lpc = 0; char *zero = NULL; CRM_CHECK(last_rsc_id != NULL, return NULL); if(last_rsc_id != NULL) { lpc = strlen(last_rsc_id); } while(--lpc > 0) { switch(last_rsc_id[lpc]) { case 0: return NULL; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': break; case ':': crm_malloc0(zero, lpc + 3); memcpy(zero, last_rsc_id, lpc); zero[lpc] = ':'; zero[lpc+1] = '0'; zero[lpc+2] = 0; return zero; } } return NULL; } - -static char * +char * increment_clone(char *last_rsc_id) { int lpc = 0; int len = 0; char *tmp = NULL; gboolean complete = FALSE; CRM_CHECK(last_rsc_id != NULL, return NULL); if(last_rsc_id != NULL) { len = strlen(last_rsc_id); } lpc = len-1; while(complete == FALSE && lpc > 0) { switch (last_rsc_id[lpc]) { case 0: lpc--; break; case '0': set_char('1'); break; case '1': set_char('2'); break; case '2': set_char('3'); break; case '3': set_char('4'); break; case '4': set_char('5'); break; case '5': set_char('6'); break; case '6': set_char('7'); break; case '7': set_char('8'); break; case '8': set_char('9'); break; case '9': last_rsc_id[lpc] = '0'; lpc--; break; case ':': tmp = last_rsc_id; crm_malloc0(last_rsc_id, len + 2); memcpy(last_rsc_id, tmp, len); last_rsc_id[++lpc] = '1'; last_rsc_id[len] = '0'; last_rsc_id[len+1] = 0; complete = TRUE; crm_free(tmp); break; default: crm_err("Unexpected char: %c (%d)", last_rsc_id[lpc], lpc); break; } } return last_rsc_id; } static resource_t * create_fake_resource(const char *rsc_id, xmlNode *rsc_entry, pe_working_set_t *data_set) { resource_t *rsc = NULL; xmlNode *xml_rsc = create_xml_node(NULL, XML_CIB_TAG_RESOURCE); copy_in_properties(xml_rsc, rsc_entry); crm_xml_add(xml_rsc, XML_ATTR_ID, rsc_id); crm_log_xml_info(xml_rsc, "Orphan resource"); common_unpack(xml_rsc, &rsc, NULL, data_set); set_bit(rsc->flags, pe_rsc_orphan); data_set->resources = g_list_append(data_set->resources, rsc); return rsc; } extern resource_t *create_child_clone(resource_t *rsc, int sub_id, pe_working_set_t *data_set); static resource_t *find_clone(pe_working_set_t *data_set, node_t *node, resource_t *parent, const char *rsc_id) { int len = 0; resource_t *rsc = NULL; char *base = clone_zero(rsc_id); char *alt_rsc_id = crm_strdup(rsc_id); CRM_ASSERT(parent != NULL); CRM_ASSERT(parent->variant == pe_clone || parent->variant == pe_master); if(base) { len = strlen(base); } if(len > 0) { base[len-1] = 0; } crm_debug_3("Looking for %s on %s in %s %d", rsc_id, node->details->uname, parent->id, is_set(parent->flags, pe_rsc_unique)); if(is_set(parent->flags, pe_rsc_unique)) { crm_debug_3("Looking for %s", rsc_id); rsc = parent->fns->find_rsc(parent, rsc_id, FALSE, FALSE, NULL, TRUE); } else { rsc = parent->fns->find_rsc(parent, base, FALSE, TRUE, node, TRUE); if(rsc != NULL && rsc->running_on) { rsc = NULL; crm_debug_3("Looking for an existing orphan for %s: %s on %s", parent->id, rsc_id, node->details->uname); /* There is already an instance of this _anonymous_ clone active on "node". * * If there is a partially active orphan (only applies to clone groups) on * the same node, use that. * Otherwise create a new (orphaned) instance at "orphan_check:". */ slist_iter(child, resource_t, parent->children, lpc, node_t *loc = child->fns->location(child, NULL, TRUE); if(loc && loc->details == node->details) { resource_t *tmp = child->fns->find_rsc(child, base, FALSE, TRUE, NULL, TRUE); if(tmp && tmp->running_on == NULL) { rsc = tmp; break; } } ); goto orphan_check; } while(rsc == NULL) { crm_debug_3("Trying %s", alt_rsc_id); rsc = parent->fns->find_rsc(parent, alt_rsc_id, FALSE, FALSE, NULL, TRUE); if(rsc == NULL) { break; } else if(rsc->running_on == NULL) { break; } alt_rsc_id = increment_clone(alt_rsc_id); rsc = NULL; } } orphan_check: if(rsc == NULL) { /* Create an extra orphan */ resource_t *top = create_child_clone(parent, -1, data_set); crm_debug("Created orphan for %s: %s on %s", parent->id, rsc_id, node->details->uname); rsc = top->fns->find_rsc(top, base, FALSE, TRUE, NULL, TRUE); CRM_ASSERT(rsc != NULL); } crm_free(rsc->clone_name); rsc->clone_name = NULL; if(safe_str_neq(rsc_id, rsc->id)) { crm_info("Internally renamed %s on %s to %s%s", rsc_id, node->details->uname, rsc->id, is_set(rsc->flags, pe_rsc_orphan)?" (ORPHAN)":""); rsc->clone_name = crm_strdup(rsc_id); } crm_free(alt_rsc_id); crm_free(base); return rsc; } static resource_t * unpack_find_resource( pe_working_set_t *data_set, node_t *node, const char *rsc_id, xmlNode *rsc_entry) { resource_t *rsc = NULL; resource_t *clone_parent = NULL; char *alt_rsc_id = crm_strdup(rsc_id); crm_debug_2("looking for %s", rsc_id); rsc = pe_find_resource(data_set->resources, alt_rsc_id); /* no match */ if(rsc == NULL) { /* Even when clone-max=0, we still create a single :0 orphan to match against */ char *tmp = clone_zero(alt_rsc_id); resource_t *clone0 = pe_find_resource(data_set->resources, tmp); clone_parent = uber_parent(clone0); crm_free(tmp); crm_debug_2("%s not found: %s", alt_rsc_id, clone_parent?clone_parent->id:"orphan"); } else { clone_parent = uber_parent(rsc); } if(clone_parent && clone_parent->variant > pe_group) { rsc = find_clone(data_set, node, clone_parent, rsc_id); CRM_ASSERT(rsc != NULL); } crm_free(alt_rsc_id); return rsc; } static resource_t * process_orphan_resource(xmlNode *rsc_entry, node_t *node, pe_working_set_t *data_set) { resource_t *rsc = NULL; const char *rsc_id = crm_element_value(rsc_entry, XML_ATTR_ID); crm_config_warn("Nothing known about resource %s running on %s", rsc_id, node->details->uname); rsc = create_fake_resource(rsc_id, rsc_entry, data_set); if(is_set(data_set->flags, pe_flag_stop_rsc_orphans) == FALSE) { clear_bit(rsc->flags, pe_rsc_managed); } else { crm_info("Making sure orphan %s is stopped", rsc_id); print_resource(LOG_DEBUG_3, "Added orphan", rsc, FALSE); CRM_CHECK(rsc != NULL, return NULL); resource_location(rsc, NULL, -INFINITY, "__orphan_dont_run__", data_set); } return rsc; } static void process_rsc_state(resource_t *rsc, node_t *node, enum action_fail_response on_fail, xmlNode *migrate_op, pe_working_set_t *data_set) { if(on_fail == action_migrate_failure) { node_t *from = NULL; const char *uuid = crm_element_value(migrate_op, CRMD_ACTION_MIGRATED); on_fail = action_fail_recover; from = pe_find_node_id(data_set->nodes, uuid); if(from != NULL) { process_rsc_state(rsc, from, on_fail, NULL, data_set); } else { crm_log_xml_err(migrate_op, "Bad Op"); } } crm_debug_2("Resource %s is %s on %s: on_fail=%s", rsc->id, role2text(rsc->role), node->details->uname, fail2text(on_fail)); /* process current state */ if(rsc->role != RSC_ROLE_UNKNOWN) { rsc->known_on = g_list_append(rsc->known_on, node); } if(node->details->unclean) { /* No extra processing needed * Also allows resources to be started again after a node is shot */ on_fail = action_fail_ignore; } switch(on_fail) { case action_fail_ignore: /* nothing to do */ break; case action_fail_fence: /* treat it as if it is still running * but also mark the node as unclean */ node->details->unclean = TRUE; break; case action_fail_standby: node->details->standby = TRUE; node->details->standby_onfail = TRUE; break; case action_fail_block: /* is_managed == FALSE will prevent any * actions being sent for the resource */ clear_bit(rsc->flags, pe_rsc_managed); break; case action_fail_migrate: /* make sure it comes up somewhere else * or not at all */ resource_location(rsc, node, -INFINITY, "__action_migration_auto__",data_set); break; case action_fail_stop: rsc->next_role = RSC_ROLE_STOPPED; break; case action_fail_recover: if(rsc->role != RSC_ROLE_STOPPED && rsc->role != RSC_ROLE_UNKNOWN) { set_bit(rsc->flags, pe_rsc_failed); stop_action(rsc, node, FALSE); } break; case action_migrate_failure: /* anything extra? */ break; } if(rsc->role != RSC_ROLE_STOPPED && rsc->role != RSC_ROLE_UNKNOWN) { native_add_running(rsc, node, data_set); if(on_fail != action_fail_ignore) { set_bit(rsc->flags, pe_rsc_failed); } } else if(rsc->clone_name) { crm_debug_2("Resetting clone_name %s for %s (stopped)", rsc->clone_name, rsc->id); crm_free(rsc->clone_name); rsc->clone_name = NULL; } else { char *key = stop_key(rsc); GListPtr possible_matches = find_actions(rsc->actions, key, node); slist_iter(stop, action_t, possible_matches, lpc, stop->optional = TRUE; ); crm_free(key); } } /* create active recurring operations as optional */ static void process_recurring(node_t *node, resource_t *rsc, int start_index, int stop_index, GListPtr sorted_op_list, pe_working_set_t *data_set) { const char *task = NULL; const char *status = NULL; crm_debug_3("%s: Start index %d, stop index = %d", rsc->id, start_index, stop_index); slist_iter(rsc_op, xmlNode, sorted_op_list, lpc, int interval = 0; char *key = NULL; const char *id = ID(rsc_op); const char *interval_s = NULL; if(node->details->online == FALSE) { crm_debug_4("Skipping %s/%s: node is offline", rsc->id, node->details->uname); break; } else if(start_index < stop_index) { crm_debug_4("Skipping %s/%s: not active", rsc->id, node->details->uname); break; } else if(lpc <= start_index) { crm_debug_4("Skipping %s/%s: old", id, node->details->uname); continue; } interval_s = crm_element_value(rsc_op,XML_LRM_ATTR_INTERVAL); interval = crm_parse_int(interval_s, "0"); if(interval == 0) { crm_debug_4("Skipping %s/%s: non-recurring", id, node->details->uname); continue; } status = crm_element_value(rsc_op, XML_LRM_ATTR_OPSTATUS); if(safe_str_eq(status, "-1")) { crm_debug_4("Skipping %s/%s: status", id, node->details->uname); continue; } task = crm_element_value(rsc_op, XML_LRM_ATTR_TASK); /* create the action */ key = generate_op_key(rsc->id, task, interval); crm_debug_3("Creating %s/%s", key, node->details->uname); custom_action(rsc, key, task, node, TRUE, TRUE, data_set); ); } void calculate_active_ops(GListPtr sorted_op_list, int *start_index, int *stop_index) { const char *task = NULL; const char *status = NULL; *stop_index = -1; *start_index = -1; slist_iter( rsc_op, xmlNode, sorted_op_list, lpc, task = crm_element_value(rsc_op, XML_LRM_ATTR_TASK); status = crm_element_value(rsc_op, XML_LRM_ATTR_OPSTATUS); if(safe_str_eq(task, CRMD_ACTION_STOP) && safe_str_eq(status, "0")) { *stop_index = lpc; } else if(safe_str_eq(task, CRMD_ACTION_START)) { *start_index = lpc; } else if(*start_index <= *stop_index && safe_str_eq(task, CRMD_ACTION_STATUS)) { const char *rc = crm_element_value(rsc_op, XML_LRM_ATTR_RC); if(safe_str_eq(rc, "0") || safe_str_eq(rc, "8")) { *start_index = lpc; } } ); } static void unpack_lrm_rsc_state( node_t *node, xmlNode * rsc_entry, pe_working_set_t *data_set) { int stop_index = -1; int start_index = -1; enum rsc_role_e req_role = RSC_ROLE_UNKNOWN; const char *task = NULL; const char *rsc_id = crm_element_value(rsc_entry, XML_ATTR_ID); resource_t *rsc = NULL; GListPtr op_list = NULL; GListPtr sorted_op_list = NULL; xmlNode *migrate_op = NULL; enum action_fail_response on_fail = FALSE; enum rsc_role_e saved_role = RSC_ROLE_UNKNOWN; crm_debug_3("[%s] Processing %s on %s", crm_element_name(rsc_entry), rsc_id, node->details->uname); /* extract operations */ op_list = NULL; sorted_op_list = NULL; xml_child_iter_filter( rsc_entry, rsc_op, XML_LRM_TAG_RSC_OP, op_list = g_list_append(op_list, rsc_op); ); if(op_list == NULL) { /* if there are no operations, there is nothing to do */ return; } /* find the resource */ rsc = unpack_find_resource(data_set, node, rsc_id, rsc_entry); if(rsc == NULL) { rsc = process_orphan_resource(rsc_entry, node, data_set); } CRM_ASSERT(rsc != NULL); /* process operations */ saved_role = rsc->role; on_fail = action_fail_ignore; rsc->role = RSC_ROLE_UNKNOWN; sorted_op_list = g_list_sort(op_list, sort_op_by_callid); slist_iter( rsc_op, xmlNode, sorted_op_list, lpc, task = crm_element_value(rsc_op, XML_LRM_ATTR_TASK); if(safe_str_eq(task, CRMD_ACTION_MIGRATED)) { migrate_op = rsc_op; } unpack_rsc_op(rsc, node, rsc_op, &on_fail, data_set); ); /* create active recurring operations as optional */ calculate_active_ops(sorted_op_list, &start_index, &stop_index); process_recurring(node, rsc, start_index, stop_index, sorted_op_list, data_set); /* no need to free the contents */ g_list_free(sorted_op_list); process_rsc_state(rsc, node, on_fail, migrate_op, data_set); if(get_target_role(rsc, &req_role)) { if(rsc->next_role == RSC_ROLE_UNKNOWN || req_role < rsc->next_role) { crm_debug("%s: Overwriting calculated next role %s" " with requested next role %s", rsc->id, role2text(rsc->next_role), role2text(req_role)); rsc->next_role = req_role; } else if(req_role > rsc->next_role) { crm_info("%s: Not overwriting calculated next role %s" " with requested next role %s", rsc->id, role2text(rsc->next_role), role2text(req_role)); } } if(saved_role > rsc->role) { rsc->role = saved_role; } } gboolean unpack_lrm_resources(node_t *node, xmlNode * lrm_rsc_list, pe_working_set_t *data_set) { CRM_CHECK(node != NULL, return FALSE); crm_debug_3("Unpacking resources on %s", node->details->uname); xml_child_iter_filter( lrm_rsc_list, rsc_entry, XML_LRM_TAG_RESOURCE, unpack_lrm_rsc_state(node, rsc_entry, data_set); ); return TRUE; } static void set_active(resource_t *rsc) { resource_t *top = uber_parent(rsc); if(top && top->variant == pe_master) { rsc->role = RSC_ROLE_SLAVE; } else { rsc->role = RSC_ROLE_STARTED; } } gboolean unpack_rsc_op(resource_t *rsc, node_t *node, xmlNode *xml_op, enum action_fail_response *on_fail, pe_working_set_t *data_set) { const char *id = NULL; const char *key = NULL; const char *task = NULL; const char *magic = NULL; const char *task_id = NULL; const char *actual_rc = NULL; /* const char *target_rc = NULL; */ const char *task_status = NULL; const char *interval_s = NULL; const char *op_digest = NULL; const char *op_version = NULL; int interval = 0; int task_status_i = -2; int actual_rc_i = 0; int target_rc = -1; action_t *action = NULL; node_t *effective_node = NULL; resource_t *failed = NULL; gboolean expired = FALSE; gboolean is_probe = FALSE; CRM_CHECK(rsc != NULL, return FALSE); CRM_CHECK(node != NULL, return FALSE); CRM_CHECK(xml_op != NULL, return FALSE); id = ID(xml_op); task = crm_element_value(xml_op, XML_LRM_ATTR_TASK); task_id = crm_element_value(xml_op, XML_LRM_ATTR_CALLID); task_status = crm_element_value(xml_op, XML_LRM_ATTR_OPSTATUS); op_digest = crm_element_value(xml_op, XML_LRM_ATTR_OP_DIGEST); op_version = crm_element_value(xml_op, XML_ATTR_CRM_VERSION); magic = crm_element_value(xml_op, XML_ATTR_TRANSITION_MAGIC); key = crm_element_value(xml_op, XML_ATTR_TRANSITION_KEY); CRM_CHECK(id != NULL, return FALSE); CRM_CHECK(task != NULL, return FALSE); CRM_CHECK(task_status != NULL, return FALSE); task_status_i = crm_parse_int(task_status, NULL); CRM_CHECK(task_status_i <= LRM_OP_ERROR, return FALSE); CRM_CHECK(task_status_i >= LRM_OP_PENDING, return FALSE); if(safe_str_eq(task, CRMD_ACTION_NOTIFY)) { /* safe to ignore these */ return TRUE; } if(rsc->failure_timeout > 0) { int last_run = 0; if(crm_element_value_int(xml_op, "last-run", &last_run) == 0) { /* int last_change = crm_element_value_int(xml_op, "last_rc_change"); */ time_t now = get_timet_now(data_set); if(now > (last_run + rsc->failure_timeout)) { expired = TRUE; } } } crm_debug_2("Unpacking task %s/%s (call_id=%s, status=%s) on %s (role=%s)", id, task, task_id, task_status, node->details->uname, role2text(rsc->role)); interval_s = crm_element_value(xml_op, XML_LRM_ATTR_INTERVAL); interval = crm_parse_int(interval_s, "0"); if(interval == 0 && safe_str_eq(task, CRMD_ACTION_STATUS)) { is_probe = TRUE; } if(node->details->unclean) { crm_debug_2("Node %s (where %s is running) is unclean." " Further action depends on the value of the stop's on-fail attribue", node->details->uname, rsc->id); } actual_rc = crm_element_value(xml_op, XML_LRM_ATTR_RC); CRM_CHECK(actual_rc != NULL, return FALSE); actual_rc_i = crm_parse_int(actual_rc, NULL); if(key) { int dummy = 0; char *dummy_string = NULL; decode_transition_key(key, &dummy_string, &dummy, &dummy, &target_rc); crm_free(dummy_string); } if(task_status_i == LRM_OP_DONE && target_rc >= 0) { if(target_rc == actual_rc_i) { task_status_i = LRM_OP_DONE; } else { task_status_i = LRM_OP_ERROR; crm_debug("%s on %s returned %d (%s) instead of the expected value: %d (%s)", id, node->details->uname, actual_rc_i, execra_code2string(actual_rc_i), target_rc, execra_code2string(target_rc)); } } else if(task_status_i == LRM_OP_ERROR) { /* let us decide that */ task_status_i = LRM_OP_DONE; } if(task_status_i == LRM_OP_NOTSUPPORTED) { actual_rc_i = EXECRA_UNIMPLEMENT_FEATURE; } if(expired && actual_rc_i != EXECRA_NOT_RUNNING && actual_rc_i != EXECRA_RUNNING_MASTER && actual_rc_i != EXECRA_OK) { crm_notice("Ignoring expired failure %s (rc=%d, magic=%s) on %s", id, actual_rc_i, magic, node->details->uname); goto done; } /* we could clean this up significantly except for old LRMs and CRMs that * didnt include target_rc and liked to remap status */ switch(actual_rc_i) { case EXECRA_NOT_RUNNING: if(is_probe || target_rc == actual_rc_i) { task_status_i = LRM_OP_DONE; rsc->role = RSC_ROLE_STOPPED; /* clear any previous failure actions */ *on_fail = action_fail_ignore; rsc->next_role = RSC_ROLE_UNKNOWN; } else if(safe_str_neq(task, CRMD_ACTION_STOP)) { task_status_i = LRM_OP_ERROR; } break; case EXECRA_RUNNING_MASTER: if(is_probe) { task_status_i = LRM_OP_DONE; crm_notice("Operation %s found resource %s active in master mode on %s", id, rsc->id, node->details->uname); } else if(target_rc == actual_rc_i) { /* nothing to do */ } else if(target_rc >= 0) { task_status_i = LRM_OP_ERROR; /* legacy code for pre-0.6.5 operations */ } else if(safe_str_neq(task, CRMD_ACTION_STATUS) || rsc->role != RSC_ROLE_MASTER) { task_status_i = LRM_OP_ERROR; if(rsc->role != RSC_ROLE_MASTER) { crm_err("%s reported %s in master mode on %s", id, rsc->id, node->details->uname); } } rsc->role = RSC_ROLE_MASTER; break; case EXECRA_FAILED_MASTER: rsc->role = RSC_ROLE_MASTER; task_status_i = LRM_OP_ERROR; break; case EXECRA_UNIMPLEMENT_FEATURE: if(interval > 0) { task_status_i = LRM_OP_NOTSUPPORTED; break; } /* else: fall through */ case EXECRA_INSUFFICIENT_PRIV: case EXECRA_NOT_INSTALLED: case EXECRA_INVALID_PARAM: effective_node = node; /* fall through */ case EXECRA_NOT_CONFIGURED: failed = rsc; if(is_not_set(rsc->flags, pe_rsc_unique)) { failed = uber_parent(failed); } crm_err("Hard error - %s failed with rc=%d: Preventing %s from re-starting %s %s", id, actual_rc_i, failed->id, effective_node?"on":"anywhere", effective_node?effective_node->details->uname:"in the cluster"); resource_location(failed, effective_node, -INFINITY, "hard-error", data_set); if(is_probe) { /* treat these like stops */ task = CRMD_ACTION_STOP; task_status_i = LRM_OP_DONE; crm_xml_add(xml_op, XML_ATTR_UNAME, node->details->uname); add_node_copy(data_set->failed, xml_op); } break; case EXECRA_OK: if(is_probe && target_rc == 7) { task_status_i = LRM_OP_DONE; crm_notice("Operation %s found resource %s active on %s", id, rsc->id, node->details->uname); /* legacy code for pre-0.6.5 operations */ } else if(target_rc < 0 && interval > 0 && rsc->role == RSC_ROLE_MASTER) { /* catch status ops that return 0 instead of 8 while they * are supposed to be in master mode */ task_status_i = LRM_OP_ERROR; } break; default: if(task_status_i == LRM_OP_DONE) { crm_info("Remapping %s (rc=%d) on %s to an ERROR", id, actual_rc_i, node->details->uname); task_status_i = LRM_OP_ERROR; } } if(task_status_i == LRM_OP_ERROR || task_status_i == LRM_OP_TIMEOUT || task_status_i == LRM_OP_NOTSUPPORTED) { action = custom_action(rsc, crm_strdup(id), task, NULL, TRUE, FALSE, data_set); if(expired) { crm_notice("Ignoring expired failure (calculated) %s (rc=%d, magic=%s) on %s", id, actual_rc_i, magic, node->details->uname); goto done; } else if(action->on_fail == action_fail_ignore) { crm_warn("Remapping %s (rc=%d) on %s to DONE: ignore", id, actual_rc_i, node->details->uname); task_status_i = LRM_OP_DONE; } } switch(task_status_i) { case LRM_OP_PENDING: if(safe_str_eq(task, CRMD_ACTION_START)) { set_bit(rsc->flags, pe_rsc_start_pending); set_active(rsc); } else if(safe_str_eq(task, CRMD_ACTION_PROMOTE)) { rsc->role = RSC_ROLE_MASTER; } break; case LRM_OP_DONE: crm_debug_3("%s/%s completed on %s", rsc->id, task, node->details->uname); if(actual_rc_i == EXECRA_NOT_RUNNING) { /* nothing to do */ } else if(safe_str_eq(task, CRMD_ACTION_STOP)) { rsc->role = RSC_ROLE_STOPPED; /* clear any previous failure actions */ switch(*on_fail) { case action_fail_block: case action_fail_stop: case action_fail_fence: case action_fail_migrate: case action_fail_standby: crm_debug_2("%s.%s is not cleared by a completed stop", rsc->id, fail2text(*on_fail)); break; case action_fail_ignore: case action_fail_recover: case action_migrate_failure: *on_fail = action_fail_ignore; rsc->next_role = RSC_ROLE_UNKNOWN; } } else if(safe_str_eq(task, CRMD_ACTION_PROMOTE)) { rsc->role = RSC_ROLE_MASTER; } else if(safe_str_eq(task, CRMD_ACTION_DEMOTE)) { rsc->role = RSC_ROLE_SLAVE; } else if(rsc->role < RSC_ROLE_STARTED) { crm_debug_3("%s active on %s", rsc->id, node->details->uname); set_active(rsc); } break; case LRM_OP_ERROR: case LRM_OP_TIMEOUT: case LRM_OP_NOTSUPPORTED: crm_warn("Processing failed op %s on %s: %s (%d)", id, node->details->uname, execra_code2string(actual_rc_i), actual_rc_i); crm_xml_add(xml_op, XML_ATTR_UNAME, node->details->uname); add_node_copy(data_set->failed, xml_op); if(*on_fail < action->on_fail) { *on_fail = action->on_fail; } if(safe_str_eq(task, CRMD_ACTION_STOP)) { resource_location( rsc, node, -INFINITY, "__stop_fail__", data_set); } else if(safe_str_eq(task, CRMD_ACTION_PROMOTE)) { rsc->role = RSC_ROLE_MASTER; } else if(safe_str_eq(task, CRMD_ACTION_DEMOTE)) { /* * staying in role=master ends up putting the PE/TE into a loop * setting role=slave is not dangerous because no master will be * promoted until the failed resource has been fully stopped */ crm_warn("Forcing %s to stop after a failed demote action", rsc->id); rsc->next_role = RSC_ROLE_STOPPED; rsc->role = RSC_ROLE_SLAVE; } else if(compare_version("2.0", op_version) > 0 && safe_str_eq(task, CRMD_ACTION_START)) { crm_warn("Compatibility handling for failed op %s on %s", id, node->details->uname); resource_location( rsc, node, -INFINITY, "__legacy_start__", data_set); } if(rsc->role < RSC_ROLE_STARTED) { set_active(rsc); } crm_debug_2("Resource %s: role=%s, unclean=%s, on_fail=%s, fail_role=%s", rsc->id, role2text(rsc->role), node->details->unclean?"true":"false", fail2text(action->on_fail), role2text(action->fail_role)); if(action->fail_role != RSC_ROLE_STARTED && rsc->next_role < action->fail_role) { rsc->next_role = action->fail_role; } if(action->fail_role == RSC_ROLE_STOPPED) { crm_err("Making sure %s doesn't come up again", rsc->id); /* make sure it doesnt come up again */ pe_free_shallow_adv(rsc->allowed_nodes, TRUE); rsc->allowed_nodes = node_list_dup( data_set->nodes, FALSE, FALSE); slist_iter( node, node_t, rsc->allowed_nodes, lpc, node->weight = -INFINITY; ); } pe_free_action(action); action = NULL; break; case LRM_OP_CANCELLED: /* do nothing?? */ pe_err("Dont know what to do for cancelled ops yet"); break; } done: crm_debug_3("Resource %s after %s: role=%s", rsc->id, task, role2text(rsc->role)); pe_free_action(action); return TRUE; } gboolean add_node_attrs(xmlNode *xml_obj, node_t *node, gboolean overwrite, pe_working_set_t *data_set) { g_hash_table_insert(node->details->attrs, crm_strdup("#"XML_ATTR_UNAME), crm_strdup(node->details->uname)); g_hash_table_insert(node->details->attrs, crm_strdup("#"XML_ATTR_ID), crm_strdup(node->details->id)); if(safe_str_eq(node->details->id, data_set->dc_uuid)) { data_set->dc_node = node; node->details->is_dc = TRUE; g_hash_table_insert(node->details->attrs, crm_strdup("#"XML_ATTR_DC), crm_strdup(XML_BOOLEAN_TRUE)); } else { g_hash_table_insert(node->details->attrs, crm_strdup("#"XML_ATTR_DC), crm_strdup(XML_BOOLEAN_FALSE)); } unpack_instance_attributes( data_set->input, xml_obj, XML_TAG_ATTR_SETS, NULL, node->details->attrs, NULL, overwrite, data_set->now); return TRUE; } static GListPtr extract_operations(const char *node, const char *rsc, xmlNode *rsc_entry, gboolean active_filter) { int stop_index = -1; int start_index = -1; GListPtr op_list = NULL; GListPtr sorted_op_list = NULL; /* extract operations */ op_list = NULL; sorted_op_list = NULL; xml_child_iter_filter( rsc_entry, rsc_op, XML_LRM_TAG_RSC_OP, crm_xml_add(rsc_op, "resource", rsc); crm_xml_add(rsc_op, XML_ATTR_UNAME, node); op_list = g_list_append(op_list, rsc_op); ); if(op_list == NULL) { /* if there are no operations, there is nothing to do */ return NULL; } sorted_op_list = g_list_sort(op_list, sort_op_by_callid); /* create active recurring operations as optional */ if(active_filter == FALSE) { return sorted_op_list; } op_list = NULL; calculate_active_ops(sorted_op_list, &start_index, &stop_index); slist_iter(rsc_op, xmlNode, sorted_op_list, lpc, if(start_index < stop_index) { crm_debug_4("Skipping %s: not active", ID(rsc_entry)); break; } else if(lpc < start_index) { crm_debug_4("Skipping %s: old", ID(rsc_op)); continue; } op_list = g_list_append(op_list, rsc_op); ); g_list_free(sorted_op_list); return op_list; } GListPtr find_operations( const char *rsc, const char *node, gboolean active_filter, pe_working_set_t *data_set) { GListPtr output = NULL; GListPtr intermediate = NULL; xmlNode *tmp = NULL; xmlNode *status = find_xml_node(data_set->input, XML_CIB_TAG_STATUS, TRUE); const char *uname = NULL; node_t *this_node = NULL; xml_child_iter_filter( status, node_state, XML_CIB_TAG_STATE, uname = crm_element_value(node_state, XML_ATTR_UNAME); if(node != NULL && safe_str_neq(uname, node)) { continue; } this_node = pe_find_node(data_set->nodes, uname); CRM_CHECK(this_node != NULL, continue); determine_online_status(node_state, this_node, data_set); if(this_node->details->online || is_set(data_set->flags, pe_flag_stonith_enabled)) { /* offline nodes run no resources... * unless stonith is enabled in which case we need to * make sure rsc start events happen after the stonith */ tmp = find_xml_node(node_state, XML_CIB_TAG_LRM, FALSE); tmp = find_xml_node(tmp, XML_LRM_TAG_RESOURCES, FALSE); xml_child_iter_filter( tmp, lrm_rsc, XML_LRM_TAG_RESOURCE, const char *rsc_id = crm_element_value(lrm_rsc, XML_ATTR_ID); if(rsc != NULL && safe_str_neq(rsc_id, rsc)) { continue; } intermediate = extract_operations(uname, rsc_id, lrm_rsc, active_filter); output = g_list_concat(output, intermediate); ); } ); return output; } diff --git a/lib/pengine/unpack.h b/lib/pengine/unpack.h index 5275dfd1e7..14beebd7ce 100644 --- a/lib/pengine/unpack.h +++ b/lib/pengine/unpack.h @@ -1,92 +1,94 @@ /* * Copyright (C) 2004 Andrew Beekhof * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef PENGINE_UNPACK__H #define PENGINE_UNPACK__H extern gboolean unpack_resources( xmlNode *xml_resources, pe_working_set_t *data_set); extern gboolean unpack_config(xmlNode *config, pe_working_set_t *data_set); extern gboolean unpack_nodes(xmlNode *xml_nodes, pe_working_set_t *data_set); extern gboolean unpack_status(xmlNode *status, pe_working_set_t *data_set); extern gint sort_op_by_callid(gconstpointer a, gconstpointer b); extern gboolean unpack_lrm_resources( node_t *node, xmlNode * lrm_state, pe_working_set_t *data_set); extern gboolean add_node_attrs( xmlNode * attrs, node_t *node, gboolean overwrite, pe_working_set_t *data_set); extern gboolean determine_online_status( xmlNode * node_state, node_t *this_node, pe_working_set_t *data_set); extern const char *param_value( GHashTable *hash, xmlNode * parent, const char *name); +extern char *clone_zero(const char *last_rsc_id); +extern char *increment_clone(char *last_rsc_id); /* * The man pages for both curses and ncurses suggest inclusion of "curses.h". * We believe the following to be acceptable and portable. */ #if defined(HAVE_LIBNCURSES) || defined(HAVE_LIBCURSES) # if defined(HAVE_NCURSES_H) && !defined(HAVE_INCOMPATIBLE_PRINTW) # include # define CURSES_ENABLED 1 # elif defined(HAVE_NCURSES_NCURSES_H) && !defined(HAVE_INCOMPATIBLE_PRINTW) # include # define CURSES_ENABLED 1 # elif defined(HAVE_CURSES_H) && !defined(HAVE_INCOMPATIBLE_PRINTW) # include # define CURSES_ENABLED 1 # elif defined(HAVE_CURSES_CURSES_H) && !defined(HAVE_INCOMPATIBLE_PRINTW) # include # define CURSES_ENABLED 1 # else # define CURSES_ENABLED 0 # endif #else # define CURSES_ENABLED 0 #endif #if CURSES_ENABLED # define status_printw(fmt, args...) printw(fmt, ##args) #else # define status_printw(fmt, args...) \ crm_err("printw support requires ncurses to be available during configure"); \ do_crm_log(LOG_WARNING, fmt, ##args); #endif #define status_print(fmt, args...) \ if(options & pe_print_html) { \ FILE *stream = print_data; \ fprintf(stream, fmt, ##args); \ } else if(options & pe_print_ncurses) { \ status_printw(fmt, ##args); \ } else if(options & pe_print_printf) { \ FILE *stream = print_data; \ fprintf(stream, fmt, ##args); \ } else if(options & pe_print_log) { \ int log_level = *(int*)print_data; \ do_crm_log(log_level, fmt, ##args); \ } #endif diff --git a/lib/pengine/utils.c b/lib/pengine/utils.c index 8cf426b431..631ebf0c65 100644 --- a/lib/pengine/utils.c +++ b/lib/pengine/utils.c @@ -1,1418 +1,1413 @@ /* * Copyright (C) 2004 Andrew Beekhof * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include extern xmlNode *get_object_root(const char *object_type,xmlNode *the_root); void print_str_str(gpointer key, gpointer value, gpointer user_data); gboolean ghash_free_str_str(gpointer key, gpointer value, gpointer user_data); void unpack_operation( action_t *action, xmlNode *xml_obj, pe_working_set_t* data_set); void pe_free_shallow(GListPtr alist) { pe_free_shallow_adv(alist, TRUE); } void pe_free_shallow_adv(GListPtr alist, gboolean with_data) { GListPtr item; GListPtr item_next = alist; if(with_data == FALSE && alist != NULL) { g_list_free(alist); return; } while(item_next != NULL) { item = item_next; item_next = item_next->next; if(with_data) { /* crm_debug_5("freeing %p", item->data); */ crm_free(item->data); } item->data = NULL; item->next = NULL; g_list_free_1(item); } } node_t * node_copy(node_t *this_node) { node_t *new_node = NULL; CRM_CHECK(this_node != NULL, return NULL); crm_malloc0(new_node, sizeof(node_t)); CRM_ASSERT(new_node != NULL); crm_debug_5("Copying %p (%s) to %p", this_node, this_node->details->uname, new_node); new_node->weight = this_node->weight; new_node->fixed = this_node->fixed; new_node->details = this_node->details; return new_node; } /* are the contents of list1 and list2 equal * nodes with weight < 0 are ignored if filter == TRUE * * slow but linear * */ gboolean node_list_eq(GListPtr list1, GListPtr list2, gboolean filter) { node_t *other_node; GListPtr lhs = list1; GListPtr rhs = list2; slist_iter( node, node_t, lhs, lpc, if(node == NULL || (filter && node->weight < 0)) { continue; } other_node = (node_t*) pe_find_node_id(rhs, node->details->id); if(other_node == NULL || other_node->weight < 0) { return FALSE; } ); lhs = list2; rhs = list1; slist_iter( node, node_t, lhs, lpc, if(node == NULL || (filter && node->weight < 0)) { continue; } other_node = (node_t*) pe_find_node_id(rhs, node->details->id); if(other_node == NULL || other_node->weight < 0) { return FALSE; } ); return TRUE; } /* any node in list1 or list2 and not in the other gets a score of -INFINITY */ GListPtr node_list_exclude(GListPtr list1, GListPtr list2) { node_t *other_node = NULL; GListPtr result = NULL; result = node_list_dup(list1, FALSE, FALSE); slist_iter( node, node_t, result, lpc, other_node = pe_find_node_id(list2, node->details->id); if(other_node == NULL) { node->weight = -INFINITY; } else { node->weight = merge_weights(node->weight, other_node->weight); } ); slist_iter( node, node_t, list2, lpc, other_node = pe_find_node_id(result, node->details->id); if(other_node == NULL) { node_t *new_node = node_copy(node); new_node->weight = -INFINITY; result = g_list_append(result, new_node); } ); return result; } /* the intersection of list1 and list2 */ GListPtr node_list_and(GListPtr list1, GListPtr list2, gboolean filter) { GListPtr result = NULL; unsigned lpc = 0; for(lpc = 0; lpc < g_list_length(list1); lpc++) { node_t *node = (node_t*)g_list_nth_data(list1, lpc); node_t *other_node = pe_find_node_id(list2, node->details->id); node_t *new_node = NULL; if(other_node != NULL) { new_node = node_copy(node); } if(new_node != NULL) { crm_debug_4("%s: %d + %d", node->details->uname, other_node->weight, new_node->weight); new_node->weight = merge_weights( new_node->weight, other_node->weight); crm_debug_3("New node weight for %s: %d", new_node->details->uname, new_node->weight); if(filter && new_node->weight < 0) { crm_free(new_node); new_node = NULL; } } if(new_node != NULL) { result = g_list_append(result, new_node); } } return result; } /* list1 - list2 */ GListPtr node_list_minus(GListPtr list1, GListPtr list2, gboolean filter) { GListPtr result = NULL; slist_iter( node, node_t, list1, lpc, node_t *other_node = pe_find_node_id(list2, node->details->id); node_t *new_node = NULL; if(node == NULL || other_node != NULL || (filter && node->weight < 0)) { continue; } new_node = node_copy(node); result = g_list_append(result, new_node); ); crm_debug_3("Minus result len: %d", g_list_length(result)); return result; } /* list1 + list2 - (intersection of list1 and list2) */ GListPtr node_list_xor(GListPtr list1, GListPtr list2, gboolean filter) { GListPtr result = NULL; slist_iter( node, node_t, list1, lpc, node_t *new_node = NULL; node_t *other_node = (node_t*) pe_find_node_id(list2, node->details->id); if(node == NULL || other_node != NULL || (filter && node->weight < 0)) { continue; } new_node = node_copy(node); result = g_list_append(result, new_node); ); slist_iter( node, node_t, list2, lpc, node_t *new_node = NULL; node_t *other_node = (node_t*) pe_find_node_id(list1, node->details->id); if(node == NULL || other_node != NULL || (filter && node->weight < 0)) { continue; } new_node = node_copy(node); result = g_list_append(result, new_node); ); crm_debug_3("Xor result len: %d", g_list_length(result)); return result; } GListPtr node_list_or(GListPtr list1, GListPtr list2, gboolean filter) { node_t *other_node = NULL; GListPtr result = NULL; gboolean needs_filter = FALSE; result = node_list_dup(list1, FALSE, filter); slist_iter( node, node_t, list2, lpc, if(node == NULL) { continue; } other_node = (node_t*)pe_find_node_id( result, node->details->id); if(other_node != NULL) { crm_debug_4("%s + %s: %d + %d", node->details->uname, other_node->details->uname, node->weight, other_node->weight); other_node->weight = merge_weights( other_node->weight, node->weight); if(filter && node->weight < 0) { needs_filter = TRUE; } } else if(filter == FALSE || node->weight >= 0) { node_t *new_node = node_copy(node); result = g_list_append(result, new_node); } ); /* not the neatest way, but the most expedient for now */ if(filter && needs_filter) { GListPtr old_result = result; result = node_list_dup(old_result, FALSE, filter); pe_free_shallow_adv(old_result, TRUE); } return result; } GListPtr node_list_dup(GListPtr list1, gboolean reset, gboolean filter) { GListPtr result = NULL; slist_iter( this_node, node_t, list1, lpc, node_t *new_node = NULL; if(filter && this_node->weight < 0) { continue; } new_node = node_copy(this_node); if(reset) { new_node->weight = 0; } if(new_node != NULL) { result = g_list_append(result, new_node); } ); return result; } void dump_node_scores(int level, resource_t *rsc, const char *comment, GListPtr nodes) { GListPtr list = nodes; if(rsc) { list = rsc->allowed_nodes; } if(is_set(rsc->flags, pe_rsc_orphan)) { /* Don't show the allocation scores for orphans */ return; } slist_iter( node, node_t, list, lpc, if(level == 0) { if(rsc) { fprintf(stdout, "%s: %s allocation score on %s: %d\n", comment, rsc->id, node->details->uname, node->weight); } else { fprintf(stdout, "%s: %s = %d\n", comment, node->details->uname, node->weight); } } else { if(rsc) { do_crm_log_unlikely(level, "%s: %s allocation score on %s: %d", comment, rsc->id, node->details->uname, node->weight); } else { do_crm_log_unlikely(level, "%s: %s = %d", comment, node->details->uname, node->weight); } } ); if(rsc && rsc->children) { slist_iter( child, resource_t, rsc->children, lpc, dump_node_scores(level, child, comment, nodes); ); } } gint sort_rsc_index(gconstpointer a, gconstpointer b) { const resource_t *resource1 = (const resource_t*)a; const resource_t *resource2 = (const resource_t*)b; if(a == NULL && b == NULL) { return 0; } if(a == NULL) { return 1; } if(b == NULL) { return -1; } if(resource1->sort_index > resource2->sort_index) { return -1; } if(resource1->sort_index < resource2->sort_index) { return 1; } return 0; } gint sort_rsc_priority(gconstpointer a, gconstpointer b) { const resource_t *resource1 = (const resource_t*)a; const resource_t *resource2 = (const resource_t*)b; if(a == NULL && b == NULL) { return 0; } if(a == NULL) { return 1; } if(b == NULL) { return -1; } if(resource1->priority > resource2->priority) { return -1; } if(resource1->priority < resource2->priority) { return 1; } return 0; } action_t * custom_action(resource_t *rsc, char *key, const char *task, node_t *on_node, gboolean optional, gboolean save_action, pe_working_set_t *data_set) { action_t *action = NULL; GListPtr possible_matches = NULL; CRM_CHECK(key != NULL, return NULL); CRM_CHECK(task != NULL, return NULL); if(save_action && rsc != NULL) { possible_matches = find_actions(rsc->actions, key, on_node); } if(possible_matches != NULL) { crm_free(key); if(g_list_length(possible_matches) > 1) { pe_warn("Action %s for %s on %s exists %d times", task, rsc?rsc->id:"", on_node?on_node->details->uname:"", g_list_length(possible_matches)); } action = g_list_nth_data(possible_matches, 0); crm_debug_4("Found existing action (%d) %s for %s on %s", action->id, task, rsc?rsc->id:"", on_node?on_node->details->uname:""); g_list_free(possible_matches); } if(action == NULL) { if(save_action) { crm_debug_4("Creating%s action %d: %s for %s on %s", optional?"":" manditory", data_set->action_id, key, rsc?rsc->id:"", on_node?on_node->details->uname:""); } crm_malloc0(action, sizeof(action_t)); if(save_action) { action->id = data_set->action_id++; } else { action->id = 0; } action->rsc = rsc; CRM_ASSERT(task != NULL); action->task = crm_strdup(task); action->node = on_node; action->uuid = key; action->actions_before = NULL; action->actions_after = NULL; action->failure_is_fatal = TRUE; action->pseudo = FALSE; action->dumped = FALSE; action->runnable = TRUE; action->processed = FALSE; action->optional = optional; action->seen_count = 0; action->extra = g_hash_table_new_full( g_str_hash, g_str_equal, free, free); action->meta = g_hash_table_new_full( g_str_hash, g_str_equal, free, free); if(save_action) { data_set->actions = g_list_append( data_set->actions, action); } if(rsc != NULL) { action->op_entry = find_rsc_op_entry(rsc, key); unpack_operation( action, action->op_entry, data_set); if(save_action) { rsc->actions = g_list_append( rsc->actions, action); } } if(save_action) { crm_debug_4("Action %d created", action->id); } } if(optional == FALSE && action->optional) { crm_debug_2("Action %d (%s) marked manditory", action->id, action->uuid); action->optional = FALSE; } if(rsc != NULL) { enum action_tasks a_task = text2task(action->task); int warn_level = LOG_DEBUG_3; if(save_action) { warn_level = LOG_WARNING; } if(action->node != NULL && action->op_entry != NULL) { unpack_instance_attributes( data_set->input, action->op_entry, XML_TAG_ATTR_SETS, action->node->details->attrs, action->extra, NULL, FALSE, data_set->now); } if(action->pseudo) { /* leave untouched */ } else if(action->node == NULL) { action->runnable = FALSE; } else if(g_hash_table_lookup(action->meta, XML_LRM_ATTR_INTERVAL) == NULL && is_not_set(rsc->flags, pe_rsc_managed)) { do_crm_log_unlikely(LOG_DEBUG, "Action %s (unmanaged)", action->uuid); action->optional = TRUE; /* action->runnable = FALSE; */ } else if(action->node->details->online == FALSE) { action->runnable = FALSE; do_crm_log(warn_level, "Action %s on %s is unrunnable (offline)", action->uuid, action->node->details->uname); if(is_set(action->rsc->flags, pe_rsc_managed) && save_action && a_task == stop_rsc) { do_crm_log(warn_level, "Marking node %s unclean", action->node->details->uname); action->node->details->unclean = TRUE; } } else if(action->node->details->pending) { action->runnable = FALSE; do_crm_log(warn_level, "Action %s on %s is unrunnable (pending)", action->uuid, action->node->details->uname); } else if(action->needs == rsc_req_nothing) { crm_debug_3("Action %s doesnt require anything", action->uuid); action->runnable = TRUE; #if 0 /* * No point checking this * - if we dont have quorum we cant stonith anyway */ } else if(action->needs == rsc_req_stonith) { crm_debug_3("Action %s requires only stonith", action->uuid); action->runnable = TRUE; #endif } else if(is_set(data_set->flags, pe_flag_have_quorum) == FALSE && data_set->no_quorum_policy == no_quorum_stop) { action->runnable = FALSE; crm_debug("%s\t%s (cancelled : quorum)", action->node->details->uname, action->uuid); } else if(is_set(data_set->flags, pe_flag_have_quorum) == FALSE && data_set->no_quorum_policy == no_quorum_freeze) { crm_debug_3("Check resource is already active"); if(rsc->fns->active(rsc, TRUE) == FALSE) { action->runnable = FALSE; crm_debug("%s\t%s (cancelled : quorum freeze)", action->node->details->uname, action->uuid); } } else { crm_debug_3("Action %s is runnable", action->uuid); action->runnable = TRUE; } if(save_action) { switch(a_task) { case stop_rsc: set_bit(rsc->flags, pe_rsc_stopping); break; case start_rsc: clear_bit(rsc->flags, pe_rsc_starting); if(action->runnable) { set_bit(rsc->flags, pe_rsc_starting); } break; default: break; } } } return action; } void unpack_operation( action_t *action, xmlNode *xml_obj, pe_working_set_t* data_set) { int value_i = 0; unsigned long long interval = 0; unsigned long long start_delay = 0; char *value_ms = NULL; const char *class = NULL; const char *value = NULL; const char *field = NULL; CRM_CHECK(action->rsc != NULL, return); unpack_instance_attributes(data_set->input, data_set->op_defaults, XML_TAG_META_SETS, NULL, action->meta, NULL, FALSE, data_set->now); xml_prop_iter(xml_obj, name, value, if(value != NULL && g_hash_table_lookup(action->meta, name) == NULL) { g_hash_table_insert(action->meta, crm_strdup(name), crm_strdup(value)); } ); unpack_instance_attributes(data_set->input, xml_obj, XML_TAG_META_SETS, NULL, action->meta, NULL, FALSE, data_set->now); unpack_instance_attributes(data_set->input, xml_obj, XML_TAG_ATTR_SETS, NULL, action->meta, NULL, FALSE, data_set->now); g_hash_table_remove(action->meta, "id"); class = g_hash_table_lookup(action->rsc->meta, "class"); value = g_hash_table_lookup(action->meta, "requires"); - if(value == NULL && safe_str_neq(action->task, CRMD_ACTION_START)) { - /* todo: integrate stop as an option? */ + if(safe_str_eq(class, "stonith")) { action->needs = rsc_req_nothing; - value = "nothing (default)"; + value = "nothing (fencing op)"; + + } else if(value == NULL && safe_str_neq(action->task, CRMD_ACTION_START)) { + action->needs = rsc_req_nothing; + value = "nothing (default)"; } else if(safe_str_eq(value, "nothing")) { action->needs = rsc_req_nothing; } else if(safe_str_eq(value, "quorum")) { action->needs = rsc_req_quorum; } else if(safe_str_eq(value, "fencing")) { action->needs = rsc_req_stonith; } else if(data_set->no_quorum_policy == no_quorum_ignore || safe_str_eq(class, "stonith")) { action->needs = rsc_req_nothing; value = "nothing (default)"; } else if(data_set->no_quorum_policy == no_quorum_freeze && is_set(data_set->flags, pe_flag_stonith_enabled)) { action->needs = rsc_req_stonith; value = "fencing (default)"; } else { action->needs = rsc_req_quorum; value = "quorum (default)"; } - if(safe_str_eq(class, "stonith")) { - if(action->needs == rsc_req_stonith) { - crm_config_err("Stonith resources (eg. %s) cannot require" - " fencing to start", action->rsc->id); - } - action->needs = rsc_req_nothing; - value = "nothing (fencing override)"; - } crm_debug_3("\tAction %s requires: %s", action->task, value); value = g_hash_table_lookup(action->meta, XML_OP_ATTR_ON_FAIL); if(safe_str_eq(action->task, CRMD_ACTION_STOP) && safe_str_eq(value, "standby")) { crm_config_err("on-fail=standby is not allowed for stop actions: %s", action->rsc->id); value = NULL; } if(value == NULL) { } else if(safe_str_eq(value, "block")) { action->on_fail = action_fail_block; } else if(safe_str_eq(value, "fence")) { action->on_fail = action_fail_fence; value = "node fencing"; if(is_set(data_set->flags, pe_flag_stonith_enabled) == FALSE) { crm_config_err("Specifying on_fail=fence and" " stonith-enabled=false makes no sense"); action->on_fail = action_fail_stop; action->fail_role = RSC_ROLE_STOPPED; value = "stop resource"; } } else if(safe_str_eq(value, "standby")) { action->on_fail = action_fail_standby; value = "node standby"; } else if(safe_str_eq(value, "ignore") || safe_str_eq(value, "nothing")) { action->on_fail = action_fail_ignore; value = "ignore"; } else if(safe_str_eq(value, "migrate")) { action->on_fail = action_fail_migrate; value = "force migration"; } else if(safe_str_eq(value, "stop")) { action->on_fail = action_fail_stop; action->fail_role = RSC_ROLE_STOPPED; value = "stop resource"; } else if(safe_str_eq(value, "restart")) { action->on_fail = action_fail_recover; value = "restart (and possibly migrate)"; } else { pe_err("Resource %s: Unknown failure type (%s)", action->rsc->id, value); value = NULL; } /* defaults */ if(value == NULL && safe_str_eq(action->task, CRMD_ACTION_STOP)) { if(is_set(data_set->flags, pe_flag_stonith_enabled)) { action->on_fail = action_fail_fence; value = "resource fence (default)"; } else { action->on_fail = action_fail_block; value = "resource block (default)"; } } else if(value == NULL && safe_str_eq(action->task, CRMD_ACTION_MIGRATED)) { action->on_fail = action_migrate_failure; value = "atomic migration recovery (default)"; } else if(value == NULL) { action->on_fail = action_fail_recover; value = "restart (and possibly migrate) (default)"; } crm_debug_3("\t%s failure handling: %s", action->task, value); value = NULL; if(xml_obj != NULL) { value = g_hash_table_lookup(action->meta, "role_after_failure"); } if(value != NULL && action->fail_role == RSC_ROLE_UNKNOWN) { action->fail_role = text2role(value); } /* defaults */ if(action->fail_role == RSC_ROLE_UNKNOWN) { if(safe_str_eq(action->task, CRMD_ACTION_PROMOTE)) { action->fail_role = RSC_ROLE_SLAVE; } else { action->fail_role = RSC_ROLE_STARTED; } } crm_debug_3("\t%s failure results in: %s", action->task, role2text(action->fail_role)); field = XML_LRM_ATTR_INTERVAL; value = g_hash_table_lookup(action->meta, field); if(value != NULL) { interval = crm_get_interval(value); if(interval > 0) { value_ms = crm_itoa(interval); g_hash_table_replace(action->meta, crm_strdup(field), value_ms); } else { g_hash_table_remove(action->meta, field); } } field = XML_OP_ATTR_START_DELAY; value = g_hash_table_lookup(action->meta, field); if(value != NULL) { value_i = crm_get_msec(value); if(value_i < 0) { value_i = 0; } start_delay = value_i; value_ms = crm_itoa(value_i); g_hash_table_replace(action->meta, crm_strdup(field), value_ms); } else if(interval > 0 && g_hash_table_lookup(action->meta, XML_OP_ATTR_ORIGIN)) { char *date_str = NULL; char *date_str_mutable = NULL; ha_time_t *origin = NULL; value = g_hash_table_lookup(action->meta, XML_OP_ATTR_ORIGIN); date_str = crm_strdup(value); date_str_mutable = date_str; origin = parse_date(&date_str_mutable); crm_free(date_str); if(origin == NULL) { crm_config_err("Operation %s contained an invalid "XML_OP_ATTR_ORIGIN": %s", ID(xml_obj), value); } else { ha_time_t *delay = NULL; int rc = compare_date(origin, data_set->now); unsigned long long delay_s = 0; while(rc < 0) { add_seconds(origin, interval/1000); rc = compare_date(origin, data_set->now); } delay = subtract_time(origin, data_set->now); delay_s = date_in_seconds(delay); /* log_date(LOG_DEBUG_5, "delay", delay, ha_log_date|ha_log_time|ha_log_local); */ crm_info("Calculated a start delay of %llus for %s", delay_s, ID(xml_obj)); g_hash_table_replace(action->meta, crm_strdup(XML_OP_ATTR_START_DELAY), crm_itoa(delay_s * 1000)); start_delay = delay_s * 1000; free_ha_date(origin); free_ha_date(delay); } } field = XML_ATTR_TIMEOUT; value = g_hash_table_lookup(action->meta, field); if(value == NULL) { value = pe_pref( data_set->config_hash, "default-action-timeout"); } value_i = crm_get_msec(value); if(value_i < 0) { value_i = 0; } value_i += start_delay; value_ms = crm_itoa(value_i); g_hash_table_replace(action->meta, crm_strdup(field), value_ms); } xmlNode * find_rsc_op_entry(resource_t *rsc, const char *key) { int number = 0; const char *name = NULL; const char *value = NULL; const char *interval = NULL; char *match_key = NULL; xmlNode *op = NULL; xml_child_iter_filter( rsc->ops_xml, operation, "op", name = crm_element_value(operation, "name"); interval = crm_element_value(operation, XML_LRM_ATTR_INTERVAL); value = crm_element_value(operation, "enabled"); if(value && crm_is_true(value) == FALSE) { continue; } number = crm_get_interval(interval); if(number < 0) { continue; } match_key = generate_op_key(rsc->id, name, number); if(safe_str_eq(key, match_key)) { op = operation; } crm_free(match_key); if(op != NULL) { return op; } ); if(strstr(key, CRMD_ACTION_MIGRATE) || strstr(key, CRMD_ACTION_MIGRATED)) { match_key = generate_op_key(rsc->id, "migrate", 0); op = find_rsc_op_entry(rsc, match_key); crm_free(match_key); } if(op == NULL) { crm_debug_3("No match for %s", key); } return op; } void print_node(const char *pre_text, node_t *node, gboolean details) { if(node == NULL) { crm_debug_4("%s%s: ", pre_text==NULL?"":pre_text, pre_text==NULL?"":": "); return; } crm_debug_4("%s%s%sNode %s: (weight=%d, fixed=%s)", pre_text==NULL?"":pre_text, pre_text==NULL?"":": ", node->details==NULL?"error ":node->details->online?"":"Unavailable/Unclean ", node->details->uname, node->weight, node->fixed?"True":"False"); if(details && node != NULL && node->details != NULL) { char *pe_mutable = crm_strdup("\t\t"); crm_debug_4("\t\t===Node Attributes"); g_hash_table_foreach(node->details->attrs, print_str_str, pe_mutable); crm_free(pe_mutable); crm_debug_4("\t\t=== Resources"); slist_iter( rsc, resource_t, node->details->running_rsc, lpc, print_resource(LOG_DEBUG_4, "\t\t", rsc, FALSE); ); } } /* * Used by the HashTable for-loop */ void print_str_str(gpointer key, gpointer value, gpointer user_data) { crm_debug_4("%s%s %s ==> %s", user_data==NULL?"":(char*)user_data, user_data==NULL?"":": ", (char*)key, (char*)value); } void print_resource( int log_level, const char *pre_text, resource_t *rsc, gboolean details) { long options = pe_print_log; if(rsc == NULL) { do_crm_log(log_level-1, "%s%s: ", pre_text==NULL?"":pre_text, pre_text==NULL?"":": "); return; } if(details) { options |= pe_print_details; } rsc->fns->print(rsc, pre_text, options, &log_level); } void pe_free_action(action_t *action) { if(action == NULL) { return; } pe_free_shallow(action->actions_before);/* action_warpper_t* */ pe_free_shallow(action->actions_after); /* action_warpper_t* */ g_hash_table_destroy(action->extra); g_hash_table_destroy(action->meta); crm_free(action->task); crm_free(action->uuid); crm_free(action); } GListPtr find_recurring_actions(GListPtr input, node_t *not_on_node) { const char *value = NULL; GListPtr result = NULL; CRM_CHECK(input != NULL, return NULL); slist_iter( action, action_t, input, lpc, value = g_hash_table_lookup(action->meta, XML_LRM_ATTR_INTERVAL); if(value == NULL) { /* skip */ } else if(safe_str_eq(value, "0")) { /* skip */ } else if(safe_str_eq(CRMD_ACTION_CANCEL, action->task)) { /* skip */ } else if(not_on_node == NULL) { crm_debug_5("(null) Found: %s", action->uuid); result = g_list_append(result, action); } else if(action->node == NULL) { /* skip */ } else if(action->node->details != not_on_node->details) { crm_debug_5("Found: %s", action->uuid); result = g_list_append(result, action); } ); return result; } action_t * find_first_action(GListPtr input, const char *uuid, const char *task, node_t *on_node) { CRM_CHECK(uuid || task, return NULL); slist_iter( action, action_t, input, lpc, if(uuid != NULL && safe_str_neq(uuid, action->uuid)) { continue; } else if(task != NULL && safe_str_neq(task, action->task)) { continue; } else if(on_node == NULL) { return action; } else if(action->node == NULL) { continue; } else if(on_node->details == action->node->details) { return action; } ); return NULL; } GListPtr find_actions(GListPtr input, const char *key, node_t *on_node) { GListPtr result = NULL; CRM_CHECK(key != NULL, return NULL); slist_iter( action, action_t, input, lpc, crm_debug_5("Matching %s against %s", key, action->uuid); if(safe_str_neq(key, action->uuid)) { continue; } else if(on_node == NULL) { result = g_list_append(result, action); } else if(action->node == NULL) { /* skip */ crm_debug_2("While looking for %s action on %s, " "found an unallocated one. Assigning" " it to the requested node...", key, on_node->details->uname); action->node = on_node; result = g_list_append(result, action); } else if(on_node->details == action->node->details) { result = g_list_append(result, action); } ); return result; } GListPtr find_actions_exact(GListPtr input, const char *key, node_t *on_node) { GListPtr result = NULL; CRM_CHECK(key != NULL, return NULL); slist_iter( action, action_t, input, lpc, crm_debug_5("Matching %s against %s", key, action->uuid); if(safe_str_neq(key, action->uuid)) { crm_debug_3("Key mismatch: %s vs. %s", key, action->uuid); continue; } else if(on_node == NULL || action->node == NULL) { crm_debug_3("on_node=%p, action->node=%p", on_node, action->node); continue; } else if(safe_str_eq(on_node->details->id, action->node->details->id)) { result = g_list_append(result, action); } crm_debug_2("Node mismatch: %s vs. %s", on_node->details->id, action->node->details->id); ); return result; } void set_id(xmlNode * xml_obj, const char *prefix, int child) { int id_len = 0; gboolean use_prefix = TRUE; gboolean use_child = TRUE; char *new_id = NULL; const char *id = crm_element_value(xml_obj, XML_ATTR_ID); id_len = 1 + strlen(id); if(child > 999) { pe_err("Are you insane?!?" " The CRM does not support > 1000 children per resource"); return; } else if(child < 0) { use_child = FALSE; } else { id_len += 4; /* child */ } if(prefix == NULL || safe_str_eq(id, prefix)) { use_prefix = FALSE; } else { id_len += (1 + strlen(prefix)); } crm_malloc0(new_id, id_len); if(use_child) { snprintf(new_id, id_len, "%s%s%s:%d", use_prefix?prefix:"", use_prefix?":":"", id, child); } else { snprintf(new_id, id_len, "%s%s%s", use_prefix?prefix:"", use_prefix?":":"", id); } crm_xml_add(xml_obj, XML_ATTR_ID, new_id); crm_free(new_id); } static void resource_node_score(resource_t *rsc, node_t *node, int score, const char *tag) { node_t *match = NULL; if(rsc->children) { slist_iter( child_rsc, resource_t, rsc->children, lpc, resource_node_score(child_rsc, node, score, tag); ); } crm_debug_2("Setting %s for %s on %s: %d", tag, rsc->id, node->details->uname, score); match = pe_find_node_id(rsc->allowed_nodes, node->details->id); if(match == NULL) { match = node_copy(node); match->weight = 0; rsc->allowed_nodes = g_list_append(rsc->allowed_nodes, match); } match->weight = merge_weights(match->weight, score); } void resource_location(resource_t *rsc, node_t *node, int score, const char *tag, pe_working_set_t *data_set) { if(node != NULL) { resource_node_score(rsc, node, score, tag); } else if(data_set != NULL) { slist_iter( node, node_t, data_set->nodes, lpc, resource_node_score(rsc, node, score, tag); ); } else { slist_iter( node, node_t, rsc->allowed_nodes, lpc, resource_node_score(rsc, node, score, tag); ); } if(node == NULL && score == -INFINITY) { if(rsc->allocated_to) { crm_info("Deallocating %s from %s", rsc->id, rsc->allocated_to->details->uname); crm_free(rsc->allocated_to); rsc->allocated_to = NULL; } } } #define sort_return(an_int) crm_free(a_uuid); crm_free(b_uuid); return an_int gint sort_op_by_callid(gconstpointer a, gconstpointer b) { char *a_uuid = NULL; char *b_uuid = NULL; const xmlNode *xml_a = a; const xmlNode *xml_b = b; const char *a_xml_id = crm_element_value_const(xml_a, XML_ATTR_ID); const char *b_xml_id = crm_element_value_const(xml_b, XML_ATTR_ID); const char *a_task_id = crm_element_value_const(xml_a, XML_LRM_ATTR_CALLID); const char *b_task_id = crm_element_value_const(xml_b, XML_LRM_ATTR_CALLID); const char *a_key = crm_element_value_const(xml_a, XML_ATTR_TRANSITION_MAGIC); const char *b_key = crm_element_value_const(xml_b, XML_ATTR_TRANSITION_MAGIC); int dummy = -1; int a_id = -1; int b_id = -1; int a_rc = -1; int b_rc = -1; int a_status = -1; int b_status = -1; int a_call_id = -1; int b_call_id = -1; if(safe_str_eq(a_xml_id, b_xml_id)) { /* We have duplicate lrm_rsc_op entries in the status * section which is unliklely to be a good thing * - we can handle it easily enough, but we need to get * to the bottom of why its happening. */ pe_err("Duplicate lrm_rsc_op entries named %s", a_xml_id); sort_return(0); } CRM_CHECK(a_task_id != NULL && b_task_id != NULL, crm_err("a: %s, b: %s", crm_str(a_xml_id), crm_str(b_xml_id)); sort_return(0)); a_call_id = crm_parse_int(a_task_id, NULL); b_call_id = crm_parse_int(b_task_id, NULL); if(a_call_id == -1 && b_call_id == -1) { /* both are pending ops so it doesnt matter since * stops are never pending */ sort_return(0); } else if(a_call_id >= 0 && a_call_id < b_call_id) { crm_debug_4("%s (%d) < %s (%d) : call id", a_xml_id, a_call_id, b_xml_id, b_call_id); sort_return(-1); } else if(b_call_id >= 0 && a_call_id > b_call_id) { crm_debug_4("%s (%d) > %s (%d) : call id", a_xml_id, a_call_id, b_xml_id, b_call_id); sort_return(1); } crm_debug_5("%s (%d) == %s (%d) : continuing", a_xml_id, a_call_id, b_xml_id, b_call_id); /* now process pending ops */ CRM_CHECK(a_key != NULL && b_key != NULL, sort_return(0)); CRM_CHECK(decode_transition_magic( a_key, &a_uuid, &a_id, &dummy, &a_status, &a_rc, &dummy), sort_return(0)); CRM_CHECK(decode_transition_magic( b_key, &b_uuid, &b_id, &dummy, &b_status, &b_rc, &dummy), sort_return(0)); /* try and determin the relative age of the operation... * some pending operations (ie. a start) may have been supuerceeded * by a subsequent stop * * [a|b]_id == -1 means its a shutdown operation and _always_ comes last */ if(safe_str_neq(a_uuid, b_uuid) || a_id == b_id) { /* * some of the logic in here may be redundant... * * if the UUID from the TE doesnt match then one better * be a pending operation. * pending operations dont survive between elections and joins * because we query the LRM directly */ CRM_CHECK(a_call_id == -1 || b_call_id == -1, crm_err("a: %s=%d, b: %s=%d", crm_str(a_xml_id), a_call_id, crm_str(b_xml_id), b_call_id); sort_return(0)); CRM_CHECK(a_call_id >= 0 || b_call_id >= 0, sort_return(0)); if(b_call_id == -1) { crm_debug_2("%s (%d) < %s (%d) : transition + call id", a_xml_id, a_call_id, b_xml_id, b_call_id); sort_return(-1); } if(a_call_id == -1) { crm_debug_2("%s (%d) > %s (%d) : transition + call id", a_xml_id, a_call_id, b_xml_id, b_call_id); sort_return(1); } } else if((a_id >= 0 && a_id < b_id) || b_id == -1) { crm_debug_3("%s (%d) < %s (%d) : transition", a_xml_id, a_id, b_xml_id, b_id); sort_return(-1); } else if((b_id >= 0 && a_id > b_id) || a_id == -1) { crm_debug_3("%s (%d) > %s (%d) : transition", a_xml_id, a_id, b_xml_id, b_id); sort_return(1); } /* we should never end up here */ crm_err("%s (%d:%d:%s) ?? %s (%d:%d:%s) : default", a_xml_id, a_call_id, a_id, a_uuid, b_xml_id, b_call_id, b_id, b_uuid); CRM_CHECK(FALSE, sort_return(0)); } time_t get_timet_now(pe_working_set_t *data_set) { time_t now = 0; if(data_set && data_set->now) { now = data_set->now->tm_now; } if(now == 0) { /* eventually we should convert data_set->now into time_tm * for now, its only triggered by PE regression tests */ now = time(NULL); crm_crit("Defaulting to 'now'"); if(data_set && data_set->now) { data_set->now->tm_now = now; } } return now; } int get_failcount(node_t *node, resource_t *rsc, int *last_failure, pe_working_set_t *data_set) { int last = 0; int fail_count = 0; resource_t *failed = rsc; char *fail_attr = crm_concat("fail-count", rsc->id, '-'); const char *value = g_hash_table_lookup(node->details->attrs, fail_attr); if(is_not_set(rsc->flags, pe_rsc_unique)) { failed = uber_parent(rsc); } if(value != NULL) { fail_count = char2score(value); crm_info("%s has failed %d times on %s", failed->id, fail_count, node->details->uname); } crm_free(fail_attr); fail_attr = crm_concat("last-failure", rsc->id, '-'); value = g_hash_table_lookup(node->details->attrs, fail_attr); if(value != NULL && rsc->failure_timeout) { last = crm_parse_int(value, NULL); if(last_failure) { *last_failure = last; } if(last > 0) { time_t now = get_timet_now(data_set); if(now > (last + rsc->failure_timeout)) { crm_notice("Failcount for %s on %s has expired (limit was %ds)", failed->id, node->details->uname, rsc->failure_timeout); fail_count = 0; } } } crm_free(fail_attr); return fail_count; } gboolean get_target_role(resource_t *rsc, enum rsc_role_e *role) { const char *value = g_hash_table_lookup(rsc->meta, XML_RSC_ATTR_TARGET_ROLE); CRM_CHECK(role != NULL, return FALSE); if(value == NULL || safe_str_eq("started", value) || safe_str_eq("default", value)) { return FALSE; } *role = text2role(value); if(role == RSC_ROLE_UNKNOWN) { crm_config_err("%s: Unknown value for %s: %s", rsc->id, XML_RSC_ATTR_TARGET_ROLE, value); return FALSE; } return TRUE; } diff --git a/pengine/clone.c b/pengine/clone.c index 0f4d8bc867..a991d97615 100644 --- a/pengine/clone.c +++ b/pengine/clone.c @@ -1,1266 +1,1275 @@ /* * Copyright (C) 2004 Andrew Beekhof * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #define VARIANT_CLONE 1 #include gint sort_clone_instance(gconstpointer a, gconstpointer b); void child_stopping_constraints( clone_variant_data_t *clone_data, resource_t *self, resource_t *child, resource_t *last, pe_working_set_t *data_set); void child_starting_constraints( clone_variant_data_t *clone_data, resource_t *self, resource_t *child, resource_t *last, pe_working_set_t *data_set); static node_t * parent_node_instance(const resource_t *rsc, node_t *node) { node_t *ret = NULL; if(node != NULL) { ret = pe_find_node_id( rsc->parent->allowed_nodes, node->details->id); } return ret; } static gboolean did_fail(const resource_t *rsc) { if(is_set(rsc->flags, pe_rsc_failed)) { return TRUE; } slist_iter( child_rsc, resource_t, rsc->children, lpc, if(did_fail(child_rsc)) { return TRUE; } ); return FALSE; } gint sort_clone_instance(gconstpointer a, gconstpointer b) { int level = LOG_DEBUG_3; node_t *node1 = NULL; node_t *node2 = NULL; gboolean can1 = TRUE; gboolean can2 = TRUE; gboolean with_scores = TRUE; const resource_t *resource1 = (const resource_t*)a; const resource_t *resource2 = (const resource_t*)b; CRM_ASSERT(resource1 != NULL); CRM_ASSERT(resource2 != NULL); /* allocation order: * - active instances * - instances running on nodes with the least copies * - active instances on nodes that cant support them or are to be fenced * - failed instances * - inactive instances */ do_crm_log_unlikely(level+1, "%s ? %s", resource1->id, resource2->id); if(resource1->running_on && resource2->running_on) { if(g_list_length(resource1->running_on) < g_list_length(resource2->running_on)) { do_crm_log_unlikely(level, "%s < %s: running_on", resource1->id, resource2->id); return -1; } else if(g_list_length(resource1->running_on) > g_list_length(resource2->running_on)) { do_crm_log_unlikely(level, "%s > %s: running_on", resource1->id, resource2->id); return 1; } } if(resource1->running_on) { node1 = resource1->running_on->data; } if(resource2->running_on) { node2 = resource2->running_on->data; } if(node1) { node_t *match = pe_find_node_id(resource1->allowed_nodes, node1->details->id); if(match == NULL || match->weight < 0) { do_crm_log_unlikely(level, "%s: current location is unavailable", resource1->id); node1 = NULL; can1 = FALSE; } } if(node2) { node_t *match = pe_find_node_id(resource2->allowed_nodes, node2->details->id); if(match == NULL || match->weight < 0) { do_crm_log_unlikely(level, "%s: current location is unavailable", resource2->id); node2 = NULL; can2 = FALSE; } } if(can1 != can2) { if(can1) { do_crm_log_unlikely(level, "%s < %s: availability of current location", resource1->id, resource2->id); return -1; } do_crm_log_unlikely(level, "%s > %s: availability of current location", resource1->id, resource2->id); return 1; } if(resource1->priority < resource2->priority) { do_crm_log_unlikely(level, "%s < %s: priority", resource1->id, resource2->id); return 1; } else if(resource1->priority > resource2->priority) { do_crm_log_unlikely(level, "%s > %s: priority", resource1->id, resource2->id); return -1; } if(node1 == NULL && node2 == NULL) { do_crm_log_unlikely(level, "%s == %s: not active", resource1->id, resource2->id); return 0; } if(node1 != node2) { if(node1 == NULL) { do_crm_log_unlikely(level, "%s > %s: active", resource1->id, resource2->id); return 1; } else if(node2 == NULL) { do_crm_log_unlikely(level, "%s < %s: active", resource1->id, resource2->id); return -1; } } can1 = can_run_resources(node1); can2 = can_run_resources(node2); if(can1 != can2) { if(can1) { do_crm_log_unlikely(level, "%s < %s: can", resource1->id, resource2->id); return -1; } do_crm_log_unlikely(level, "%s > %s: can", resource1->id, resource2->id); return 1; } node1 = parent_node_instance(resource1, node1); node2 = parent_node_instance(resource2, node2); if(node1 != NULL && node2 == NULL) { do_crm_log_unlikely(level, "%s < %s: not allowed", resource1->id, resource2->id); return -1; } else if(node1 == NULL && node2 != NULL) { do_crm_log_unlikely(level, "%s > %s: not allowed", resource1->id, resource2->id); return 1; } if(node1 == NULL) { do_crm_log_unlikely(level, "%s == %s: not allowed", resource1->id, resource2->id); return 0; } if(node1->count < node2->count) { do_crm_log_unlikely(level, "%s < %s: count", resource1->id, resource2->id); return -1; } else if(node1->count > node2->count) { do_crm_log_unlikely(level, "%s > %s: count", resource1->id, resource2->id); return 1; } if(with_scores) { int max = 0; int lpc = 0; GListPtr list1 = node_list_dup(resource1->allowed_nodes, FALSE, FALSE); GListPtr list2 = node_list_dup(resource2->allowed_nodes, FALSE, FALSE); list1 = g_list_sort(list1, sort_node_weight); list2 = g_list_sort(list2, sort_node_weight); max = g_list_length(list1); if(max < g_list_length(list2)) { max = g_list_length(list2); } for(;lpc < max; lpc++) { node1 = g_list_nth_data(list1, lpc); node2 = g_list_nth_data(list2, lpc); if(node1 == NULL) { do_crm_log_unlikely(level, "%s < %s: node score NULL", resource1->id, resource2->id); pe_free_shallow(list1); pe_free_shallow(list2); return 1; } else if(node2 == NULL) { do_crm_log_unlikely(level, "%s > %s: node score NULL", resource1->id, resource2->id); pe_free_shallow(list1); pe_free_shallow(list2); return -1; } if(node1->weight < node2->weight) { do_crm_log_unlikely(level, "%s < %s: node score", resource1->id, resource2->id); pe_free_shallow(list1); pe_free_shallow(list2); return 1; } else if(node1->weight > node2->weight) { do_crm_log_unlikely(level, "%s > %s: node score", resource1->id, resource2->id); pe_free_shallow(list1); pe_free_shallow(list2); return -1; } } pe_free_shallow(list1); pe_free_shallow(list2); } can1 = did_fail(resource1); can2 = did_fail(resource2); if(can1 != can2) { if(can1) { do_crm_log_unlikely(level, "%s > %s: failed", resource1->id, resource2->id); return 1; } do_crm_log_unlikely(level, "%s < %s: failed", resource1->id, resource2->id); return -1; } if(node1 && node2) { int max = 0; int lpc = 0; GListPtr list1 = g_list_append(NULL, node_copy(resource1->running_on->data)); GListPtr list2 = g_list_append(NULL, node_copy(resource2->running_on->data)); /* Possibly a replacement for the with_scores block above */ slist_iter( constraint, rsc_colocation_t, resource1->parent->rsc_cons_lhs, lpc, do_crm_log_unlikely(level+1, "Applying %s to %s", constraint->id, resource1->id); list1 = native_merge_weights( constraint->rsc_lh, resource1->id, list1, constraint->node_attribute, constraint->score/INFINITY, FALSE); ); slist_iter( constraint, rsc_colocation_t, resource2->parent->rsc_cons_lhs, lpc, do_crm_log_unlikely(level+1, "Applying %s to %s", constraint->id, resource2->id); list2 = native_merge_weights( constraint->rsc_lh, resource2->id, list2, constraint->node_attribute, constraint->score/INFINITY, FALSE); ); list1 = g_list_sort(list1, sort_node_weight); list2 = g_list_sort(list2, sort_node_weight); max = g_list_length(list1); if(max < g_list_length(list2)) { max = g_list_length(list2); } for(;lpc < max; lpc++) { node1 = g_list_nth_data(list1, lpc); node2 = g_list_nth_data(list2, lpc); if(node1 == NULL) { do_crm_log_unlikely(level, "%s < %s: colocated score NULL", resource1->id, resource2->id); pe_free_shallow(list1); pe_free_shallow(list2); return 1; } else if(node2 == NULL) { do_crm_log_unlikely(level, "%s > %s: colocated score NULL", resource1->id, resource2->id); pe_free_shallow(list1); pe_free_shallow(list2); return -1; } if(node1->weight < node2->weight) { do_crm_log_unlikely(level, "%s < %s: colocated score", resource1->id, resource2->id); pe_free_shallow(list1); pe_free_shallow(list2); return 1; } else if(node1->weight > node2->weight) { do_crm_log_unlikely(level, "%s > %s: colocated score", resource1->id, resource2->id); pe_free_shallow(list1); pe_free_shallow(list2); return -1; } } pe_free_shallow(list1); pe_free_shallow(list2); } do_crm_log_unlikely(level, "%s == %s: default %d", resource1->id, resource2->id, node2->weight); return 0; } static node_t * can_run_instance(resource_t *rsc, node_t *node) { node_t *local_node = NULL; clone_variant_data_t *clone_data = NULL; if(can_run_resources(node) == FALSE) { goto bail; } else if(is_set(rsc->flags, pe_rsc_orphan)) { goto bail; } local_node = parent_node_instance(rsc, node); get_clone_variant_data(clone_data, rsc->parent); if(local_node == NULL) { crm_warn("%s cannot run on %s: node not allowed", rsc->id, node->details->uname); goto bail; } else if(local_node->count < clone_data->clone_node_max) { return local_node; } else { crm_debug_2("%s cannot run on %s: node full", rsc->id, node->details->uname); } bail: if(node) { common_update_score(rsc, node->details->id, -INFINITY); } return NULL; } static node_t * color_instance(resource_t *rsc, pe_working_set_t *data_set) { node_t *chosen = NULL; node_t *local_node = NULL; crm_debug_2("Processing %s", rsc->id); if(is_not_set(rsc->flags, pe_rsc_provisional)) { return rsc->fns->location(rsc, NULL, FALSE); } else if(is_set(rsc->flags, pe_rsc_allocating)) { crm_debug("Dependancy loop detected involving %s", rsc->id); return NULL; } if(rsc->allowed_nodes) { slist_iter(try_node, node_t, rsc->allowed_nodes, lpc, can_run_instance(rsc, try_node); ); } chosen = rsc->cmds->color(rsc, data_set); if(chosen) { local_node = pe_find_node_id( rsc->parent->allowed_nodes, chosen->details->id); if(local_node) { local_node->count++; } else if(is_set(rsc->flags, pe_rsc_managed)) { /* what to do? we can't enforce per-node limits in this case */ crm_config_err("%s not found in %s (list=%d)", chosen->details->id, rsc->parent->id, g_list_length(rsc->parent->allowed_nodes)); } } return chosen; } static void append_parent_colocation(resource_t *rsc, resource_t *child, gboolean all) { slist_iter(cons, rsc_colocation_t, rsc->rsc_cons, lpc, if(all || cons->score < 0 || cons->score == INFINITY) { child->rsc_cons = g_list_append(child->rsc_cons, cons); } ); slist_iter(cons, rsc_colocation_t, rsc->rsc_cons_lhs, lpc, if(all || cons->score < 0) { child->rsc_cons_lhs = g_list_append(child->rsc_cons_lhs, cons); } ); } node_t * clone_color(resource_t *rsc, pe_working_set_t *data_set) { int allocated = 0; int available_nodes = 0; clone_variant_data_t *clone_data = NULL; get_clone_variant_data(clone_data, rsc); if(is_not_set(rsc->flags, pe_rsc_provisional)) { return NULL; } else if(is_set(rsc->flags, pe_rsc_allocating)) { crm_debug("Dependancy loop detected involving %s", rsc->id); return NULL; } set_bit(rsc->flags, pe_rsc_allocating); crm_debug_2("Processing %s", rsc->id); /* this information is used by sort_clone_instance() when deciding in which * order to allocate clone instances */ slist_iter( constraint, rsc_colocation_t, rsc->rsc_cons_lhs, lpc, rsc->allowed_nodes = constraint->rsc_lh->cmds->merge_weights( constraint->rsc_lh, rsc->id, rsc->allowed_nodes, constraint->node_attribute, constraint->score/INFINITY, TRUE); ); dump_node_scores(show_scores?0:scores_log_level, rsc, __FUNCTION__, rsc->allowed_nodes); /* count now tracks the number of clones currently allocated */ slist_iter(node, node_t, rsc->allowed_nodes, lpc, node->count = 0; ); slist_iter(child, resource_t, rsc->children, lpc, if(g_list_length(child->running_on) > 0) { node_t *child_node = child->running_on->data; node_t *local_node = parent_node_instance( child, child->running_on->data); if(local_node) { local_node->count++; } else { crm_err("%s is running on %s which isn't allowed", child->id, child_node->details->uname); } } ); rsc->children = g_list_sort(rsc->children, sort_clone_instance); /* count now tracks the number of clones we have allocated */ slist_iter(node, node_t, rsc->allowed_nodes, lpc, node->count = 0; ); rsc->allowed_nodes = g_list_sort( rsc->allowed_nodes, sort_node_weight); slist_iter(node, node_t, rsc->allowed_nodes, lpc, if(can_run_resources(node)) { available_nodes++; } ); slist_iter(child, resource_t, rsc->children, lpc, if(allocated >= clone_data->clone_max) { crm_debug("Child %s not allocated - limit reached", child->id); resource_location(child, NULL, -INFINITY, "clone_color:limit_reached", data_set); } else if (clone_data->clone_max < available_nodes) { /* Only include positive colocation preferences of dependant resources * if not every node will get a copy of the clone */ append_parent_colocation(rsc, child, TRUE); } else { append_parent_colocation(rsc, child, FALSE); } if(color_instance(child, data_set)) { allocated++; } ); crm_debug("Allocated %d %s instances of a possible %d", allocated, rsc->id, clone_data->clone_max); clear_bit(rsc->flags, pe_rsc_provisional); clear_bit(rsc->flags, pe_rsc_allocating); return NULL; } static void clone_update_pseudo_status( - resource_t *rsc, gboolean *stopping, gboolean *starting) + resource_t *rsc, gboolean *stopping, gboolean *starting, gboolean *active) { if(rsc->children) { slist_iter(child, resource_t, rsc->children, lpc, - clone_update_pseudo_status(child, stopping, starting) + clone_update_pseudo_status(child, stopping, starting, active) ); return; } - CRM_ASSERT(stopping != NULL); + CRM_ASSERT(active != NULL); CRM_ASSERT(starting != NULL); + CRM_ASSERT(stopping != NULL); + if(rsc->running_on) { + *active = TRUE; + } + slist_iter( action, action_t, rsc->actions, lpc, if(*starting && *stopping) { return; } else if(action->optional) { crm_debug_3("Skipping optional: %s", action->uuid); continue; } else if(action->pseudo == FALSE && action->runnable == FALSE){ crm_debug_3("Skipping unrunnable: %s", action->uuid); continue; } else if(safe_str_eq(RSC_STOP, action->task)) { crm_debug_2("Stopping due to: %s", action->uuid); *stopping = TRUE; } else if(safe_str_eq(RSC_START, action->task)) { if(action->runnable == FALSE) { crm_debug_3("Skipping pseudo-op: %s run=%d, pseudo=%d", action->uuid, action->runnable, action->pseudo); } else { crm_debug_2("Starting due to: %s", action->uuid); crm_debug_3("%s run=%d, pseudo=%d", action->uuid, action->runnable, action->pseudo); *starting = TRUE; } } ); } static action_t * find_rsc_action(resource_t *rsc, const char *key, gboolean active_only, GListPtr *list) { action_t *match = NULL; GListPtr possible = NULL; GListPtr active = NULL; possible = find_actions(rsc->actions, key, NULL); if(active_only) { slist_iter(op, action_t, possible, lpc, if(op->optional == FALSE) { active = g_list_append(active, op); } ); if(active && g_list_length(active) == 1) { match = g_list_nth_data(active, 0); } if(list) { *list = active; active = NULL; } } else if(possible && g_list_length(possible) == 1) { match = g_list_nth_data(possible, 0); } if(list) { *list = possible; possible = NULL; } if(possible) { g_list_free(possible); } if(active) { g_list_free(active); } return match; } static void child_ordering_constraints(resource_t *rsc, pe_working_set_t *data_set) { char *key = NULL; action_t *stop = NULL; action_t *start = NULL; action_t *last_stop = NULL; action_t *last_start = NULL; gboolean active_only = TRUE; /* change to false to get the old behavior */ clone_variant_data_t *clone_data = NULL; get_clone_variant_data(clone_data, rsc); if(clone_data->ordered == FALSE) { return; } slist_iter( child, resource_t, rsc->children, lpc, key = stop_key(child); stop = find_rsc_action(child, key, active_only, NULL); crm_free(key); key = start_key(child); start = find_rsc_action(child, key, active_only, NULL); crm_free(key); if(stop) { if(last_stop) { /* child/child relative stop */ order_actions(stop, last_stop, pe_order_implies_left); } last_stop = stop; } if(start) { if(last_start) { /* child/child relative start */ order_actions(last_start, start, pe_order_implies_left); } last_start = start; } ); } void clone_create_actions(resource_t *rsc, pe_working_set_t *data_set) { + gboolean child_active = FALSE; gboolean child_starting = FALSE; gboolean child_stopping = FALSE; action_t *stop = NULL; action_t *stopped = NULL; action_t *start = NULL; action_t *started = NULL; resource_t *last_start_rsc = NULL; resource_t *last_stop_rsc = NULL; clone_variant_data_t *clone_data = NULL; get_clone_variant_data(clone_data, rsc); crm_debug_2("Creating actions for %s", rsc->id); slist_iter( child_rsc, resource_t, rsc->children, lpc, child_rsc->cmds->create_actions(child_rsc, data_set); clone_update_pseudo_status( - child_rsc, &child_stopping, &child_starting); + child_rsc, &child_stopping, &child_starting, &child_active); if(is_set(child_rsc->flags, pe_rsc_starting)) { last_start_rsc = child_rsc; } if(is_set(child_rsc->flags, pe_rsc_stopping)) { last_stop_rsc = child_rsc; } ); /* start */ start = start_action(rsc, NULL, !child_starting); started = custom_action(rsc, started_key(rsc), RSC_STARTED, NULL, !child_starting, TRUE, data_set); start->pseudo = TRUE; start->runnable = TRUE; started->pseudo = TRUE; - started->runnable = TRUE; started->priority = INFINITY; + + if(child_active || child_starting) { + started->runnable = TRUE; + } child_ordering_constraints(rsc, data_set); child_starting_constraints(clone_data, rsc, NULL, last_start_rsc, data_set); clone_data->start_notify = create_notification_boundaries(rsc, RSC_START, start, started, data_set); /* stop */ stop = stop_action(rsc, NULL, !child_stopping); stopped = custom_action(rsc, stopped_key(rsc), RSC_STOPPED, NULL, !child_stopping, TRUE, data_set); stop->pseudo = TRUE; stop->runnable = TRUE; stopped->pseudo = TRUE; stopped->runnable = TRUE; stopped->priority = INFINITY; child_stopping_constraints(clone_data, rsc, NULL, last_stop_rsc, data_set); clone_data->stop_notify = create_notification_boundaries(rsc, RSC_STOP, stop, stopped, data_set); if(clone_data->stop_notify && clone_data->start_notify) { order_actions(clone_data->stop_notify->post_done, clone_data->start_notify->pre, pe_order_optional); } } void child_starting_constraints( clone_variant_data_t *clone_data, resource_t *rsc, resource_t *child, resource_t *last, pe_working_set_t *data_set) { if(child == NULL && last == NULL) { crm_debug("%s has no active children", rsc->id); return; } if(child != NULL) { order_start_start( rsc, child, pe_order_runnable_left|pe_order_implies_left_printed); new_rsc_order(child, RSC_START, rsc, RSC_STARTED, pe_order_implies_right_printed, data_set); } if(FALSE && clone_data->ordered) { if(child == NULL) { /* last child start before global started */ new_rsc_order(last, RSC_START, rsc, RSC_STARTED, pe_order_runnable_left, data_set); } else if(last == NULL) { /* global start before first child start */ order_start_start( rsc, child, pe_order_implies_left); } else { /* child/child relative start */ order_start_start(last, child, pe_order_implies_left); } } } void child_stopping_constraints( clone_variant_data_t *clone_data, resource_t *rsc, resource_t *child, resource_t *last, pe_working_set_t *data_set) { if(child == NULL && last == NULL) { crm_debug("%s has no active children", rsc->id); return; } if(child != NULL) { order_stop_stop(rsc, child, pe_order_shutdown|pe_order_implies_left_printed); new_rsc_order(child, RSC_STOP, rsc, RSC_STOPPED, pe_order_implies_right_printed, data_set); } if(FALSE && clone_data->ordered) { if(last == NULL) { /* first child stop before global stopped */ new_rsc_order(child, RSC_STOP, rsc, RSC_STOPPED, pe_order_runnable_left, data_set); } else if(child == NULL) { /* global stop before last child stop */ order_stop_stop( rsc, last, pe_order_implies_left); } else { /* child/child relative stop */ order_stop_stop(child, last, pe_order_implies_left); } } } void clone_internal_constraints(resource_t *rsc, pe_working_set_t *data_set) { resource_t *last_rsc = NULL; clone_variant_data_t *clone_data = NULL; get_clone_variant_data(clone_data, rsc); native_internal_constraints(rsc, data_set); /* global stop before stopped */ new_rsc_order(rsc, RSC_STOP, rsc, RSC_STOPPED, pe_order_runnable_left, data_set); /* global start before started */ new_rsc_order(rsc, RSC_START, rsc, RSC_STARTED, pe_order_runnable_left, data_set); /* global stopped before start */ new_rsc_order(rsc, RSC_STOPPED, rsc, RSC_START, pe_order_optional, data_set); slist_iter( child_rsc, resource_t, rsc->children, lpc, child_rsc->cmds->internal_constraints(child_rsc, data_set); child_starting_constraints( clone_data, rsc, child_rsc, last_rsc, data_set); child_stopping_constraints( clone_data, rsc, child_rsc, last_rsc, data_set); last_rsc = child_rsc; ); } resource_t* find_compatible_child( resource_t *local_child, resource_t *rsc, enum rsc_role_e filter, gboolean current) { node_t *local_node = NULL; node_t *node = NULL; clone_variant_data_t *clone_data = NULL; get_clone_variant_data(clone_data, rsc); local_node = local_child->fns->location(local_child, NULL, current); if(local_node == NULL) { crm_debug("Can't colocate unrunnable child %s with %s", local_child->id, rsc->id); return NULL; } slist_iter( child_rsc, resource_t, rsc->children, lpc, enum rsc_role_e next_role = child_rsc->fns->state(child_rsc, current); node = child_rsc->fns->location(child_rsc, NULL, current); if(filter != RSC_ROLE_UNKNOWN && next_role != filter) { crm_debug_2("Filtered %s", child_rsc->id); continue; } if(node && local_node && node->details == local_node->details) { crm_info("Colocating %s with %s on %s", local_child->id, child_rsc->id, node->details->uname); return child_rsc; } ); crm_debug("Can't colocate child %s with %s", local_child->id, rsc->id); return NULL; } void clone_rsc_colocation_lh( resource_t *rsc_lh, resource_t *rsc_rh, rsc_colocation_t *constraint) { gboolean do_interleave = FALSE; resource_t *rsc = constraint->rsc_lh; clone_variant_data_t *clone_data = NULL; clone_variant_data_t *clone_data_rh = NULL; if(rsc == NULL) { pe_err("rsc_lh was NULL for %s", constraint->id); return; } else if(constraint->rsc_rh == NULL) { pe_err("rsc_rh was NULL for %s", constraint->id); return; } else { crm_debug_4("Processing constraints from %s", rsc->id); } get_clone_variant_data(clone_data, rsc); if(constraint->rsc_rh->variant == pe_clone || constraint->rsc_rh->variant == pe_master) { get_clone_variant_data( clone_data_rh, constraint->rsc_rh); if(clone_data->clone_node_max != clone_data_rh->clone_node_max) { crm_config_err("Cannot interleave "XML_CIB_TAG_INCARNATION " %s and %s because" " they do not support the same number of" " resources per node", constraint->rsc_lh->id, constraint->rsc_rh->id); /* only the LHS side needs to be labeled as interleave */ } else if(clone_data->interleave) { do_interleave = TRUE; } else if(constraint->score >= INFINITY) { GListPtr lhs = NULL, rhs = NULL; lhs = rsc_lh->allowed_nodes; slist_iter( child_rsc, resource_t, rsc_rh->children, lpc, node_t *chosen = child_rsc->fns->location(child_rsc, NULL, FALSE); if(chosen != NULL) { rhs = g_list_append(rhs, chosen); } ); rsc_lh->allowed_nodes = node_list_exclude(lhs, rhs); pe_free_shallow_adv(rhs, FALSE); pe_free_shallow(lhs); return; } } else if(constraint->score >= INFINITY) { crm_config_err("Manditory co-location of clones (%s) with other" " non-clone (%s) resources is not supported", rsc_lh->id, rsc_rh->id); return; } if(do_interleave) { resource_t *rh_child = NULL; slist_iter(lh_child, resource_t, rsc->children, lpc, CRM_ASSERT(lh_child != NULL); rh_child = find_compatible_child( lh_child, rsc_rh, RSC_ROLE_UNKNOWN, FALSE); if(rh_child == NULL) { crm_debug_2("No match found for %s", lh_child->id); continue; } crm_debug("Interleaving %s with %s", lh_child->id, rh_child->id); lh_child->cmds->rsc_colocation_lh( lh_child, rh_child, constraint); ); return; } slist_iter( child_rsc, resource_t, rsc->children, lpc, child_rsc->cmds->rsc_colocation_lh(child_rsc, constraint->rsc_rh, constraint); ); } void clone_rsc_colocation_rh( resource_t *rsc_lh, resource_t *rsc_rh, rsc_colocation_t *constraint) { clone_variant_data_t *clone_data = NULL; CRM_CHECK(rsc_lh != NULL, return); CRM_CHECK(rsc_lh->variant == pe_native, return); get_clone_variant_data(clone_data, rsc_rh); crm_debug_3("Processing constraint %s: %d", constraint->id, constraint->score); if(rsc_rh == NULL) { pe_err("rsc_rh was NULL for %s", constraint->id); return; } else if(is_set(rsc_rh->flags, pe_rsc_provisional)) { crm_debug_3("%s is still provisional", rsc_rh->id); return; } else if(constraint->score >= INFINITY) { GListPtr lhs = NULL, rhs = NULL; lhs = rsc_lh->allowed_nodes; slist_iter( child_rsc, resource_t, rsc_rh->children, lpc, node_t *chosen = child_rsc->fns->location(child_rsc, NULL, FALSE); if(chosen != NULL) { rhs = g_list_append(rhs, chosen); } ); rsc_lh->allowed_nodes = node_list_exclude(lhs, rhs); pe_free_shallow_adv(rhs, FALSE); pe_free_shallow(lhs); return; } slist_iter( child_rsc, resource_t, rsc_rh->children, lpc, child_rsc->cmds->rsc_colocation_rh(rsc_lh, child_rsc, constraint); ); } void clone_rsc_order_lh(resource_t *rsc, order_constraint_t *order, pe_working_set_t *data_set) { resource_t *r1 = NULL; resource_t *r2 = NULL; gboolean do_interleave = FALSE; clone_variant_data_t *clone_data = NULL; get_clone_variant_data(clone_data, rsc); crm_debug_4("%s->%s", order->lh_action_task, order->rh_action_task); if(order->rh_rsc == NULL) { order->lh_action_task = convert_non_atomic_task(order->lh_action_task, FALSE, TRUE); native_rsc_order_lh(rsc, order, data_set); return; } r1 = uber_parent(rsc); r2 = uber_parent(order->rh_rsc); if(r1 == r2) { native_rsc_order_lh(rsc, order, data_set); return; } if(order->rh_rsc->variant == pe_clone || order->rh_rsc->variant == pe_master) { clone_variant_data_t *clone_data_rh = NULL; get_clone_variant_data(clone_data_rh, order->rh_rsc); if(clone_data->clone_node_max != clone_data_rh->clone_node_max) { crm_config_err("Cannot interleave "XML_CIB_TAG_INCARNATION " %s and %s because they do not support the same" " number of resources per node", rsc->id, order->rh_rsc->id); /* only the LHS side needs to be labeled as interleave */ } else if(clone_data->interleave) { do_interleave = TRUE; } } if(order->rh_rsc == NULL) { do_interleave = FALSE; } if(do_interleave) { resource_t *lh_child = NULL; resource_t *rh_saved = order->rh_rsc; gboolean current = FALSE; if(strstr(order->lh_action_task, "_stop_0") || strstr(order->lh_action_task, "_demote_0")) { current = TRUE; } slist_iter( rh_child, resource_t, rh_saved->children, lpc, CRM_ASSERT(rh_child != NULL); lh_child = find_compatible_child(rh_child, rsc, RSC_ROLE_UNKNOWN, current); if(lh_child == NULL) { crm_debug_2("No match found for %s", rh_child->id); continue; } crm_debug("Interleaving %s with %s", lh_child->id, rh_child->id); order->rh_rsc = rh_child; lh_child->cmds->rsc_order_lh(lh_child, order, data_set); order->rh_rsc = rh_saved; ); } else { #if 0 if(order->type != pe_order_optional) { crm_debug("Upgraded ordering constraint %d - 0x%.6x", order->id, order->type); native_rsc_order_lh(rsc, order, data_set); } #endif if(order->type & pe_order_implies_left) { if(rsc->variant == order->rh_rsc->variant) { crm_debug_2("Clone-to-clone ordering: %s -> %s 0x%.6x", order->lh_action_task, order->rh_action_task, order->type); /* stop instances on the same nodes as stopping RHS instances */ slist_iter( child_rsc, resource_t, rsc->children, lpc, native_rsc_order_lh(child_rsc, order, data_set); ); } else { /* stop everything */ crm_debug_2("Clone-to-* ordering: %s -> %s 0x%.6x", order->lh_action_task, order->rh_action_task, order->type); slist_iter( child_rsc, resource_t, rsc->children, lpc, native_rsc_order_lh(child_rsc, order, data_set); ); } } } if(do_interleave == FALSE || clone_data->ordered) { order->lh_action_task = convert_non_atomic_task(order->lh_action_task, FALSE, TRUE); native_rsc_order_lh(rsc, order, data_set); } if(is_set(rsc->flags, pe_rsc_notify)) { order->type = pe_order_optional; order->lh_action_task = convert_non_atomic_task(order->lh_action_task, TRUE, TRUE); native_rsc_order_lh(rsc, order, data_set); } } void clone_rsc_order_rh( action_t *lh_action, resource_t *rsc, order_constraint_t *order) { enum pe_ordering type = order->type; clone_variant_data_t *clone_data = NULL; get_clone_variant_data(clone_data, rsc); if(safe_str_eq(CRM_OP_PROBED, lh_action->uuid)) { slist_iter( child_rsc, resource_t, rsc->children, lpc, child_rsc->cmds->rsc_order_rh(lh_action, child_rsc, order); ); if(rsc->fns->state(rsc, TRUE) < RSC_ROLE_STARTED && rsc->fns->state(rsc, FALSE) > RSC_ROLE_STOPPED) { order->type |= pe_order_implies_right; } } native_rsc_order_rh(lh_action, rsc, order); order->type = type; } void clone_rsc_location(resource_t *rsc, rsc_to_node_t *constraint) { clone_variant_data_t *clone_data = NULL; get_clone_variant_data(clone_data, rsc); crm_debug_3("Processing location constraint %s for %s", constraint->id, rsc->id); native_rsc_location(rsc, constraint); slist_iter( child_rsc, resource_t, rsc->children, lpc, child_rsc->cmds->rsc_location(child_rsc, constraint); ); } void clone_expand(resource_t *rsc, pe_working_set_t *data_set) { clone_variant_data_t *clone_data = NULL; get_clone_variant_data(clone_data, rsc); crm_debug_2("Processing actions from %s", rsc->id); if(clone_data->start_notify) { collect_notification_data(rsc, TRUE, TRUE, clone_data->start_notify); expand_notification_data(clone_data->start_notify); create_notifications(rsc, clone_data->start_notify, data_set); } if(clone_data->stop_notify) { collect_notification_data(rsc, TRUE, TRUE, clone_data->stop_notify); expand_notification_data(clone_data->stop_notify); create_notifications(rsc, clone_data->stop_notify, data_set); } if(clone_data->promote_notify) { collect_notification_data(rsc, TRUE, TRUE, clone_data->promote_notify); expand_notification_data(clone_data->promote_notify); create_notifications(rsc, clone_data->promote_notify, data_set); } if(clone_data->demote_notify) { collect_notification_data(rsc, TRUE, TRUE, clone_data->demote_notify); expand_notification_data(clone_data->demote_notify); create_notifications(rsc, clone_data->demote_notify, data_set); } /* Now that the notifcations have been created we can expand the children */ slist_iter( child_rsc, resource_t, rsc->children, lpc, child_rsc->cmds->expand(child_rsc, data_set)); native_expand(rsc, data_set); /* The notifications are in the graph now, we can destroy the notify_data */ free_notification_data(clone_data->demote_notify); free_notification_data(clone_data->stop_notify); free_notification_data(clone_data->start_notify); free_notification_data(clone_data->promote_notify); } static gint sort_rsc_id(gconstpointer a, gconstpointer b) { const resource_t *resource1 = (const resource_t*)a; const resource_t *resource2 = (const resource_t*)b; CRM_ASSERT(resource1 != NULL); CRM_ASSERT(resource2 != NULL); return strcmp(resource1->id, resource2->id); } static resource_t *find_instance_on(resource_t *rsc, node_t *node) { slist_iter(child, resource_t, rsc->children, lpc, GListPtr known_list = NULL; rsc_known_on(child, &known_list); slist_iter(known, node_t, known_list, lpc2, if(node->details == known->details) { g_list_free(known_list); return child; } ); g_list_free(known_list); ); return NULL; } gboolean clone_create_probe(resource_t *rsc, node_t *node, action_t *complete, gboolean force, pe_working_set_t *data_set) { gboolean any_created = FALSE; clone_variant_data_t *clone_data = NULL; get_clone_variant_data(clone_data, rsc); rsc->children = g_list_sort(rsc->children, sort_rsc_id); if(rsc->children == NULL) { pe_warn("Clone %s has no children", rsc->id); return FALSE; } if(is_not_set(rsc->flags, pe_rsc_unique) && clone_data->clone_node_max == 1) { /* only look for one copy */ resource_t *child = NULL; /* Try whoever we probed last time */ child = find_instance_on(rsc, node); if(child) { return child->cmds->create_probe( child, node, complete, force, data_set); } /* Try whoever we plan on starting there */ slist_iter( child_rsc, resource_t, rsc->children, lpc, node_t *local_node = child_rsc->fns->location(child_rsc, NULL, FALSE); if(local_node == NULL) { continue; } if(local_node->details == node->details) { return child_rsc->cmds->create_probe( child_rsc, node, complete, force, data_set); } ); /* Fall back to the first clone instance */ child = rsc->children->data; return child->cmds->create_probe(child, node, complete, force, data_set); } slist_iter( child_rsc, resource_t, rsc->children, lpc, if(child_rsc->cmds->create_probe( child_rsc, node, complete, force, data_set)) { any_created = TRUE; } if(any_created && is_not_set(rsc->flags, pe_rsc_unique) && clone_data->clone_node_max == 1) { /* only look for one copy (clone :0) */ break; } ); return any_created; } diff --git a/pengine/group.c b/pengine/group.c index 393b0154f0..9f60e81a5e 100644 --- a/pengine/group.c +++ b/pengine/group.c @@ -1,518 +1,519 @@ /* * Copyright (C) 2004 Andrew Beekhof * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #define VARIANT_GROUP 1 #include node_t * group_color(resource_t *rsc, pe_working_set_t *data_set) { node_t *node = NULL; node_t *group_node = NULL; group_variant_data_t *group_data = NULL; get_group_variant_data(group_data, rsc); if(is_not_set(rsc->flags, pe_rsc_provisional)) { return rsc->allocated_to; } crm_debug_2("Processing %s", rsc->id); if(is_set(rsc->flags, pe_rsc_allocating)) { crm_debug("Dependancy loop detected involving %s", rsc->id); return NULL; } if(group_data->first_child == NULL) { /* nothign to allocate */ clear_bit(rsc->flags, pe_rsc_provisional); return NULL; } set_bit(rsc->flags, pe_rsc_allocating); rsc->role = group_data->first_child->role; group_data->first_child->rsc_cons = g_list_concat( group_data->first_child->rsc_cons, rsc->rsc_cons); rsc->rsc_cons = NULL; group_data->first_child->rsc_cons_lhs = g_list_concat( group_data->first_child->rsc_cons_lhs, rsc->rsc_cons_lhs); rsc->rsc_cons_lhs = NULL; dump_node_scores(show_scores?0:scores_log_level, rsc, __PRETTY_FUNCTION__, rsc->allowed_nodes); slist_iter( child_rsc, resource_t, rsc->children, lpc, node = child_rsc->cmds->color(child_rsc, data_set); if(group_node == NULL) { group_node = node; } ); rsc->next_role = group_data->first_child->next_role; clear_bit(rsc->flags, pe_rsc_allocating); clear_bit(rsc->flags, pe_rsc_provisional); if(group_data->colocated) { return group_node; } return NULL; } void group_update_pseudo_status(resource_t *parent, resource_t *child); void group_create_actions(resource_t *rsc, pe_working_set_t *data_set) { action_t *op = NULL; const char *value = NULL; group_variant_data_t *group_data = NULL; get_group_variant_data(group_data, rsc); crm_debug_2("Creating actions for %s", rsc->id); slist_iter( child_rsc, resource_t, rsc->children, lpc, child_rsc->cmds->create_actions(child_rsc, data_set); group_update_pseudo_status(rsc, child_rsc); ); op = start_action(rsc, NULL, TRUE/* !group_data->child_starting */); op->pseudo = TRUE; op->runnable = TRUE; op = custom_action(rsc, started_key(rsc), RSC_STARTED, NULL, TRUE/* !group_data->child_starting */, TRUE, data_set); op->pseudo = TRUE; op->runnable = TRUE; op = stop_action(rsc, NULL, TRUE/* !group_data->child_stopping */); op->pseudo = TRUE; op->runnable = TRUE; op = custom_action(rsc, stopped_key(rsc), RSC_STOPPED, NULL, TRUE/* !group_data->child_stopping */, TRUE, data_set); op->pseudo = TRUE; op->runnable = TRUE; value = g_hash_table_lookup(rsc->meta, "stateful"); if(crm_is_true(value)) { op = custom_action(rsc, demote_key(rsc), RSC_DEMOTE, NULL, TRUE, TRUE, data_set); op->pseudo = TRUE; op->runnable = TRUE; op = custom_action(rsc, demoted_key(rsc), RSC_DEMOTED, NULL, TRUE, TRUE, data_set); op->pseudo = TRUE; op->runnable = TRUE; op = custom_action(rsc, promote_key(rsc), RSC_PROMOTE, NULL, TRUE, TRUE, data_set); op->pseudo = TRUE; op->runnable = TRUE; op = custom_action(rsc, promoted_key(rsc), RSC_PROMOTED, NULL, TRUE, TRUE, data_set); op->pseudo = TRUE; op->runnable = TRUE; } rsc->actions = rsc->actions; /* rsc->actions = NULL; */ } void group_update_pseudo_status(resource_t *parent, resource_t *child) { group_variant_data_t *group_data = NULL; get_group_variant_data(group_data, parent); if(group_data->ordered == FALSE) { /* If this group is not ordered, then leave the meta-actions as optional */ return; } if(group_data->child_stopping && group_data->child_starting) { return; } slist_iter( action, action_t, child->actions, lpc, if(action->optional) { continue; } if(safe_str_eq(RSC_STOP, action->task) && action->runnable) { group_data->child_stopping = TRUE; crm_debug_3("Based on %s the group is stopping", action->uuid); } else if(safe_str_eq(RSC_START, action->task) && action->runnable) { group_data->child_starting = TRUE; crm_debug_3("Based on %s the group is starting", action->uuid); } ); } void group_internal_constraints(resource_t *rsc, pe_working_set_t *data_set) { const char *value = NULL; gboolean stateful = FALSE; resource_t *last_rsc = NULL; group_variant_data_t *group_data = NULL; get_group_variant_data(group_data, rsc); native_internal_constraints(rsc, data_set); value = g_hash_table_lookup(rsc->meta, "stateful"); stateful = crm_is_true(value); new_rsc_order(rsc, RSC_STOPPED, rsc, RSC_START, pe_order_optional, data_set); new_rsc_order(rsc, RSC_STOP, rsc, RSC_STOPPED, pe_order_runnable_left|pe_order_implies_right|pe_order_implies_left, data_set); new_rsc_order(rsc, RSC_START, rsc, RSC_STARTED, pe_order_runnable_left, data_set); slist_iter( child_rsc, resource_t, rsc->children, lpc, int stop = pe_order_shutdown|pe_order_implies_right; int stopped = pe_order_implies_right_printed; int start = pe_order_implies_right|pe_order_runnable_left; int started = pe_order_runnable_left|pe_order_implies_right|pe_order_implies_right_printed; child_rsc->cmds->internal_constraints(child_rsc, data_set); if(last_rsc == NULL) { if(group_data->ordered) { stop |= pe_order_implies_left; stopped = pe_order_implies_right; } } else if(group_data->colocated) { rsc_colocation_new( "group:internal_colocation", NULL, INFINITY, child_rsc, last_rsc, NULL, NULL, data_set); } if(stateful) { new_rsc_order(rsc, RSC_DEMOTE, child_rsc, RSC_DEMOTE, stop|pe_order_implies_left_printed, data_set); new_rsc_order(child_rsc, RSC_DEMOTE, rsc, RSC_DEMOTED, stopped, data_set); new_rsc_order(child_rsc, RSC_PROMOTE, rsc, RSC_PROMOTED, started, data_set); new_rsc_order(rsc, RSC_PROMOTE, child_rsc, RSC_PROMOTE, pe_order_implies_left_printed, data_set); } order_start_start(rsc, child_rsc, pe_order_implies_left_printed); order_stop_stop(rsc, child_rsc, stop|pe_order_implies_left_printed); new_rsc_order(child_rsc, RSC_STOP, rsc, RSC_STOPPED, stopped, data_set); new_rsc_order(child_rsc, RSC_START, rsc, RSC_STARTED, started, data_set); if(group_data->ordered == FALSE) { order_start_start(rsc, child_rsc, start|pe_order_implies_left_printed); if(stateful) { new_rsc_order(rsc, RSC_PROMOTE, child_rsc, RSC_PROMOTE, start|pe_order_implies_left_printed, data_set); } } else if(last_rsc != NULL) { child_rsc->restart_type = pe_restart_restart; order_start_start(last_rsc, child_rsc, start); order_stop_stop(child_rsc, last_rsc, pe_order_implies_left); if(stateful) { new_rsc_order(last_rsc, RSC_PROMOTE, child_rsc, RSC_PROMOTE, start, data_set); new_rsc_order(child_rsc, RSC_DEMOTE, last_rsc, RSC_DEMOTE, pe_order_implies_left, data_set); } } else { /* If anyone in the group is starting, then * pe_order_implies_right will cause _everyone_ in the group * to be sent a start action * But this is safe since starting something that is already * started is required to be "safe" */ int flags = pe_order_implies_left|pe_order_implies_right|pe_order_runnable_right|pe_order_runnable_left; order_start_start(rsc, child_rsc, flags); if(stateful) { new_rsc_order(rsc, RSC_PROMOTE, child_rsc, RSC_PROMOTE, flags, data_set); } } last_rsc = child_rsc; ); if(group_data->ordered && last_rsc != NULL) { int stop_stop_flags = pe_order_implies_right; int stop_stopped_flags = pe_order_implies_left; order_stop_stop(rsc, last_rsc, stop_stop_flags); new_rsc_order(last_rsc, RSC_STOP, rsc, RSC_STOPPED, stop_stopped_flags, data_set); if(stateful) { new_rsc_order(rsc, RSC_DEMOTE, last_rsc, RSC_DEMOTE, stop_stop_flags, data_set); new_rsc_order(last_rsc, RSC_DEMOTE, rsc, RSC_DEMOTED, stop_stopped_flags, data_set); } } } void group_rsc_colocation_lh( resource_t *rsc_lh, resource_t *rsc_rh, rsc_colocation_t *constraint) { group_variant_data_t *group_data = NULL; if(rsc_lh == NULL) { pe_err("rsc_lh was NULL for %s", constraint->id); return; } else if(rsc_rh == NULL) { pe_err("rsc_rh was NULL for %s", constraint->id); return; } crm_debug_4("Processing constraints from %s", rsc_lh->id); get_group_variant_data(group_data, rsc_lh); if(group_data->colocated) { group_data->first_child->cmds->rsc_colocation_lh( group_data->first_child, rsc_rh, constraint); return; } else if(constraint->score >= INFINITY) { crm_config_err("%s: Cannot perform manditory colocation" " between non-colocated group and %s", rsc_lh->id, rsc_rh->id); return; } slist_iter( child_rsc, resource_t, rsc_lh->children, lpc, child_rsc->cmds->rsc_colocation_lh( child_rsc, rsc_rh, constraint); ); } void group_rsc_colocation_rh( resource_t *rsc_lh, resource_t *rsc_rh, rsc_colocation_t *constraint) { group_variant_data_t *group_data = NULL; get_group_variant_data(group_data, rsc_rh); CRM_CHECK(rsc_lh->variant == pe_native, return); crm_debug_3("Processing RH of constraint %s", constraint->id); print_resource(LOG_DEBUG_3, "LHS", rsc_lh, TRUE); if(is_set(rsc_rh->flags, pe_rsc_provisional)) { return; } else if(group_data->colocated && group_data->first_child) { group_data->first_child->cmds->rsc_colocation_rh( rsc_lh, group_data->first_child, constraint); return; } else if(constraint->score >= INFINITY) { crm_config_err("%s: Cannot perform manditory colocation with" " non-colocated group: %s", rsc_lh->id, rsc_rh->id); return; } slist_iter( child_rsc, resource_t, rsc_rh->children, lpc, child_rsc->cmds->rsc_colocation_rh( rsc_lh, child_rsc, constraint); ); } void group_rsc_order_lh(resource_t *rsc, order_constraint_t *order, pe_working_set_t *data_set) { group_variant_data_t *group_data = NULL; get_group_variant_data(group_data, rsc); crm_debug_4("%s->%s", order->lh_action_task, order->rh_action_task); if(order->rh_rsc != NULL && (rsc == order->rh_rsc || rsc == order->rh_rsc->parent)) { native_rsc_order_lh(rsc, order, data_set); return; } #if 0 if(order->type != pe_order_optional) { native_rsc_order_lh(rsc, order, data_set); } if(order->type & pe_order_implies_left) { native_rsc_order_lh(group_data->first_child, order, data_set); } #endif order->lh_action_task = convert_non_atomic_task( order->lh_action_task, is_set(rsc->flags, pe_rsc_notify), TRUE); native_rsc_order_lh(rsc, order, data_set); } void group_rsc_order_rh( action_t *lh_action, resource_t *rsc, order_constraint_t *order) { enum pe_ordering type = order->type; group_variant_data_t *group_data = NULL; get_group_variant_data(group_data, rsc); crm_debug_3("%s/%p: %s->%s", rsc->id, order, lh_action->uuid, order->rh_action_task); if(rsc == NULL) { return; } if(safe_str_eq(CRM_OP_PROBED, lh_action->uuid)) { slist_iter( child_rsc, resource_t, rsc->children, lpc, child_rsc->cmds->rsc_order_rh(lh_action, child_rsc, order); ); if(rsc->fns->state(rsc, TRUE) < RSC_ROLE_STARTED && rsc->fns->state(rsc, FALSE) > RSC_ROLE_STOPPED) { order->type |= pe_order_implies_right; } } else if(lh_action->rsc != NULL && lh_action->rsc != rsc && lh_action->rsc != rsc->parent && lh_action->rsc->parent != rsc) { char *tmp = NULL; char *task_s = NULL; int interval = 0; enum action_tasks task = 0; parse_op_key(order->lh_action_task, &tmp, &task_s, &interval); task = text2task(task_s); crm_free(task_s); crm_free(tmp); switch(task) { case no_action: case monitor_rsc: case action_notify: case action_notified: case shutdown_crm: case stonith_node: break; case stop_rsc: case stopped_rsc: case action_demote: case action_demoted: order->type |= pe_order_complex_left; break; case start_rsc: case started_rsc: case action_promote: case action_promoted: order->type |= pe_order_complex_right; break; } } native_rsc_order_rh(lh_action, rsc, order); order->type = type; } void group_rsc_location(resource_t *rsc, rsc_to_node_t *constraint) { GListPtr saved = constraint->node_list_rh; GListPtr zero = node_list_dup(constraint->node_list_rh, TRUE, FALSE); gboolean reset_scores = TRUE; group_variant_data_t *group_data = NULL; get_group_variant_data(group_data, rsc); crm_debug("Processing rsc_location %s for %s", constraint->id, rsc->id); + native_rsc_location(rsc, constraint); slist_iter( child_rsc, resource_t, rsc->children, lpc, child_rsc->cmds->rsc_location(child_rsc, constraint); if(group_data->colocated && reset_scores) { reset_scores = FALSE; constraint->node_list_rh = zero; } ); constraint->node_list_rh = saved; pe_free_shallow_adv(zero, TRUE); } void group_expand(resource_t *rsc, pe_working_set_t *data_set) { group_variant_data_t *group_data = NULL; get_group_variant_data(group_data, rsc); crm_debug_3("Processing actions from %s", rsc->id); CRM_CHECK(rsc != NULL, return); native_expand(rsc, data_set); slist_iter( child_rsc, resource_t, rsc->children, lpc, child_rsc->cmds->expand(child_rsc, data_set); ); } GListPtr group_merge_weights( resource_t *rsc, const char *rhs, GListPtr nodes, const char *attr, int factor, gboolean allow_rollback) { group_variant_data_t *group_data = NULL; get_group_variant_data(group_data, rsc); if(is_set(rsc->flags, pe_rsc_merging)) { crm_info("Breaking dependancy loop with %s at %s", rsc->id, rhs); return nodes; } set_bit(rsc->flags, pe_rsc_merging); nodes = group_data->first_child->cmds->merge_weights( group_data->first_child, rhs, nodes, attr, factor, allow_rollback); slist_iter( constraint, rsc_colocation_t, rsc->rsc_cons_lhs, lpc, nodes = native_merge_weights( constraint->rsc_lh, rsc->id, nodes, constraint->node_attribute, constraint->score/INFINITY, allow_rollback); ); clear_bit(rsc->flags, pe_rsc_merging); return nodes; } diff --git a/pengine/native.c b/pengine/native.c index f6e9a6e6f3..f66b7a7d82 100644 --- a/pengine/native.c +++ b/pengine/native.c @@ -1,2118 +1,2152 @@ /* * Copyright (C) 2004 Andrew Beekhof * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #define DELETE_THEN_REFRESH 1 /* The crmd will remove the resource from the CIB itself, making this redundant */ #define VARIANT_NATIVE 1 #include void native_rsc_colocation_rh_must(resource_t *rsc_lh, gboolean update_lh, resource_t *rsc_rh, gboolean update_rh); void native_rsc_colocation_rh_mustnot(resource_t *rsc_lh, gboolean update_lh, resource_t *rsc_rh, gboolean update_rh); void Recurring(resource_t *rsc, action_t *start, node_t *node, pe_working_set_t *data_set); void RecurringOp(resource_t *rsc, action_t *start, node_t *node, xmlNode *operation, pe_working_set_t *data_set); void pe_post_notify( resource_t *rsc, node_t *node, action_t *op, notify_data_t *n_data, pe_working_set_t *data_set); void NoRoleChange (resource_t *rsc, node_t *current, node_t *next, pe_working_set_t *data_set); gboolean DeleteRsc (resource_t *rsc, node_t *node, gboolean optional, pe_working_set_t *data_set); gboolean StopRsc (resource_t *rsc, node_t *next, gboolean optional, pe_working_set_t *data_set); gboolean StartRsc (resource_t *rsc, node_t *next, gboolean optional, pe_working_set_t *data_set); gboolean DemoteRsc (resource_t *rsc, node_t *next, gboolean optional, pe_working_set_t *data_set); gboolean PromoteRsc(resource_t *rsc, node_t *next, gboolean optional, pe_working_set_t *data_set); gboolean RoleError (resource_t *rsc, node_t *next, gboolean optional, pe_working_set_t *data_set); gboolean NullOp (resource_t *rsc, node_t *next, gboolean optional, pe_working_set_t *data_set); enum rsc_role_e rsc_state_matrix[RSC_ROLE_MAX][RSC_ROLE_MAX] = { /* Current State */ /* Next State: Unknown Stopped Started Slave Master */ /* Unknown */ { RSC_ROLE_UNKNOWN, RSC_ROLE_STOPPED, RSC_ROLE_STOPPED, RSC_ROLE_STOPPED, RSC_ROLE_STOPPED, }, /* Stopped */ { RSC_ROLE_STOPPED, RSC_ROLE_STOPPED, RSC_ROLE_STARTED, RSC_ROLE_SLAVE, RSC_ROLE_SLAVE, }, /* Started */ { RSC_ROLE_STOPPED, RSC_ROLE_STOPPED, RSC_ROLE_STARTED, RSC_ROLE_SLAVE, RSC_ROLE_MASTER, }, /* Slave */ { RSC_ROLE_STOPPED, RSC_ROLE_STOPPED, RSC_ROLE_UNKNOWN, RSC_ROLE_SLAVE, RSC_ROLE_MASTER, }, /* Master */ { RSC_ROLE_STOPPED, RSC_ROLE_SLAVE, RSC_ROLE_UNKNOWN, RSC_ROLE_SLAVE, RSC_ROLE_MASTER, }, }; gboolean (*rsc_action_matrix[RSC_ROLE_MAX][RSC_ROLE_MAX])(resource_t*,node_t*,gboolean,pe_working_set_t*) = { /* Current State */ /* Next State: Unknown Stopped Started Slave Master */ /* Unknown */ { RoleError, StopRsc, RoleError, RoleError, RoleError, }, /* Stopped */ { RoleError, NullOp, StartRsc, StartRsc, RoleError, }, /* Started */ { RoleError, StopRsc, NullOp, NullOp, PromoteRsc, }, /* Slave */ { RoleError, StopRsc, RoleError, NullOp, PromoteRsc, }, /* Master */ { RoleError, RoleError, RoleError, DemoteRsc, NullOp, }, }; static gboolean native_choose_node(resource_t *rsc) { /* 1. Sort by weight 2. color.chosen_node = the node (of those with the highest wieght) with the fewest resources 3. remove color.chosen_node from all other colors */ GListPtr nodes = NULL; node_t *chosen = NULL; int lpc = 0; int multiple = 0; int length = g_list_length(rsc->allowed_nodes); if(is_not_set(rsc->flags, pe_rsc_provisional)) { return rsc->allocated_to?TRUE:FALSE; } crm_debug_3("Choosing node for %s from %d candidates", rsc->id, length); if(rsc->allowed_nodes) { rsc->allowed_nodes = g_list_sort(rsc->allowed_nodes, sort_node_weight); nodes = rsc->allowed_nodes; chosen = g_list_nth_data(nodes, 0); if(chosen && chosen->weight > 0 && can_run_resources(chosen)) { node_t *running = g_list_nth_data(rsc->running_on, 0); if(can_run_resources(running) == FALSE) { running = NULL; } for(lpc = 1; lpc < length; lpc++) { node_t *tmp = g_list_nth_data(nodes, lpc); if(tmp->weight == chosen->weight) { multiple++; if(running && tmp->details == running->details) { /* prefer the existing node if scores are equal */ chosen = tmp; } } } } } if(multiple > 1) { int log_level = LOG_INFO; char *score = score2char(chosen->weight); if(chosen->weight >= INFINITY) { log_level = LOG_WARNING; } do_crm_log(log_level, "%d nodes with equal score (%s) for" " running %s resources. Chose %s.", multiple, score, rsc->id, chosen->details->uname); crm_free(score); } return native_assign_node(rsc, nodes, chosen, FALSE); } int node_list_attr_score(GListPtr list, const char *attr, const char *value) { int best_score = -INFINITY; const char *best_node = NULL; if(attr == NULL) { attr = "#"XML_ATTR_UNAME; } slist_iter(node, node_t, list, lpc, int weight = node->weight; if(can_run_resources(node) == FALSE) { weight = -INFINITY; } if(weight > best_score || best_node == NULL) { const char *tmp = g_hash_table_lookup(node->details->attrs, attr); if(safe_str_eq(value, tmp)) { best_score = weight; best_node = node->details->uname; } } ); if(safe_str_neq(attr, "#"XML_ATTR_UNAME)) { crm_info("Best score for %s=%s was %s with %d", attr, value, best_node?best_node:"", best_score); } return best_score; } static void node_list_update(GListPtr list1, GListPtr list2, const char *attr, int factor) { int score = 0; if(attr == NULL) { attr = "#"XML_ATTR_UNAME; } slist_iter( node, node_t, list1, lpc, CRM_CHECK(node != NULL, continue); score = node_list_attr_score(list2, attr, g_hash_table_lookup(node->details->attrs, attr)); if(factor < 0 && score < 0) { /* Negative preference for a node with a negative score * should not become a positive preference * * TODO: Decide if we want to filter only if weight == -INFINITY * */ continue; } crm_debug_2("%s: %d + %d*%d", node->details->uname, node->weight, factor, score); node->weight = merge_weights(factor*score, node->weight); ); } GListPtr native_merge_weights( resource_t *rsc, const char *rhs, GListPtr nodes, const char *attr, int factor, gboolean allow_rollback) { GListPtr archive = NULL; if(is_set(rsc->flags, pe_rsc_merging)) { crm_info("%s: Breaking dependancy loop at %s", rhs, rsc->id); return nodes; } set_bit(rsc->flags, pe_rsc_merging); crm_debug_2("%s: Combining scores from %s", rhs, rsc->id); if(allow_rollback) { archive = node_list_dup(nodes, FALSE, FALSE); } node_list_update(nodes, rsc->allowed_nodes, attr, factor); if(can_run_any(nodes) == FALSE) { if(archive) { crm_info("%s: Rolling back scores from %s", rhs, rsc->id); pe_free_shallow_adv(nodes, TRUE); nodes = archive; } goto bail; } pe_free_shallow_adv(archive, TRUE); slist_iter( constraint, rsc_colocation_t, rsc->rsc_cons_lhs, lpc, nodes = constraint->rsc_lh->cmds->merge_weights( constraint->rsc_lh, rhs, nodes, constraint->node_attribute, constraint->score/INFINITY, allow_rollback); ); bail: clear_bit(rsc->flags, pe_rsc_merging); return nodes; } node_t * native_color(resource_t *rsc, pe_working_set_t *data_set) { int alloc_details = scores_log_level+1; if(rsc->parent && is_not_set(rsc->parent->flags, pe_rsc_allocating)) { /* never allocate children on their own */ crm_debug("Escalating allocation of %s to its parent: %s", rsc->id, rsc->parent->id); rsc->parent->cmds->color(rsc->parent, data_set); } if(is_not_set(rsc->flags, pe_rsc_provisional)) { return rsc->allocated_to; } if(is_set(rsc->flags, pe_rsc_allocating)) { crm_debug("Dependancy loop detected involving %s", rsc->id); return NULL; } set_bit(rsc->flags, pe_rsc_allocating); print_resource(alloc_details, "Allocating: ", rsc, FALSE); dump_node_scores(alloc_details, rsc, "Pre-allloc", rsc->allowed_nodes); slist_iter( constraint, rsc_colocation_t, rsc->rsc_cons, lpc, resource_t *rsc_rh = constraint->rsc_rh; crm_debug_2("%s: Pre-Processing %s (%s)", rsc->id, constraint->id, rsc_rh->id); rsc_rh->cmds->color(rsc_rh, data_set); rsc->cmds->rsc_colocation_lh(rsc, rsc_rh, constraint); ); dump_node_scores(alloc_details, rsc, "Post-coloc", rsc->allowed_nodes); slist_iter( constraint, rsc_colocation_t, rsc->rsc_cons_lhs, lpc, rsc->allowed_nodes = constraint->rsc_lh->cmds->merge_weights( constraint->rsc_lh, rsc->id, rsc->allowed_nodes, constraint->node_attribute, constraint->score/INFINITY, TRUE); ); print_resource(LOG_DEBUG_2, "Allocating: ", rsc, FALSE); if(rsc->next_role == RSC_ROLE_STOPPED) { crm_debug_2("Making sure %s doesn't get allocated", rsc->id); /* make sure it doesnt come up again */ resource_location( rsc, NULL, -INFINITY, XML_RSC_ATTR_TARGET_ROLE, data_set); } dump_node_scores(show_scores?0:scores_log_level, rsc, __PRETTY_FUNCTION__, rsc->allowed_nodes); if(is_set(data_set->flags, pe_flag_stonith_enabled) && is_set(data_set->flags, pe_flag_have_stonith_resource) == FALSE) { clear_bit(rsc->flags, pe_rsc_managed); } if(is_not_set(rsc->flags, pe_rsc_managed)) { const char *reason = NULL; node_t *assign_to = NULL; if(rsc->running_on == NULL) { reason = "inactive"; } else if(rsc->role == RSC_ROLE_MASTER) { assign_to = rsc->running_on->data; reason = "master"; } else if(is_set(rsc->flags, pe_rsc_failed)) { reason = "failed"; } else { assign_to = rsc->running_on->data; reason = "active"; } crm_info("Unmanaged resource %s allocated to %s: %s", rsc->id, assign_to?assign_to->details->uname:"'nowhere'", reason); native_assign_node(rsc, NULL, assign_to, TRUE); } else if(is_set(data_set->flags, pe_flag_stop_everything)) { crm_debug("Forcing %s to stop", rsc->id); native_assign_node(rsc, NULL, NULL, TRUE); } else if(is_set(rsc->flags, pe_rsc_provisional) && native_choose_node(rsc) ) { crm_debug_3("Allocated resource %s to %s", rsc->id, rsc->allocated_to->details->uname); } else if(rsc->allocated_to == NULL) { if(is_not_set(rsc->flags, pe_rsc_orphan)) { pe_warn("Resource %s cannot run anywhere", rsc->id); } else if(rsc->running_on != NULL) { crm_info("Stopping orphan resource %s", rsc->id); } } else { crm_debug("Pre-Allocated resource %s to %s", rsc->id, rsc->allocated_to->details->uname); } clear_bit(rsc->flags, pe_rsc_allocating); print_resource(LOG_DEBUG_3, "Allocated ", rsc, TRUE); return rsc->allocated_to; } static gboolean is_op_dup( resource_t *rsc, const char *name, const char *interval) { gboolean dup = FALSE; const char *id = NULL; const char *value = NULL; xml_child_iter_filter( rsc->ops_xml, operation, "op", value = crm_element_value(operation, "name"); if(safe_str_neq(value, name)) { continue; } value = crm_element_value(operation, XML_LRM_ATTR_INTERVAL); if(value == NULL) { value = "0"; } if(safe_str_neq(value, interval)) { continue; } if(id == NULL) { id = ID(operation); } else { crm_config_err("Operation %s is a duplicate of %s", ID(operation), id); crm_config_err("Do not use the same (name, interval) combination more than once per resource"); dup = TRUE; } ); return dup; } void RecurringOp(resource_t *rsc, action_t *start, node_t *node, xmlNode *operation, pe_working_set_t *data_set) { char *key = NULL; const char *name = NULL; const char *value = NULL; const char *interval = NULL; const char *node_uname = NULL; unsigned long long interval_ms = 0; action_t *mon = NULL; gboolean is_optional = TRUE; GListPtr possible_matches = NULL; crm_debug_2("Creating recurring action %s for %s in role %s", ID(operation), rsc->id, role2text(rsc->next_role)); if(node != NULL) { node_uname = node->details->uname; } interval = crm_element_value(operation, XML_LRM_ATTR_INTERVAL); interval_ms = crm_get_interval(interval); if(interval_ms == 0) { return; } name = crm_element_value(operation, "name"); if(is_op_dup(rsc, name, interval)) { return; } key = generate_op_key(rsc->id, name, interval_ms); if(find_rsc_op_entry(rsc, key) == NULL) { /* disabled */ return; } if(start != NULL) { crm_debug_3("Marking %s %s due to %s", key, start->optional?"optional":"manditory", start->uuid); is_optional = start->optional; } else { crm_debug_2("Marking %s optional", key); is_optional = TRUE; } /* start a monitor for an already active resource */ possible_matches = find_actions_exact(rsc->actions, key, node); if(possible_matches == NULL) { is_optional = FALSE; crm_debug_3("Marking %s manditory: not active", key); } else { g_list_free(possible_matches); } value = crm_element_value(operation, "role"); if((rsc->next_role == RSC_ROLE_MASTER && value == NULL) || (value != NULL && text2role(value) != rsc->next_role)) { int log_level = LOG_DEBUG_2; const char *result = "Ignoring"; if(is_optional) { char *local_key = crm_strdup(key); log_level = LOG_INFO; result = "Cancelling"; /* its running : cancel it */ mon = custom_action( rsc, local_key, RSC_CANCEL, node, FALSE, TRUE, data_set); crm_free(mon->task); mon->task = crm_strdup(RSC_CANCEL); add_hash_param(mon->meta, XML_LRM_ATTR_INTERVAL, interval); add_hash_param(mon->meta, XML_LRM_ATTR_TASK, name); local_key = NULL; switch(rsc->role) { case RSC_ROLE_SLAVE: case RSC_ROLE_STARTED: if(rsc->next_role == RSC_ROLE_MASTER) { local_key = promote_key(rsc); } else if(rsc->next_role == RSC_ROLE_STOPPED) { local_key = stop_key(rsc); } break; case RSC_ROLE_MASTER: local_key = demote_key(rsc); break; default: break; } if(local_key) { custom_action_order(rsc, NULL, mon, rsc, local_key, NULL, pe_order_runnable_left, data_set); } mon = NULL; } do_crm_log(log_level, "%s action %s (%s vs. %s)", result , key, value?value:role2text(RSC_ROLE_SLAVE), role2text(rsc->next_role)); crm_free(key); key = NULL; return; } mon = custom_action(rsc, key, name, node, is_optional, TRUE, data_set); key = mon->uuid; if(is_optional) { crm_debug_2("%s\t %s (optional)", crm_str(node_uname), mon->uuid); } if(start == NULL || start->runnable == FALSE) { crm_debug("%s\t %s (cancelled : start un-runnable)", crm_str(node_uname), mon->uuid); mon->runnable = FALSE; } else if(node == NULL || node->details->online == FALSE || node->details->unclean) { crm_debug("%s\t %s (cancelled : no node available)", crm_str(node_uname), mon->uuid); mon->runnable = FALSE; } else if(mon->optional == FALSE) { crm_notice(" Start recurring %s (%llus) for %s on %s", mon->task, interval_ms/1000, rsc->id, crm_str(node_uname)); } if(rsc->next_role == RSC_ROLE_MASTER) { char *running_master = crm_itoa(EXECRA_RUNNING_MASTER); add_hash_param(mon->meta, XML_ATTR_TE_TARGET_RC, running_master); crm_free(running_master); } if(node == NULL || is_set(rsc->flags, pe_rsc_managed)) { custom_action_order(rsc, start_key(rsc), NULL, NULL, crm_strdup(key), mon, pe_order_implies_right|pe_order_runnable_left, data_set); if(rsc->next_role == RSC_ROLE_MASTER) { custom_action_order( rsc, promote_key(rsc), NULL, rsc, NULL, mon, pe_order_optional|pe_order_runnable_left, data_set); } else if(rsc->role == RSC_ROLE_MASTER) { custom_action_order( rsc, demote_key(rsc), NULL, rsc, NULL, mon, pe_order_optional|pe_order_runnable_left, data_set); } } } void Recurring(resource_t *rsc, action_t *start, node_t *node, pe_working_set_t *data_set) { if(is_not_set(data_set->flags, pe_flag_maintenance_mode)) { xml_child_iter_filter( rsc->ops_xml, operation, "op", RecurringOp(rsc, start, node, operation, data_set); ); } } void native_create_actions(resource_t *rsc, pe_working_set_t *data_set) { action_t *start = NULL; node_t *chosen = NULL; enum rsc_role_e role = RSC_ROLE_UNKNOWN; enum rsc_role_e next_role = RSC_ROLE_UNKNOWN; crm_debug_2("Createing actions for %s: %s->%s", rsc->id, role2text(rsc->role), role2text(rsc->next_role)); chosen = rsc->allocated_to; if(chosen != NULL && rsc->next_role == RSC_ROLE_UNKNOWN) { rsc->next_role = RSC_ROLE_STARTED; } else if(rsc->next_role == RSC_ROLE_UNKNOWN) { rsc->next_role = RSC_ROLE_STOPPED; } get_rsc_attributes(rsc->parameters, rsc, chosen, data_set); if(g_list_length(rsc->running_on) > 1) { if(rsc->recovery_type == recovery_stop_start) { pe_proc_warn("Attempting recovery of resource %s", rsc->id); if(rsc->role == RSC_ROLE_MASTER) { DemoteRsc(rsc, NULL, FALSE, data_set); } StopRsc(rsc, NULL, FALSE, data_set); rsc->role = RSC_ROLE_STOPPED; } } else if(rsc->running_on != NULL) { node_t *current = rsc->running_on->data; NoRoleChange(rsc, current, chosen, data_set); } else if(rsc->role == RSC_ROLE_STOPPED && rsc->next_role == RSC_ROLE_STOPPED) { char *key = start_key(rsc); GListPtr possible_matches = find_actions(rsc->actions, key, NULL); slist_iter( action, action_t, possible_matches, lpc, action->optional = TRUE; /* action->pseudo = TRUE; */ ); g_list_free(possible_matches); crm_debug_2("Stopping a stopped resource"); crm_free(key); goto do_recurring; } else if(rsc->role != RSC_ROLE_STOPPED) { /* A cheap trick to account for the fact that Master/Slave groups may not be * completely running when we set their role to Slave */ crm_debug_2("Resetting %s.role = %s (was %s)", rsc->id, role2text(RSC_ROLE_STOPPED), role2text(rsc->role)); rsc->role = RSC_ROLE_STOPPED; } role = rsc->role; while(role != rsc->next_role) { next_role = rsc_state_matrix[role][rsc->next_role]; crm_debug_2("Executing: %s->%s (%s)", role2text(role), role2text(next_role), rsc->id); if(rsc_action_matrix[role][next_role]( rsc, chosen, FALSE, data_set) == FALSE) { break; } role = next_role; } do_recurring: if(rsc->next_role != RSC_ROLE_STOPPED || is_set(rsc->flags, pe_rsc_managed) == FALSE) { start = start_action(rsc, chosen, TRUE); Recurring(rsc, start, chosen, data_set); } } void native_internal_constraints(resource_t *rsc, pe_working_set_t *data_set) { int type = pe_order_optional; const char *class = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS); action_t *all_stopped = get_pseudo_op(ALL_STOPPED, data_set); if(rsc->variant == pe_native) { type |= pe_order_implies_right; } if(rsc->parent == NULL || rsc->parent->variant == pe_group) { type |= pe_order_restart; } new_rsc_order(rsc, RSC_STOP, rsc, RSC_START, type, data_set); new_rsc_order(rsc, RSC_DEMOTE, rsc, RSC_STOP, pe_order_demote_stop, data_set); new_rsc_order(rsc, RSC_START, rsc, RSC_PROMOTE, pe_order_runnable_left, data_set); new_rsc_order(rsc, RSC_DELETE, rsc, RSC_START, pe_order_optional, data_set); if(is_not_set(rsc->flags, pe_rsc_managed)) { crm_debug_3("Skipping fencing constraints for unmanaged resource: %s", rsc->id); return; } if(rsc->variant == pe_native && safe_str_neq(class, "stonith")) { custom_action_order( rsc, stop_key(rsc), NULL, NULL, crm_strdup(all_stopped->task), all_stopped, pe_order_implies_right|pe_order_runnable_left, data_set); } } void native_rsc_colocation_lh( resource_t *rsc_lh, resource_t *rsc_rh, rsc_colocation_t *constraint) { if(rsc_lh == NULL) { pe_err("rsc_lh was NULL for %s", constraint->id); return; } else if(constraint->rsc_rh == NULL) { pe_err("rsc_rh was NULL for %s", constraint->id); return; } crm_debug_2("Processing colocation constraint between %s and %s", rsc_lh->id, rsc_rh->id); rsc_rh->cmds->rsc_colocation_rh(rsc_lh, rsc_rh, constraint); } static gboolean filter_colocation_constraint( resource_t *rsc_lh, resource_t *rsc_rh, rsc_colocation_t *constraint) { int level = LOG_DEBUG_4; if(constraint->score == 0){ return FALSE; } if(constraint->score > 0 && constraint->role_lh != RSC_ROLE_UNKNOWN && constraint->role_lh != rsc_lh->next_role) { do_crm_log_unlikely(level, "LH: Skipping constraint: \"%s\" state filter", role2text(constraint->role_rh)); return FALSE; } if(constraint->score > 0 && constraint->role_rh != RSC_ROLE_UNKNOWN && constraint->role_rh != rsc_rh->next_role) { do_crm_log_unlikely(level, "RH: Skipping constraint: \"%s\" state filter", role2text(constraint->role_rh)); return FALSE; } if(constraint->score < 0 && constraint->role_lh != RSC_ROLE_UNKNOWN && constraint->role_lh == rsc_lh->next_role) { do_crm_log_unlikely(level, "LH: Skipping -ve constraint: \"%s\" state filter", role2text(constraint->role_rh)); return FALSE; } if(constraint->score < 0 && constraint->role_rh != RSC_ROLE_UNKNOWN && constraint->role_rh == rsc_rh->next_role) { do_crm_log_unlikely(level, "RH: Skipping -ve constraint: \"%s\" state filter", role2text(constraint->role_rh)); return FALSE; } return TRUE; } static void colocation_match( resource_t *rsc_lh, resource_t *rsc_rh, rsc_colocation_t *constraint) { const char *tmp = NULL; const char *value = NULL; gboolean do_check = FALSE; const char *attribute = "#id"; if(constraint->node_attribute != NULL) { attribute = constraint->node_attribute; } if(rsc_rh->allocated_to) { value = g_hash_table_lookup( rsc_rh->allocated_to->details->attrs, attribute); do_check = TRUE; } else if(constraint->score < 0) { /* nothing to do: * anti-colocation with something thats not running */ return; } slist_iter( node, node_t, rsc_lh->allowed_nodes, lpc, tmp = g_hash_table_lookup(node->details->attrs, attribute); if(do_check && safe_str_eq(tmp, value)) { if(constraint->score < INFINITY) { crm_debug_2("%s: %s.%s += %d", constraint->id, rsc_lh->id, node->details->uname, constraint->score); node->weight = merge_weights( constraint->score, node->weight); } } else if(do_check == FALSE || constraint->score >= INFINITY) { crm_debug_2("%s: %s.%s -= %d (%s)", constraint->id, rsc_lh->id, node->details->uname, constraint->score, do_check?"failed":"unallocated"); node->weight = merge_weights(-constraint->score, node->weight); } ); } void native_rsc_colocation_rh( resource_t *rsc_lh, resource_t *rsc_rh, rsc_colocation_t *constraint) { crm_debug_2("%sColocating %s with %s (%s, weight=%d)", constraint->score >= 0?"":"Anti-", rsc_lh->id, rsc_rh->id, constraint->id, constraint->score); if(filter_colocation_constraint(rsc_lh, rsc_rh, constraint) == FALSE) { return; } if(is_set(rsc_rh->flags, pe_rsc_provisional)) { return; } else if(is_not_set(rsc_lh->flags, pe_rsc_provisional)) { /* error check */ struct node_shared_s *details_lh; struct node_shared_s *details_rh; if((constraint->score > -INFINITY) && (constraint->score < INFINITY)) { return; } details_rh = rsc_rh->allocated_to?rsc_rh->allocated_to->details:NULL; details_lh = rsc_lh->allocated_to?rsc_lh->allocated_to->details:NULL; if(constraint->score == INFINITY && details_lh != details_rh) { crm_err("%s and %s are both allocated" " but to different nodes: %s vs. %s", rsc_lh->id, rsc_rh->id, details_lh?details_lh->uname:"n/a", details_rh?details_rh->uname:"n/a"); } else if(constraint->score == -INFINITY && details_lh == details_rh) { crm_err("%s and %s are both allocated" " but to the SAME node: %s", rsc_lh->id, rsc_rh->id, details_rh?details_rh->uname:"n/a"); } return; } else { colocation_match(rsc_lh, rsc_rh, constraint); } } static GListPtr find_actions_by_task(GListPtr actions, resource_t *rsc, const char *original_key) { GListPtr list = NULL; list = find_actions(actions, original_key, NULL); if(list == NULL) { /* we're potentially searching a child of the original resource */ char *key = NULL; char *tmp = NULL; char *task = NULL; int interval = 0; if(parse_op_key(original_key, &tmp, &task, &interval)) { key = generate_op_key(rsc->id, task, interval); /* crm_err("looking up %s instead of %s", key, original_key); */ /* slist_iter(action, action_t, actions, lpc, */ /* crm_err(" - %s", action->uuid)); */ list = find_actions(actions, key, NULL); } else { crm_err("search key: %s", original_key); } crm_free(key); crm_free(tmp); crm_free(task); } return list; } void native_rsc_order_lh(resource_t *lh_rsc, order_constraint_t *order, pe_working_set_t *data_set) { GListPtr lh_actions = NULL; action_t *lh_action = order->lh_action; resource_t *rh_rsc = order->rh_rsc; crm_debug_3("Processing LH of ordering constraint %d", order->id); CRM_ASSERT(lh_rsc != NULL); if(lh_action != NULL) { lh_actions = g_list_append(NULL, lh_action); } else if(lh_action == NULL) { lh_actions = find_actions_by_task( lh_rsc->actions, lh_rsc, order->lh_action_task); } if(lh_actions == NULL && lh_rsc != rh_rsc) { char *key = NULL; char *rsc_id = NULL; char *op_type = NULL; int interval = 0; crm_debug_4("No LH-Side (%s/%s) found for constraint %d with %s - creating", lh_rsc->id, order->lh_action_task, order->id, order->rh_action_task); parse_op_key( order->lh_action_task, &rsc_id, &op_type, &interval); key = generate_op_key(lh_rsc->id, op_type, interval); lh_action = custom_action(lh_rsc, key, op_type, NULL, TRUE, TRUE, data_set); if(lh_rsc->fns->state(lh_rsc, TRUE) == RSC_ROLE_STOPPED && safe_str_eq(op_type, RSC_STOP)) { lh_action->pseudo = TRUE; lh_action->runnable = TRUE; } lh_actions = g_list_append(NULL, lh_action); crm_free(op_type); crm_free(rsc_id); } slist_iter( lh_action_iter, action_t, lh_actions, lpc, if(rh_rsc == NULL && order->rh_action) { rh_rsc = order->rh_action->rsc; } if(rh_rsc) { rh_rsc->cmds->rsc_order_rh( lh_action_iter, rh_rsc, order); } else if(order->rh_action) { order_actions( lh_action_iter, order->rh_action, order->type); } ); pe_free_shallow_adv(lh_actions, FALSE); } void native_rsc_order_rh( action_t *lh_action, resource_t *rsc, order_constraint_t *order) { GListPtr rh_actions = NULL; action_t *rh_action = NULL; CRM_CHECK(rsc != NULL, return); CRM_CHECK(order != NULL, return); rh_action = order->rh_action; crm_debug_3("Processing RH of ordering constraint %d", order->id); if(rh_action != NULL) { rh_actions = g_list_append(NULL, rh_action); } else if(rsc != NULL) { rh_actions = find_actions_by_task( rsc->actions, rsc, order->rh_action_task); } if(rh_actions == NULL) { crm_debug_4("No RH-Side (%s/%s) found for constraint..." " ignoring", rsc->id,order->rh_action_task); if(lh_action) { crm_debug_4("LH-Side was: %s", lh_action->uuid); } return; } slist_iter( rh_action_iter, action_t, rh_actions, lpc, if(lh_action) { order_actions(lh_action, rh_action_iter, order->type); } else if(order->type & pe_order_implies_right) { rh_action_iter->runnable = FALSE; crm_warn("Unrunnable %s 0x%.6x", rh_action_iter->uuid, order->type); } else { crm_warn("neither %s 0x%.6x", rh_action_iter->uuid, order->type); } ); pe_free_shallow_adv(rh_actions, FALSE); } void native_rsc_location(resource_t *rsc, rsc_to_node_t *constraint) { GListPtr or_list; crm_debug_2("Applying %s (%s) to %s", constraint->id, role2text(constraint->role_filter), rsc->id); /* take "lifetime" into account */ if(constraint == NULL) { pe_err("Constraint is NULL"); return; } else if(rsc == NULL) { pe_err("LHS of rsc_to_node (%s) is NULL", constraint->id); return; } else if(constraint->role_filter > 0 && constraint->role_filter != rsc->next_role) { crm_debug("Constraint (%s) is not active (role : %s)", constraint->id, role2text(constraint->role_filter)); return; } else if(is_active(constraint) == FALSE) { crm_debug_2("Constraint (%s) is not active", constraint->id); return; } if(constraint->node_list_rh == NULL) { crm_debug_2("RHS of constraint %s is NULL", constraint->id); return; } or_list = node_list_or( rsc->allowed_nodes, constraint->node_list_rh, FALSE); pe_free_shallow(rsc->allowed_nodes); rsc->allowed_nodes = or_list; slist_iter(node, node_t, or_list, lpc, crm_debug_3("%s + %s : %d", rsc->id, node->details->uname, node->weight); ); } void native_expand(resource_t *rsc, pe_working_set_t *data_set) { crm_debug_3("Processing actions from %s", rsc->id); slist_iter( action, action_t, rsc->actions, lpc, crm_debug_4("processing action %d for rsc=%s", action->id, rsc->id); graph_element_from_action(action, data_set); ); slist_iter( child_rsc, resource_t, rsc->children, lpc, child_rsc->cmds->expand(child_rsc, data_set); ); } void LogActions(resource_t *rsc, pe_working_set_t *data_set) { node_t *next = NULL; node_t *current = NULL; gboolean moving = FALSE; if(rsc->children) { slist_iter( child_rsc, resource_t, rsc->children, lpc, LogActions(child_rsc, data_set); ); return; } next = rsc->allocated_to; if(rsc->running_on) { current = rsc->running_on->data; if(rsc->role == RSC_ROLE_STOPPED) { /* * This can occur when resources are being recovered * We fiddle with the current role in native_create_actions() */ rsc->role = RSC_ROLE_STARTED; } } if(current == NULL && is_set(rsc->flags, pe_rsc_orphan)) { /* Don't log stopped orphans */ return; } if(is_not_set(rsc->flags, pe_rsc_managed) || (current == NULL && next == NULL)) { crm_notice("Leave resource %s\t(%s%s)", rsc->id, role2text(rsc->role), is_not_set(rsc->flags, pe_rsc_managed)?" unmanaged":""); return; } if(current != NULL && next != NULL && safe_str_neq(current->details->id, next->details->id)) { moving = TRUE; } if(rsc->role == rsc->next_role) { action_t *start = NULL; char *key = start_key(rsc); GListPtr possible_matches = find_actions(rsc->actions, key, next); crm_free(key); if(possible_matches) { start = possible_matches->data; g_list_free(possible_matches); } key = generate_op_key(rsc->id, CRMD_ACTION_MIGRATED, 0); possible_matches = find_actions(rsc->actions, key, next); crm_free(key); CRM_CHECK(next != NULL,); if(next == NULL) { } else if(possible_matches) { crm_notice("Migrate resource %s\t(%s %s -> %s)", rsc->id, role2text(rsc->role), current->details->uname, next->details->uname); g_list_free(possible_matches); } else if(start == NULL || start->optional) { crm_notice("Leave resource %s\t(%s %s)", rsc->id, role2text(rsc->role), next->details->uname); } else if(moving && current) { crm_notice("Move resource %s\t(%s %s -> %s)", rsc->id, role2text(rsc->role), current->details->uname, next->details->uname); } else if(is_set(rsc->flags, pe_rsc_failed)) { crm_notice("Recover resource %s\t(%s %s)", rsc->id, role2text(rsc->role), next->details->uname); } else if(start && start->runnable == FALSE) { crm_notice("Stop resource %s\t(%s %s)", rsc->id, role2text(rsc->role), next->details->uname); } else { crm_notice("Restart resource %s\t(%s %s)", rsc->id, role2text(rsc->role), next->details->uname); } return; } if(rsc->role > RSC_ROLE_SLAVE && rsc->role > rsc->next_role) { CRM_CHECK(current != NULL,); if(current != NULL) { crm_notice("Demote %s\t(%s -> %s %s)", rsc->id, role2text(rsc->role), role2text(rsc->next_role), current->details->uname); } } if(rsc->next_role == RSC_ROLE_STOPPED || moving) { CRM_CHECK(current != NULL,); slist_iter(node, node_t, rsc->running_on, lpc, crm_notice("Stop resource %s\t(%s)", rsc->id, node->details->uname)); } if(rsc->role == RSC_ROLE_STOPPED || moving) { CRM_CHECK(next != NULL,); if(next != NULL) { crm_notice("Start %s\t(%s)", rsc->id, next->details->uname); } } if(rsc->next_role > RSC_ROLE_SLAVE && rsc->role < rsc->next_role) { CRM_CHECK(next != NULL,); crm_notice("Promote %s\t(%s -> %s %s)", rsc->id, role2text(rsc->role), role2text(rsc->next_role), next->details->uname); } } void NoRoleChange(resource_t *rsc, node_t *current, node_t *next, pe_working_set_t *data_set) { action_t *stop = NULL; action_t *start = NULL; GListPtr possible_matches = NULL; crm_debug_2("Executing: %s (role=%s)", rsc->id, role2text(rsc->next_role)); if(current == NULL || next == NULL) { return; } if(is_set(rsc->flags, pe_rsc_failed) || safe_str_neq(current->details->id, next->details->id)) { if(rsc->next_role > RSC_ROLE_STARTED) { gboolean optional = TRUE; if(rsc->role == RSC_ROLE_MASTER) { optional = FALSE; } DemoteRsc(rsc, current, optional, data_set); } if(rsc->role == RSC_ROLE_MASTER) { DemoteRsc(rsc, current, FALSE, data_set); } StopRsc(rsc, current, FALSE, data_set); StartRsc(rsc, next, FALSE, data_set); if(rsc->next_role == RSC_ROLE_MASTER) { PromoteRsc(rsc, next, FALSE, data_set); } possible_matches = find_recurring_actions(rsc->actions, next); slist_iter(match, action_t, possible_matches, lpc, if(match->optional == FALSE) { crm_debug("Fixing recurring action: %s", match->uuid); match->optional = TRUE; } ); g_list_free(possible_matches); } else if(is_set(rsc->flags, pe_rsc_start_pending)) { start = start_action(rsc, next, TRUE); if(start->runnable) { /* wait for StartRsc() to be called */ rsc->role = RSC_ROLE_STOPPED; } else { /* wait for StopRsc() to be called */ rsc->next_role = RSC_ROLE_STOPPED; } } else { stop = stop_action(rsc, current, TRUE); start = start_action(rsc, next, TRUE); stop->optional = start->optional; if(rsc->next_role > RSC_ROLE_STARTED) { DemoteRsc(rsc, current, start->optional, data_set); } StopRsc(rsc, current, start->optional, data_set); StartRsc(rsc, current, start->optional, data_set); if(rsc->next_role == RSC_ROLE_MASTER) { PromoteRsc(rsc, next, start->optional, data_set); } if(start->runnable == FALSE) { rsc->next_role = RSC_ROLE_STOPPED; } } } gboolean StopRsc(resource_t *rsc, node_t *next, gboolean optional, pe_working_set_t *data_set) { action_t *stop = NULL; const char *class = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS); crm_debug_2("Executing: %s", rsc->id); if(rsc->next_role == RSC_ROLE_STOPPED && rsc->variant == pe_native && safe_str_eq(class, "stonith")) { action_t *all_stopped = get_pseudo_op(ALL_STOPPED, data_set); custom_action_order( NULL, crm_strdup(all_stopped->task), all_stopped, rsc, stop_key(rsc), NULL, pe_order_implies_left|pe_order_stonith_stop, data_set); } slist_iter( current, node_t, rsc->running_on, lpc, stop = stop_action(rsc, current, optional); if(is_set(data_set->flags, pe_flag_remove_after_stop)) { DeleteRsc(rsc, current, optional, data_set); } ); return TRUE; } gboolean StartRsc(resource_t *rsc, node_t *next, gboolean optional, pe_working_set_t *data_set) { action_t *start = NULL; crm_debug_2("Executing: %s", rsc->id); start = start_action(rsc, next, TRUE); if(start->runnable && optional == FALSE) { start->optional = FALSE; } return TRUE; } gboolean PromoteRsc(resource_t *rsc, node_t *next, gboolean optional, pe_working_set_t *data_set) { char *key = NULL; gboolean runnable = TRUE; GListPtr action_list = NULL; crm_debug_2("Executing: %s", rsc->id); CRM_CHECK(rsc->next_role == RSC_ROLE_MASTER, crm_err("Next role: %s", role2text(rsc->next_role)); return FALSE); CRM_CHECK(next != NULL, return FALSE); key = start_key(rsc); action_list = find_actions_exact(rsc->actions, key, next); crm_free(key); slist_iter(start, action_t, action_list, lpc, if(start->runnable == FALSE) { runnable = FALSE; } ); g_list_free(action_list); if(runnable) { promote_action(rsc, next, optional); return TRUE; } crm_debug("%s\tPromote %s (canceled)", next->details->uname, rsc->id); key = promote_key(rsc); action_list = find_actions_exact(rsc->actions, key, next); crm_free(key); slist_iter(promote, action_t, action_list, lpc, promote->runnable = FALSE; ); g_list_free(action_list); return TRUE; } gboolean DemoteRsc(resource_t *rsc, node_t *next, gboolean optional, pe_working_set_t *data_set) { crm_debug_2("Executing: %s", rsc->id); /* CRM_CHECK(rsc->next_role == RSC_ROLE_SLAVE, return FALSE); */ slist_iter( current, node_t, rsc->running_on, lpc, demote_action(rsc, current, optional); ); return TRUE; } gboolean RoleError(resource_t *rsc, node_t *next, gboolean optional, pe_working_set_t *data_set) { crm_debug("Executing: %s", rsc->id); CRM_CHECK(FALSE, return FALSE); return FALSE; } gboolean NullOp(resource_t *rsc, node_t *next, gboolean optional, pe_working_set_t *data_set) { crm_debug_2("Executing: %s", rsc->id); return FALSE; } gboolean DeleteRsc(resource_t *rsc, node_t *node, gboolean optional, pe_working_set_t *data_set) { action_t *delete = NULL; #if DELETE_THEN_REFRESH action_t *refresh = NULL; #endif if(is_set(rsc->flags, pe_rsc_failed)) { crm_debug_2("Resource %s not deleted from %s: failed", rsc->id, node->details->uname); return FALSE; } else if(node == NULL) { crm_debug_2("Resource %s not deleted: NULL node", rsc->id); return FALSE; } else if(node->details->unclean || node->details->online == FALSE) { crm_debug_2("Resource %s not deleted from %s: unrunnable", rsc->id, node->details->uname); return FALSE; } crm_notice("Removing %s from %s", rsc->id, node->details->uname); delete = delete_action(rsc, node, optional); new_rsc_order(rsc, RSC_STOP, rsc, RSC_DELETE, optional?pe_order_implies_right:pe_order_implies_left, data_set); #if DELETE_THEN_REFRESH refresh = custom_action( NULL, crm_strdup(CRM_OP_LRM_REFRESH), CRM_OP_LRM_REFRESH, node, FALSE, TRUE, data_set); add_hash_param(refresh->meta, XML_ATTR_TE_NOWAIT, XML_BOOLEAN_TRUE); order_actions(delete, refresh, pe_order_optional); #endif return TRUE; } +#include <../lib/pengine/unpack.h> + gboolean native_create_probe(resource_t *rsc, node_t *node, action_t *complete, gboolean force, pe_working_set_t *data_set) { char *key = NULL; char *target_rc = NULL; action_t *probe = NULL; node_t *running = NULL; + resource_t *top = uber_parent(rsc); CRM_CHECK(node != NULL, return FALSE); if(rsc->children) { gboolean any_created = FALSE; slist_iter( child_rsc, resource_t, rsc->children, lpc, any_created = child_rsc->cmds->create_probe( child_rsc, node, complete, force, data_set) || any_created; ); return any_created; } if(is_set(rsc->flags, pe_rsc_orphan)) { crm_debug_2("Skipping orphan: %s", rsc->id); return FALSE; } running = pe_find_node_id(rsc->known_on, node->details->id); if(force == FALSE && running != NULL) { /* we already know the status of the resource on this node */ crm_debug_3("Skipping active: %s", rsc->id); return FALSE; } + if(running == NULL && is_set(top->flags, pe_rsc_unique) == FALSE) { + /* Annoyingly we also need to check any other clone instances + * Clumsy, but it will work. + * + * An alternative would be to update known_on for every peer + * during process_rsc_state() + */ + + char *clone_id = clone_zero(rsc->id); + resource_t *peer = pe_find_resource(top->children, clone_id); + + while(peer && running == NULL) { + running = pe_find_node_id(peer->known_on, node->details->id); + if(force == FALSE && running != NULL) { + /* we already know the status of the resource on this node */ + crm_debug_3("Skipping active clone: %s", rsc->id); + crm_free(clone_id); + return FALSE; + } + clone_id = increment_clone(clone_id); + peer = pe_find_resource(data_set->resources, clone_id); + } + + crm_free(clone_id); + } + key = generate_op_key(rsc->id, RSC_STATUS, 0); probe = custom_action(rsc, key, RSC_STATUS, node, FALSE, TRUE, data_set); probe->optional = FALSE; running = pe_find_node_id(rsc->running_on, node->details->id); if(running == NULL) { target_rc = crm_itoa(EXECRA_NOT_RUNNING); } else if(rsc->role == RSC_ROLE_MASTER) { target_rc = crm_itoa(EXECRA_RUNNING_MASTER); } if(target_rc != NULL) { add_hash_param(probe->meta, XML_ATTR_TE_TARGET_RC, target_rc); crm_free(target_rc); } crm_debug("Probing %s on %s (%s)", rsc->id, node->details->uname, role2text(rsc->role)); order_actions(probe, complete, pe_order_implies_right); return TRUE; } static void native_start_constraints( resource_t *rsc, action_t *stonith_op, gboolean is_stonith, pe_working_set_t *data_set) { node_t *target = stonith_op?stonith_op->node:NULL; if(is_stonith) { char *key = start_key(rsc); action_t *ready = get_pseudo_op(STONITH_UP, data_set); crm_debug_2("Ordering %s action before stonith events", key); custom_action_order( rsc, key, NULL, NULL, crm_strdup(ready->task), ready, pe_order_optional, data_set); } else { action_t *all_stopped = get_pseudo_op(ALL_STOPPED, data_set); + action_t *stonith_done = get_pseudo_op(STONITH_DONE, data_set); slist_iter(action, action_t, rsc->actions, lpc2, if(action->needs == rsc_req_stonith) { - order_actions(all_stopped, action, pe_order_implies_left); + order_actions(stonith_done, action, pe_order_implies_left); } else if(target != NULL && safe_str_eq(action->task, RSC_START) && NULL == pe_find_node_id( rsc->known_on, target->details->id)) { /* if known == NULL, then we dont know if * the resource is active on the node * we're about to shoot * * in this case, regardless of action->needs, * the only safe option is to wait until * the node is shot before doing anything * to with the resource * * its analogous to waiting for all the probes * for rscX to complete before starting rscX * * the most likely explaination is that the * DC died and took its status with it */ crm_info("Ordering %s after %s recovery", action->uuid, target->details->uname); order_actions(all_stopped, action, pe_order_implies_left|pe_order_runnable_left); } ); } } static void native_stop_constraints( resource_t *rsc, action_t *stonith_op, gboolean is_stonith, pe_working_set_t *data_set) { char *key = NULL; GListPtr action_list = NULL; + resource_t *top = uber_parent(rsc); key = stop_key(rsc); action_list = find_actions(rsc->actions, key, stonith_op->node); crm_free(key); /* add the stonith OP as a stop pre-req and the mark the stop * as a pseudo op - since its now redundant */ slist_iter( action, action_t, action_list, lpc2, resource_t *parent = NULL; if(action->node->details->online && action->node->details->unclean == FALSE && is_set(rsc->flags, pe_rsc_failed)) { continue; } if(is_set(rsc->flags, pe_rsc_failed)) { crm_warn("Stop of failed resource %s is" " implicit after %s is fenced", rsc->id, action->node->details->uname); } else { crm_info("%s is implicit after %s is fenced", action->uuid, action->node->details->uname); } /* the stop would never complete and is * now implied by the stonith operation */ action->pseudo = TRUE; action->runnable = TRUE; action->implied_by_stonith = TRUE; if(is_stonith == FALSE) { + action_t *parent_stop = find_first_action(top->actions, NULL, RSC_STOP, NULL); + order_actions(stonith_op, action, pe_order_optional); + order_actions(stonith_op, parent_stop, pe_order_optional); } if(is_set(rsc->flags, pe_rsc_notify)) { /* Create a second notification that will be delivered * immediately after the node is fenced * * Basic problem: * - C is a clone active on the node to be shot and stopping on another * - R is a resource that depends on C * * + C.stop depends on R.stop * + C.stopped depends on STONITH * + C.notify depends on C.stopped * + C.healthy depends on C.notify * + R.stop depends on C.healthy * * The extra notification here changes * + C.healthy depends on C.notify * into: * + C.healthy depends on C.notify' * + C.notify' depends on STONITH' * thus breaking the loop */ notify_data_t *n_data = create_notification_boundaries(rsc, RSC_STOP, NULL, stonith_op, data_set); crm_info("Creating secondary notification for %s", action->uuid); collect_notification_data(rsc, TRUE, FALSE, n_data); g_hash_table_insert(n_data->keys, crm_strdup("notify_stop_resource"), crm_strdup(rsc->id)); g_hash_table_insert(n_data->keys, crm_strdup("notify_stop_uname"), crm_strdup(action->node->details->uname)); create_notifications(uber_parent(rsc), n_data, data_set); free_notification_data(n_data); } /* find the top-most resource */ parent = rsc->parent; while(parent != NULL && parent->parent != NULL) { parent = parent->parent; } if(parent) { crm_debug_2("Re-creating actions for %s", parent->id); parent->cmds->create_actions(parent, data_set); /* make sure we dont mess anything up in create_actions */ CRM_CHECK(action->pseudo, action->pseudo = TRUE); CRM_CHECK(action->runnable, action->runnable = TRUE); } /* From Bug #1601, successful fencing must be an input to a failed resources stop action. However given group(rA, rB) running on nodeX and B.stop has failed, A := stop healthy resource (rA.stop) B := stop failed resource (pseudo operation B.stop) C := stonith nodeX A requires B, B requires C, C requires A This loop would prevent the cluster from making progress. This block creates the "C requires A" dependancy and therefore must (at least for now) be disabled. Instead, run the block above and treat all resources on nodeX as B would be (marked as a pseudo op depending on the STONITH). TODO: Break the "A requires B" dependancy in update_action() and re-enable this block } else if(is_stonith == FALSE) { crm_info("Moving healthy resource %s" " off %s before fencing", rsc->id, node->details->uname); * stop healthy resources before the * stonith op * custom_action_order( rsc, stop_key(rsc), NULL, NULL,crm_strdup(CRM_OP_FENCE),stonith_op, pe_order_optional, data_set); */ ); g_list_free(action_list); key = demote_key(rsc); action_list = find_actions(rsc->actions, key, stonith_op->node); crm_free(key); slist_iter( action, action_t, action_list, lpc2, if(action->node->details->online == FALSE || is_set(rsc->flags, pe_rsc_failed)) { crm_info("Demote of failed resource %s is" " implict after %s is fenced", rsc->id, action->node->details->uname); /* the stop would never complete and is * now implied by the stonith operation */ action->pseudo = TRUE; action->runnable = TRUE; if(is_stonith == FALSE) { order_actions(stonith_op, action, pe_order_optional); } } ); g_list_free(action_list); } void complex_stonith_ordering( resource_t *rsc, action_t *stonith_op, pe_working_set_t *data_set) { gboolean is_stonith = FALSE; const char *class = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS); if(rsc->children) { slist_iter( child_rsc, resource_t, rsc->children, lpc, child_rsc->cmds->stonith_ordering( child_rsc, stonith_op, data_set); ); return; } if(is_not_set(rsc->flags, pe_rsc_managed)) { crm_debug_3("Skipping fencing constraints for unmanaged resource: %s", rsc->id); return; } if(stonith_op != NULL && safe_str_eq(class, "stonith")) { is_stonith = TRUE; } /* Start constraints */ native_start_constraints(rsc, stonith_op, is_stonith, data_set); /* Stop constraints */ native_stop_constraints(rsc, stonith_op, is_stonith, data_set); } #define ALLOW_WEAK_MIGRATION 0 enum stack_activity { stack_stable = 0, stack_starting = 1, stack_stopping = 2, stack_middle = 4, }; static enum stack_activity find_clone_activity_on(resource_t *rsc, resource_t *target, node_t *node, const char *type) { int mode = stack_stable; action_t *active = NULL; if(target->children) { slist_iter( child, resource_t, target->children, lpc, mode |= find_clone_activity_on(rsc, child, node, type); ); return mode; } active = find_first_action(target->actions, NULL, CRMD_ACTION_START, NULL); if(active && active->optional == FALSE && active->pseudo == FALSE) { crm_debug("%s: found scheduled %s action (%s)", rsc->id, active->uuid, type); mode |= stack_starting; } active = find_first_action(target->actions, NULL, CRMD_ACTION_STOP, node); if(active && active->optional == FALSE && active->pseudo == FALSE) { crm_debug("%s: found scheduled %s action (%s)", rsc->id, active->uuid, type); mode |= stack_stopping; } return mode; } static enum stack_activity check_stack_element(resource_t *rsc, resource_t *other_rsc, const char *type) { if(other_rsc == NULL || other_rsc == rsc) { return stack_stable; } else if(other_rsc->variant == pe_native) { crm_notice("Cannot migrate %s due to dependancy on %s (%s)", rsc->id, other_rsc->id, type); return stack_middle; } else if(other_rsc == rsc->parent) { int mode = 0; slist_iter(constraint, rsc_colocation_t, other_rsc->rsc_cons, lpc, if(constraint->score > 0) { mode |= check_stack_element(rsc, constraint->rsc_rh, type); } ); return mode; } else if(other_rsc->variant == pe_group) { crm_notice("Cannot migrate %s due to dependancy on group %s (%s)", rsc->id, other_rsc->id, type); return stack_middle; } /* else: >= clone */ /* ## Assumption A depends on clone(B) ## Resource Activity During Move N1 N2 N3 --- --- --- t0 A.stop t1 B.stop B.stop t2 B.start B.start t3 A.start ## Resource Activity During Migration N1 N2 N3 --- --- --- t0 B.start B.start t1 A.stop (1) t2 A.start (2) t3 B.stop B.stop Node 1: Rewritten to be a migrate-to operation Node 2: Rewritten to be a migrate-from operation # Constraints The following constraints already exist in the system. The 'ok' and 'fail' column refers to whether they still hold for migration. a) A.stop -> A.start - ok b) B.stop -> B.start - fail c) A.stop -> B.stop - ok d) B.start -> A.start - ok e) B.stop -> A.start - fail f) A.stop -> B.start - fail ## Scenarios B unchanged - ok B stopping only - fail - possible after fixing 'e' B starting only - fail - possible after fixing 'f' B stoping and starting - fail - constraint 'b' is unfixable B restarting only on N2 - fail - as-per previous only rarer */ /* Only allow migration when the clone is either stable, only starting or only stopping */ return find_clone_activity_on(rsc, other_rsc, NULL, type); } static gboolean at_stack_bottom(resource_t *rsc) { char *key = NULL; action_t *start = NULL; action_t *other = NULL; int mode = stack_stable; GListPtr action_list = NULL; key = start_key(rsc); action_list = find_actions(rsc->actions, key, NULL); crm_free(key); crm_debug_3("%s: processing", rsc->id); CRM_CHECK(action_list != NULL, return FALSE); start = action_list->data; g_list_free(action_list); slist_iter( constraint, rsc_colocation_t, rsc->rsc_cons, lpc, resource_t *target = constraint->rsc_rh; crm_debug_4("Checking %s: %s == %s (%d)", constraint->id, rsc->id, target->id, constraint->score); if(constraint->score > 0) { mode |= check_stack_element(rsc, target, "coloc"); if(mode & stack_middle) { return FALSE; } else if((mode & stack_stopping) && (mode & stack_starting)) { crm_notice("Cannot migrate %s due to colocation activity (last was %s)", rsc->id, target->id); return FALSE; } } ); slist_iter( other_w, action_wrapper_t, start->actions_before, lpc, other = other_w->action; #if ALLOW_WEAK_MIGRATION if((other_w->type & pe_order_implies_right) == 0) { crm_debug_3("%s: depends on %s (optional ordering)", rsc->id, other->uuid); continue; } #endif crm_debug_2("%s: Checking %s ordering", rsc->id, other->uuid); if(other->optional == FALSE) { mode |= check_stack_element(rsc, other->rsc, "order"); if(mode & stack_middle) { return FALSE; } else if((mode & stack_stopping) && (mode & stack_starting)) { crm_notice("Cannot migrate %s due to ordering activity (last was %s)", rsc->id, other->rsc->id); return FALSE; } } ); return TRUE; } void complex_migrate_reload(resource_t *rsc, pe_working_set_t *data_set) { char *key = NULL; int level = LOG_DEBUG; GListPtr action_list = NULL; action_t *stop = NULL; action_t *start = NULL; action_t *other = NULL; action_t *action = NULL; const char *value = NULL; if(rsc->children) { slist_iter( child_rsc, resource_t, rsc->children, lpc, child_rsc->cmds->migrate_reload(child_rsc, data_set); ); other = NULL; return; } else if(rsc->variant > pe_native) { return; } do_crm_log_unlikely(level+1, "Processing %s", rsc->id); if(is_not_set(rsc->flags, pe_rsc_managed) || is_set(rsc->flags, pe_rsc_failed) || is_set(rsc->flags, pe_rsc_start_pending) || rsc->next_role < RSC_ROLE_STARTED || g_list_length(rsc->running_on) != 1) { do_crm_log_unlikely( level+1, "%s: general resource state: flags=0x%.16llx", rsc->id, rsc->flags); return; } value = g_hash_table_lookup(rsc->meta, XML_OP_ATTR_ALLOW_MIGRATE); if(crm_is_true(value)) { set_bit(rsc->flags, pe_rsc_can_migrate); } if(rsc->next_role > RSC_ROLE_SLAVE) { clear_bit(rsc->flags, pe_rsc_can_migrate); do_crm_log_unlikely( level+1, "%s: resource role: role=%s", rsc->id, role2text(rsc->next_role)); } key = start_key(rsc); action_list = find_actions(rsc->actions, key, NULL); crm_free(key); if(action_list == NULL) { do_crm_log_unlikely(level, "%s: no start action", rsc->id); return; } start = action_list->data; g_list_free(action_list); if(is_not_set(rsc->flags, pe_rsc_can_migrate) && start->allow_reload_conversion == FALSE) { do_crm_log_unlikely(level+1, "%s: no need to continue", rsc->id); return; } key = stop_key(rsc); action_list = find_actions(rsc->actions, key, NULL); crm_free(key); if(action_list == NULL) { do_crm_log_unlikely(level, "%s: no stop action", rsc->id); return; } stop = action_list->data; g_list_free(action_list); action = start; if(action->pseudo || action->optional || action->node == NULL || action->runnable == FALSE) { do_crm_log_unlikely(level, "%s: %s", rsc->id, action->task); return; } action = stop; if(action->pseudo || action->optional || action->node == NULL || action->runnable == FALSE) { do_crm_log_unlikely(level, "%s: %s", rsc->id, action->task); return; } if(is_set(rsc->flags, pe_rsc_can_migrate)) { if(start->node == NULL || stop->node == NULL || stop->node->details == start->node->details) { clear_bit(rsc->flags, pe_rsc_can_migrate); } else if(at_stack_bottom(rsc) == FALSE) { clear_bit(rsc->flags, pe_rsc_can_migrate); } } if(is_set(rsc->flags, pe_rsc_can_migrate)) { crm_info("Migrating %s from %s to %s", rsc->id, stop->node->details->uname, start->node->details->uname); crm_free(stop->uuid); crm_free(stop->task); stop->task = crm_strdup(RSC_MIGRATE); stop->uuid = generate_op_key(rsc->id, stop->task, 0); add_hash_param(stop->meta, "migrate_source", stop->node->details->uname); add_hash_param(stop->meta, "migrate_target", start->node->details->uname); /* Create the correct ordering ajustments based on find_clone_activity_on(); */ slist_iter( constraint, rsc_colocation_t, rsc->rsc_cons, lpc, resource_t *target = constraint->rsc_rh; crm_info("Repairing %s: %s == %s (%d)", constraint->id, rsc->id, target->id, constraint->score); if(constraint->score > 0) { int mode = check_stack_element(rsc, target, "coloc"); action_t *clone_stop = find_first_action(target->actions, NULL, RSC_STOP, NULL); action_t *clone_start = find_first_action(target->actions, NULL, RSC_STARTED, NULL); CRM_ASSERT(clone_stop != NULL); CRM_ASSERT(clone_start != NULL); CRM_ASSERT((mode & stack_middle) == 0); CRM_ASSERT(((mode & stack_stopping) && (mode & stack_starting)) == 0); if(mode & stack_stopping) { action_t *clone_stop = find_first_action(target->actions, NULL, RSC_STOP, NULL); action_t *clone_start = find_first_action(target->actions, NULL, RSC_STARTED, NULL); crm_debug("Creating %s.start -> %s.stop ordering", rsc->id, target->id); order_actions(start, clone_stop, pe_order_optional); slist_iter( other_w, action_wrapper_t, start->actions_before, lpc2, /* Needed if the clone's started pseudo-action ever gets printed in the graph */ if(other_w->action == clone_start) { crm_debug("Breaking %s -> %s ordering", other_w->action->uuid, start->uuid); other_w->type = pe_order_none; } ); } else if(mode & stack_starting) { crm_debug("Creating %s.started -> %s.stop ordering", target->id, rsc->id); order_actions(clone_start, stop, pe_order_optional); slist_iter( other_w, action_wrapper_t, clone_stop->actions_before, lpc2, /* Needed if the clone's stop pseudo-action ever gets printed in the graph */ if(other_w->action == stop) { crm_debug("Breaking %s -> %s ordering", other_w->action->uuid, clone_stop->uuid); other_w->type = pe_order_none; } ); } } ); crm_free(start->uuid); crm_free(start->task); start->task = crm_strdup(RSC_MIGRATED); start->uuid = generate_op_key(rsc->id, start->task, 0); add_hash_param(start->meta, "migrate_source_uuid", stop->node->details->id); add_hash_param(start->meta, "migrate_source", stop->node->details->uname); add_hash_param(start->meta, "migrate_target", start->node->details->uname); /* Anything that needed stop to complete, now also needs start to have completed */ slist_iter( other_w, action_wrapper_t, stop->actions_after, lpc, other = other_w->action; if(other->optional || other->rsc != NULL) { continue; } crm_debug("Ordering %s before %s (stop)", start->uuid, other_w->action->uuid); order_actions(start, other, other_w->type); ); /* Stop also needs anything that the start needed to have completed too */ slist_iter( other_w, action_wrapper_t, start->actions_before, lpc, other = other_w->action; if(other->rsc == NULL) { /* nothing */ } else if(other->optional || other->rsc == rsc || other->rsc == rsc->parent) { continue; } crm_debug("Ordering %s before %s (start)", other_w->action->uuid, stop->uuid); order_actions(other, stop, other_w->type); ); } else if(start && stop && start->allow_reload_conversion && stop->node->details == start->node->details) { action_t *rewrite = NULL; start->pseudo = TRUE; /* easier than trying to delete it from the graph */ action = NULL; key = promote_key(rsc); action_list = find_actions(rsc->actions, key, NULL); if(action_list) { action = action_list->data; } if(action && action->optional == FALSE) { action->pseudo = TRUE; } g_list_free(action_list); crm_free(key); action = NULL; key = demote_key(rsc); action_list = find_actions(rsc->actions, key, NULL); if(action_list) { action = action_list->data; } g_list_free(action_list); crm_free(key); if(action && action->optional == FALSE) { rewrite = action; stop->pseudo = TRUE; } else { rewrite = stop; } crm_info("Rewriting %s of %s on %s as a reload", rewrite->task, rsc->id, stop->node->details->uname); crm_free(rewrite->uuid); crm_free(rewrite->task); rewrite->task = crm_strdup("reload"); rewrite->uuid = generate_op_key(rsc->id, rewrite->task, 0); } else { do_crm_log_unlikely(level+1, "%s nothing to do", rsc->id); } } diff --git a/pengine/regression.sh b/pengine/regression.sh index d69c1c10ee..6fcbd9a9b3 100755 --- a/pengine/regression.sh +++ b/pengine/regression.sh @@ -1,330 +1,332 @@ #!/bin/bash # Copyright (C) 2004 Andrew Beekhof # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This software is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # if [ -x /usr/bin/valgrind ]; then export G_SLICE=always-malloc VALGRIND_CMD="valgrind -q --show-reachable=no --leak-check=full --trace-children=no --time-stamp=yes --num-callers=20 --suppressions=./ptest.supp" fi . regression.core.sh create_mode="true" echo Generating test outputs for these tests... # do_test file description echo Done. echo "" echo Performing the following tests... create_mode="false" echo "" do_test simple1 "Offline " do_test simple2 "Start " do_test simple3 "Start 2 " do_test simple4 "Start Failed" do_test simple6 "Stop Start " do_test simple7 "Shutdown " #do_test simple8 "Stonith " #do_test simple9 "Lower version" #do_test simple10 "Higher version" do_test simple11 "Priority (ne)" do_test simple12 "Priority (eq)" do_test simple8 "Stickiness" echo "" do_test params-0 "Params: No change" do_test params-1 "Params: Changed" do_test params-2 "Params: Resource definition" do_test params-4 "Params: Reload" do_test novell-251689 "Resource definition change + target_role=stopped" do_test bug-lf-2106 "Restart all anonymous clone instances after config change" echo "" do_test orphan-0 "Orphan ignore" do_test orphan-1 "Orphan stop" echo "" do_test target-0 "Target Role : baseline" do_test target-1 "Target Role : test" echo "" do_test date-1 "Dates" -d "2005-020" do_test date-2 "Date Spec - Pass" -d "2005-020T12:30" do_test date-3 "Date Spec - Fail" -d "2005-020T11:30" do_test probe-0 "Probe (anon clone)" do_test probe-1 "Pending Probe" do_test probe-2 "Correctly re-probe cloned groups" do_test standby "Standby" do_test comments "Comments" echo "" do_test rsc_dep1 "Must not " do_test rsc_dep3 "Must " do_test rsc_dep5 "Must not 3 " do_test rsc_dep7 "Must 3 " do_test rsc_dep10 "Must (but cant)" do_test rsc_dep2 "Must (running) " do_test rsc_dep8 "Must (running : alt) " do_test rsc_dep4 "Must (running + move)" do_test asymmetric "Asymmetric - require explicit location constraints" echo "" do_test order1 "Order start 1 " do_test order2 "Order start 2 " do_test order3 "Order stop " do_test order4 "Order (multiple) " do_test order5 "Order (move) " do_test order6 "Order (move w/ restart) " do_test order7 "Order (manditory) " do_test order-optional "Order (score=0) " do_test order-required "Order (score=INFINITY) " do_test bug-lf-2171 "Prevent group start when clone is stopped" +do_test order-clone "Clone ordering should be able to prevent startup of dependant clones" echo "" do_test coloc-loop "Colocation - loop" do_test coloc-many-one "Colocation - many-to-one" do_test coloc-list "Colocation - many-to-one with list" do_test coloc-group "Colocation - groups" do_test coloc-slave-anti "Anti-colocation with slave shouldn't prevent master colocation" do_test coloc-attr "Colocation based on node attributes" #echo "" #do_test agent1 "version: lt (empty)" #do_test agent2 "version: eq " #do_test agent3 "version: gt " echo "" do_test attrs1 "string: eq (and) " do_test attrs2 "string: lt / gt (and)" do_test attrs3 "string: ne (or) " do_test attrs4 "string: exists " do_test attrs5 "string: not_exists " do_test attrs6 "is_dc: true " do_test attrs7 "is_dc: false " do_test attrs8 "score_attribute " echo "" do_test mon-rsc-1 "Schedule Monitor - start" do_test mon-rsc-2 "Schedule Monitor - move " do_test mon-rsc-3 "Schedule Monitor - pending start " do_test mon-rsc-4 "Schedule Monitor - move/pending start" echo "" do_test rec-rsc-0 "Resource Recover - no start " do_test rec-rsc-1 "Resource Recover - start " do_test rec-rsc-2 "Resource Recover - monitor " do_test rec-rsc-3 "Resource Recover - stop - ignore" do_test rec-rsc-4 "Resource Recover - stop - block " do_test rec-rsc-5 "Resource Recover - stop - fence " do_test rec-rsc-6 "Resource Recover - multiple - restart" do_test rec-rsc-7 "Resource Recover - multiple - stop " do_test rec-rsc-8 "Resource Recover - multiple - block " do_test rec-rsc-9 "Resource Recover - group/group" echo "" do_test quorum-1 "No quorum - ignore" do_test quorum-2 "No quorum - freeze" do_test quorum-3 "No quorum - stop " do_test quorum-4 "No quorum - start anyway" do_test quorum-5 "No quorum - start anyway (group)" do_test quorum-6 "No quorum - start anyway (clone)" echo "" do_test rec-node-1 "Node Recover - Startup - no fence" do_test rec-node-2 "Node Recover - Startup - fence " do_test rec-node-3 "Node Recover - HA down - no fence" do_test rec-node-4 "Node Recover - HA down - fence " do_test rec-node-5 "Node Recover - CRM down - no fence" do_test rec-node-6 "Node Recover - CRM down - fence " do_test rec-node-7 "Node Recover - no quorum - ignore " do_test rec-node-8 "Node Recover - no quorum - freeze " do_test rec-node-9 "Node Recover - no quorum - stop " do_test rec-node-10 "Node Recover - no quorum - stop w/fence" do_test rec-node-11 "Node Recover - CRM down w/ group - fence " do_test rec-node-12 "Node Recover - nothing active - fence " do_test rec-node-13 "Node Recover - failed resource + shutdown - fence " do_test rec-node-15 "Node Recover - unknown lrm section" do_test rec-node-14 "Serialize all stonith's" echo "" do_test multi1 "Multiple Active (stop/start)" echo "" do_test migrate-stop "Migration in a stopping stack" do_test migrate-start "Migration in a starting stack" do_test migrate-stop_start "Migration in a restarting stack" do_test migrate-stop-complex "Migration in a complex stopping stack" do_test migrate-start-complex "Migration in a complex starting stack" do_test migrate-1 "Migrate (migrate)" do_test migrate-2 "Migrate (stable)" do_test migrate-3 "Migrate (failed migrate_to)" do_test migrate-4 "Migrate (failed migrate_from)" do_test novell-252693 "Migration in a stopping stack" do_test novell-252693-2 "Migration in a starting stack" do_test novell-252693-3 "Non-Migration in a starting and stopping stack" do_test bug-1820 "Migration in a group" do_test bug-1820-1 "Non-migration in a group" do_test migrate-5 "Primitive migration with a clone" #echo "" #do_test complex1 "Complex " echo "" do_test group1 "Group " do_test group2 "Group + Native " do_test group3 "Group + Group " do_test group4 "Group + Native (nothing)" do_test group5 "Group + Native (move) " do_test group6 "Group + Group (move) " do_test group7 "Group colocation" do_test group13 "Group colocation (cant run)" do_test group8 "Group anti-colocation" do_test group9 "Group recovery" do_test group10 "Group partial recovery" do_test group11 "Group target_role" do_test group14 "Group stop (graph terminated)" do_test group15 "-ve group colocation" do_test bug-1573 "Partial stop of a group with two children" do_test bug-1718 "Mandatory group ordering - Stop group_FUN" echo "" do_test clone-anon-probe-1 "Probe the correct (anonymous) clone instance for each node" do_test clone-anon-probe-2 "Avoid needless re-probing of anonymous clones" do_test inc0 "Incarnation start" do_test inc1 "Incarnation start order" do_test inc2 "Incarnation silent restart, stop, move" do_test inc3 "Inter-incarnation ordering, silent restart, stop, move" do_test inc4 "Inter-incarnation ordering, silent restart, stop, move (ordered)" do_test inc5 "Inter-incarnation ordering, silent restart, stop, move (restart 1)" do_test inc6 "Inter-incarnation ordering, silent restart, stop, move (restart 2)" do_test inc7 "Clone colocation" do_test inc8 "Clone anti-colocation" do_test inc9 "Non-unique clone" do_test inc10 "Non-unique clone (stop)" do_test inc11 "Primitive colocation with clones" do_test inc12 "Clone shutdown" do_test cloned-group "Make sure only the correct number of cloned groups are started" do_test clone-no-shuffle "Dont prioritize allocation of instances that must be moved" do_test clone-max-zero "Orphan processing with clone-max=0" do_test clone-anon-dup "Bug LF#2087 - Correctly parse the state of anonymous clones that are active more than once per node" do_test bug-lf-2160 "Dont shuffle clones due to colocation" +do_test bug-lf-2213 "clone-node-max enforcement for cloned groups" echo "" do_test master-0 "Stopped -> Slave" do_test master-1 "Stopped -> Promote" do_test master-2 "Stopped -> Promote : notify" do_test master-3 "Stopped -> Promote : master location" do_test master-4 "Started -> Promote : master location" do_test master-5 "Promoted -> Promoted" do_test master-6 "Promoted -> Promoted (2)" do_test master-7 "Promoted -> Fenced" do_test master-8 "Promoted -> Fenced -> Moved" do_test master-9 "Stopped + Promotable + No quorum" do_test master-10 "Stopped -> Promotable : notify with monitor" do_test master-11 "Stopped -> Promote : colocation" do_test novell-239082 "Demote/Promote ordering" do_test novell-239087 "Stable master placement" do_test master-12 "Promotion based solely on rsc_location constraints" do_test master-13 "Include preferences of colocated resources when placing master" do_test master-demote "Ordering when actions depends on demoting a slave resource" do_test master-ordering "Prevent resources from starting that need a master" do_test bug-1765 "Master-Master Colocation (dont stop the slaves)" do_test master-group "Promotion of cloned groups" do_test bug-lf-1852 "Don't shuffle master/slave instances unnecessarily" do_test master-failed-demote "Dont retry failed demote actions" do_test master-failed-demote-2 "Dont retry failed demote actions (notify=false)" do_test master-depend "Ensure resources that depend on the master don't get allocated until the master does" do_test master-reattach "Re-attach to a running master" do_test master-allow-start "Don't include master score if it would prevent allocation" do_test master-colocation "Allow master instances placemaker to be influenced by colocation constraints" do_test master-pseudo "Make sure promote/demote pseudo actions are created correctly" do_test master-role "Prevent target-role from promoting more than master-max instances" echo "" do_test managed-0 "Managed (reference)" do_test managed-1 "Not managed - down " do_test managed-2 "Not managed - up " echo "" do_test interleave-0 "Interleave (reference)" do_test interleave-1 "coloc - not interleaved" do_test interleave-2 "coloc - interleaved " do_test interleave-3 "coloc - interleaved (2)" do_test interleave-pseudo-stop "Interleaved clone during stonith" do_test interleave-stop "Interleaved clone during stop" do_test interleave-restart "Interleaved clone during dependancy restart" echo "" do_test notify-0 "Notify reference" do_test notify-1 "Notify simple" do_test notify-2 "Notify simple, confirm" do_test notify-3 "Notify move, confirm" do_test novell-239079 "Notification priority" #do_test notify-2 "Notify - 764" echo "" do_test 594 "OSDL #594" do_test 662 "OSDL #662" do_test 696 "OSDL #696" do_test 726 "OSDL #726" do_test 735 "OSDL #735" do_test 764 "OSDL #764" do_test 797 "OSDL #797" do_test 829 "OSDL #829" do_test 994 "OSDL #994" do_test 994-2 "OSDL #994 - with a dependant resource" do_test 1360 "OSDL #1360 - Clone stickiness" do_test 1484 "OSDL #1484 - on_fail=stop" do_test 1494 "OSDL #1494 - Clone stability" do_test unrunnable-1 "Unrunnable" do_test stonith-0 "Stonith loop - 1" do_test stonith-1 "Stonith loop - 2" do_test stonith-2 "Stonith loop - 3" do_test stonith-3 "Stonith startup" do_test bug-1572-1 "Recovery of groups depending on master/slave" do_test bug-1572-2 "Recovery of groups depending on master/slave when the master is never re-promoted" do_test bug-1685 "Depends-on-master ordering" do_test bug-1822 "Dont promote partially active groups" do_test bug-pm-11 "New resource added to a m/s group" do_test bug-pm-12 "Recover only the failed portion of a cloned group" do_test bug-n-387749 "Don't shuffle clone instances" do_test bug-n-385265 "Don't ignore the failure stickiness of group children - resource_idvscommon should stay stopped" do_test bug-n-385265-2 "Ensure groups are migrated instead of remaining partially active on the current node" do_test bug-lf-1920 "Correctly handle probes that find active resources" do_test bnc-515172 "Location constraint with multiple expressions" echo "" do_test systemhealth1 "System Health () #1" do_test systemhealth2 "System Health () #2" do_test systemhealth3 "System Health () #3" do_test systemhealthn1 "System Health (None) #1" do_test systemhealthn2 "System Health (None) #2" do_test systemhealthn3 "System Health (None) #3" do_test systemhealthm1 "System Health (Migrate On Red) #1" do_test systemhealthm2 "System Health (Migrate On Red) #2" do_test systemhealthm3 "System Health (Migrate On Red) #3" do_test systemhealtho1 "System Health (Only Green) #1" do_test systemhealtho2 "System Health (Only Green) #2" do_test systemhealtho3 "System Health (Only Green) #3" do_test systemhealthp1 "System Health (Progessive) #1" do_test systemhealthp2 "System Health (Progessive) #2" do_test systemhealthp3 "System Health (Progessive) #3" echo "" test_results diff --git a/pengine/test10/1360.scores b/pengine/test10/1360.scores index 1b91b8e41d..d61c19c017 100644 --- a/pengine/test10/1360.scores +++ b/pengine/test10/1360.scores @@ -1,13 +1,13 @@ Allocation scores: -group_color: ClusterAlias allocation score on ssgtest1a: 0 +group_color: ClusterAlias allocation score on ssgtest1a: 1000000 group_color: ClusterAlias allocation score on ssgtest1b: 0 group_color: VIP allocation score on ssgtest1a: 1000000 group_color: VIP allocation score on ssgtest1b: 0 native_color: VIP allocation score on ssgtest1a: 1000000 native_color: VIP allocation score on ssgtest1b: 0 clone_color: dolly allocation score on ssgtest1a: 0 clone_color: dolly allocation score on ssgtest1b: 1000000 clone_color: dollies:0 allocation score on ssgtest1a: 0 clone_color: dollies:0 allocation score on ssgtest1b: 1000000 native_color: dollies:0 allocation score on ssgtest1a: 0 native_color: dollies:0 allocation score on ssgtest1b: 1000000 diff --git a/pengine/test10/bug-1573.scores b/pengine/test10/bug-1573.scores index 82402ba5fe..75dfd020f1 100644 --- a/pengine/test10/bug-1573.scores +++ b/pengine/test10/bug-1573.scores @@ -1,21 +1,21 @@ Allocation scores: group_color: group_1 allocation score on xen-c: 0 -group_color: group_1 allocation score on xen-b: 0 +group_color: group_1 allocation score on xen-b: 100 group_color: IPaddr_192_168_1_101 allocation score on xen-c: 0 group_color: IPaddr_192_168_1_101 allocation score on xen-b: 100 group_color: apache_2 allocation score on xen-c: 0 group_color: apache_2 allocation score on xen-b: 0 native_color: IPaddr_192_168_1_101 allocation score on xen-c: 0 native_color: IPaddr_192_168_1_101 allocation score on xen-b: 100 native_color: apache_2 allocation score on xen-c: -1000000 native_color: apache_2 allocation score on xen-b: -1000000 -group_color: group_11 allocation score on xen-c: 0 +group_color: group_11 allocation score on xen-c: 100 group_color: group_11 allocation score on xen-b: 0 group_color: IPaddr_192_168_1_102 allocation score on xen-c: 100 group_color: IPaddr_192_168_1_102 allocation score on xen-b: 0 group_color: apache_6 allocation score on xen-c: 0 group_color: apache_6 allocation score on xen-b: 0 native_color: IPaddr_192_168_1_102 allocation score on xen-c: 100 native_color: IPaddr_192_168_1_102 allocation score on xen-b: 0 native_color: apache_6 allocation score on xen-c: -1000000 native_color: apache_6 allocation score on xen-b: -1000000 diff --git a/pengine/test10/bug-1718.scores b/pengine/test10/bug-1718.scores index 067099d1a4..30dd02628a 100644 --- a/pengine/test10/bug-1718.scores +++ b/pengine/test10/bug-1718.scores @@ -1,61 +1,61 @@ Allocation scores: -group_color: Web_Group allocation score on defiant.ds9: 0 +group_color: Web_Group allocation score on defiant.ds9: 100 group_color: Web_Group allocation score on heartbeat.ds9: 0 group_color: Web_Group allocation score on ops.ds9: 0 group_color: Web_Group allocation score on biggame.ds9: 0 group_color: Web_Group allocation score on warbird.ds9: 0 group_color: Apache_IP allocation score on defiant.ds9: 100 group_color: Apache_IP allocation score on heartbeat.ds9: 0 group_color: Apache_IP allocation score on ops.ds9: 0 group_color: Apache_IP allocation score on biggame.ds9: 0 group_color: Apache_IP allocation score on warbird.ds9: 0 group_color: resource_IP2 allocation score on defiant.ds9: 0 group_color: resource_IP2 allocation score on heartbeat.ds9: 0 group_color: resource_IP2 allocation score on ops.ds9: 0 group_color: resource_IP2 allocation score on biggame.ds9: 0 group_color: resource_IP2 allocation score on warbird.ds9: 0 group_color: resource_dummyweb allocation score on defiant.ds9: 0 group_color: resource_dummyweb allocation score on heartbeat.ds9: 0 group_color: resource_dummyweb allocation score on ops.ds9: 0 group_color: resource_dummyweb allocation score on biggame.ds9: 0 group_color: resource_dummyweb allocation score on warbird.ds9: 0 native_color: Apache_IP allocation score on defiant.ds9: -1000000 native_color: Apache_IP allocation score on heartbeat.ds9: 0 native_color: Apache_IP allocation score on ops.ds9: 0 native_color: Apache_IP allocation score on biggame.ds9: 0 native_color: Apache_IP allocation score on warbird.ds9: -1000000 native_color: resource_IP2 allocation score on defiant.ds9: -1000000 native_color: resource_IP2 allocation score on heartbeat.ds9: -1000000 native_color: resource_IP2 allocation score on ops.ds9: -1000000 native_color: resource_IP2 allocation score on biggame.ds9: -1000000 native_color: resource_IP2 allocation score on warbird.ds9: -1000000 native_color: resource_dummyweb allocation score on defiant.ds9: -1000000 native_color: resource_dummyweb allocation score on heartbeat.ds9: -1000000 native_color: resource_dummyweb allocation score on ops.ds9: -1000000 native_color: resource_dummyweb allocation score on biggame.ds9: -1000000 native_color: resource_dummyweb allocation score on warbird.ds9: -1000000 group_color: group_fUN allocation score on defiant.ds9: 0 group_color: group_fUN allocation score on heartbeat.ds9: 0 group_color: group_fUN allocation score on ops.ds9: 0 group_color: group_fUN allocation score on biggame.ds9: 0 group_color: group_fUN allocation score on warbird.ds9: 0 group_color: resource_IP3 allocation score on defiant.ds9: 0 group_color: resource_IP3 allocation score on heartbeat.ds9: 0 group_color: resource_IP3 allocation score on ops.ds9: 0 group_color: resource_IP3 allocation score on biggame.ds9: 0 group_color: resource_IP3 allocation score on warbird.ds9: 0 group_color: resource_dummy allocation score on defiant.ds9: 0 group_color: resource_dummy allocation score on heartbeat.ds9: 0 group_color: resource_dummy allocation score on ops.ds9: 0 group_color: resource_dummy allocation score on biggame.ds9: 0 group_color: resource_dummy allocation score on warbird.ds9: 0 native_color: resource_IP3 allocation score on defiant.ds9: -1000000 native_color: resource_IP3 allocation score on heartbeat.ds9: 0 native_color: resource_IP3 allocation score on ops.ds9: 0 native_color: resource_IP3 allocation score on biggame.ds9: 0 native_color: resource_IP3 allocation score on warbird.ds9: -1000000 native_color: resource_dummy allocation score on defiant.ds9: -1000000 native_color: resource_dummy allocation score on heartbeat.ds9: -1000000 native_color: resource_dummy allocation score on ops.ds9: 0 native_color: resource_dummy allocation score on biggame.ds9: -1000000 native_color: resource_dummy allocation score on warbird.ds9: -1000000 diff --git a/pengine/test10/bug-1820-1.scores b/pengine/test10/bug-1820-1.scores index 6d47f682d1..cddc5c11b8 100644 --- a/pengine/test10/bug-1820-1.scores +++ b/pengine/test10/bug-1820-1.scores @@ -1,11 +1,13 @@ Allocation scores: native_color: p1 allocation score on star: -1000000 native_color: p1 allocation score on world: 2000 +group_color: gr1 allocation score on star: 1000000 +group_color: gr1 allocation score on world: 1000 group_color: test1 allocation score on star: 1000000 group_color: test1 allocation score on world: 1000 group_color: test2 allocation score on star: 0 group_color: test2 allocation score on world: 0 native_color: test1 allocation score on star: -1000000 native_color: test1 allocation score on world: 1000 native_color: test2 allocation score on star: -1000000 native_color: test2 allocation score on world: 0 diff --git a/pengine/test10/bug-1820.scores b/pengine/test10/bug-1820.scores index 88b1bbf6b8..8e535a2836 100644 --- a/pengine/test10/bug-1820.scores +++ b/pengine/test10/bug-1820.scores @@ -1,9 +1,11 @@ Allocation scores: +group_color: gr1 allocation score on star: 1000000 +group_color: gr1 allocation score on world: 1000 group_color: test1 allocation score on star: 1000000 group_color: test1 allocation score on world: 1000 group_color: test2 allocation score on star: 0 group_color: test2 allocation score on world: 0 native_color: test1 allocation score on star: -1000000 native_color: test1 allocation score on world: 1000 native_color: test2 allocation score on star: -1000000 native_color: test2 allocation score on world: 0 diff --git a/pengine/test10/bug-lf-2213.dot b/pengine/test10/bug-lf-2213.dot new file mode 100644 index 0000000000..3f63fcb085 --- /dev/null +++ b/pengine/test10/bug-lf-2213.dot @@ -0,0 +1,21 @@ +digraph "g" { +"cl-test_running_0" [ style=bold color="green" fontcolor="orange" ] +"cl-test_start_0" -> "cl-test_running_0" [ style = bold] +"cl-test_start_0" -> "gr-test:0_start_0" [ style = bold] +"cl-test_start_0" -> "gr-test:1_start_0" [ style = bold] +"cl-test_start_0" [ style=bold color="green" fontcolor="orange" ] +"gr-test:0_running_0" -> "cl-test_running_0" [ style = bold] +"gr-test:0_running_0" [ style=bold color="green" fontcolor="orange" ] +"gr-test:0_start_0" -> "gr-test:0_running_0" [ style = bold] +"gr-test:0_start_0" -> "test:0_start_0 web1" [ style = bold] +"gr-test:0_start_0" [ style=bold color="green" fontcolor="orange" ] +"gr-test:1_running_0" -> "cl-test_running_0" [ style = bold] +"gr-test:1_running_0" [ style=bold color="green" fontcolor="orange" ] +"gr-test:1_start_0" -> "gr-test:1_running_0" [ style = bold] +"gr-test:1_start_0" -> "test:1_start_0 web2" [ style = bold] +"gr-test:1_start_0" [ style=bold color="green" fontcolor="orange" ] +"test:0_start_0 web1" -> "gr-test:0_running_0" [ style = bold] +"test:0_start_0 web1" [ style=bold color="green" fontcolor="black" ] +"test:1_start_0 web2" -> "gr-test:1_running_0" [ style = bold] +"test:1_start_0 web2" [ style=bold color="green" fontcolor="black" ] +} diff --git a/pengine/test10/bug-lf-2213.exp b/pengine/test10/bug-lf-2213.exp new file mode 100644 index 0000000000..c844f18c54 --- /dev/null +++ b/pengine/test10/bug-lf-2213.exp @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pengine/test10/bug-lf-2213.scores b/pengine/test10/bug-lf-2213.scores new file mode 100644 index 0000000000..f6537b6138 --- /dev/null +++ b/pengine/test10/bug-lf-2213.scores @@ -0,0 +1,85 @@ +Allocation scores: +clone_color: cl-test allocation score on fs1: -1000000 +clone_color: cl-test allocation score on fs2: -1000000 +clone_color: cl-test allocation score on web1: 1 +clone_color: cl-test allocation score on web2: 1 +clone_color: gr-test:0 allocation score on fs1: -1000000 +clone_color: gr-test:0 allocation score on fs2: -1000000 +clone_color: gr-test:0 allocation score on web1: 1 +clone_color: gr-test:0 allocation score on web2: 1 +clone_color: test:0 allocation score on fs1: -1000000 +clone_color: test:0 allocation score on fs2: -1000000 +clone_color: test:0 allocation score on web1: 1 +clone_color: test:0 allocation score on web2: 1 +clone_color: gr-test:1 allocation score on fs1: -1000000 +clone_color: gr-test:1 allocation score on fs2: -1000000 +clone_color: gr-test:1 allocation score on web1: 1 +clone_color: gr-test:1 allocation score on web2: 1 +clone_color: test:1 allocation score on fs1: -1000000 +clone_color: test:1 allocation score on fs2: -1000000 +clone_color: test:1 allocation score on web1: 1 +clone_color: test:1 allocation score on web2: 1 +clone_color: gr-test:2 allocation score on fs1: -1000000 +clone_color: gr-test:2 allocation score on fs2: -1000000 +clone_color: gr-test:2 allocation score on web1: 1 +clone_color: gr-test:2 allocation score on web2: 1 +clone_color: test:2 allocation score on fs1: -1000000 +clone_color: test:2 allocation score on fs2: -1000000 +clone_color: test:2 allocation score on web1: 1 +clone_color: test:2 allocation score on web2: 1 +clone_color: gr-test:3 allocation score on fs1: -1000000 +clone_color: gr-test:3 allocation score on fs2: -1000000 +clone_color: gr-test:3 allocation score on web1: 1 +clone_color: gr-test:3 allocation score on web2: 1 +clone_color: test:3 allocation score on fs1: -1000000 +clone_color: test:3 allocation score on fs2: -1000000 +clone_color: test:3 allocation score on web1: 1 +clone_color: test:3 allocation score on web2: 1 +group_color: gr-test:0 allocation score on fs1: -1000000 +group_color: gr-test:0 allocation score on fs2: -1000000 +group_color: gr-test:0 allocation score on web1: 1 +group_color: gr-test:0 allocation score on web2: 1 +group_color: test:0 allocation score on fs1: -1000000 +group_color: test:0 allocation score on fs2: -1000000 +group_color: test:0 allocation score on web1: 1 +group_color: test:0 allocation score on web2: 1 +native_color: test:0 allocation score on fs1: -1000000 +native_color: test:0 allocation score on fs2: -1000000 +native_color: test:0 allocation score on web1: 1 +native_color: test:0 allocation score on web2: 1 +group_color: gr-test:1 allocation score on fs1: -1000000 +group_color: gr-test:1 allocation score on fs2: -1000000 +group_color: gr-test:1 allocation score on web1: -1000000 +group_color: gr-test:1 allocation score on web2: 1 +group_color: test:1 allocation score on fs1: -1000000 +group_color: test:1 allocation score on fs2: -1000000 +group_color: test:1 allocation score on web1: -1000000 +group_color: test:1 allocation score on web2: 1 +native_color: test:1 allocation score on fs1: -1000000 +native_color: test:1 allocation score on fs2: -1000000 +native_color: test:1 allocation score on web1: -1000000 +native_color: test:1 allocation score on web2: 1 +group_color: gr-test:2 allocation score on fs1: -1000000 +group_color: gr-test:2 allocation score on fs2: -1000000 +group_color: gr-test:2 allocation score on web1: -1000000 +group_color: gr-test:2 allocation score on web2: -1000000 +group_color: test:2 allocation score on fs1: -1000000 +group_color: test:2 allocation score on fs2: -1000000 +group_color: test:2 allocation score on web1: -1000000 +group_color: test:2 allocation score on web2: -1000000 +native_color: test:2 allocation score on fs1: -1000000 +native_color: test:2 allocation score on fs2: -1000000 +native_color: test:2 allocation score on web1: -1000000 +native_color: test:2 allocation score on web2: -1000000 +group_color: gr-test:3 allocation score on fs1: -1000000 +group_color: gr-test:3 allocation score on fs2: -1000000 +group_color: gr-test:3 allocation score on web1: -1000000 +group_color: gr-test:3 allocation score on web2: -1000000 +group_color: test:3 allocation score on fs1: -1000000 +group_color: test:3 allocation score on fs2: -1000000 +group_color: test:3 allocation score on web1: -1000000 +group_color: test:3 allocation score on web2: -1000000 +native_color: test:3 allocation score on fs1: -1000000 +native_color: test:3 allocation score on fs2: -1000000 +native_color: test:3 allocation score on web1: -1000000 +native_color: test:3 allocation score on web2: -1000000 diff --git a/pengine/test10/bug-lf-2213.xml b/pengine/test10/bug-lf-2213.xml new file mode 100644 index 0000000000..af9c8a017c --- /dev/null +++ b/pengine/test10/bug-lf-2213.xml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pengine/test10/bug-n-387749.scores b/pengine/test10/bug-n-387749.scores index 1e06ec1e6d..ee2fdc1bff 100644 --- a/pengine/test10/bug-n-387749.scores +++ b/pengine/test10/bug-n-387749.scores @@ -1,37 +1,37 @@ Allocation scores: clone_color: export_home_ocfs2_clone_set allocation score on power720-1: 1000000 clone_color: export_home_ocfs2_clone_set allocation score on power720-2: 2000 clone_color: export_home_ocfs2_clone_set allocation score on power720-4: -1000000 clone_color: export_home_ocfs2:0 allocation score on power720-1: 0 clone_color: export_home_ocfs2:0 allocation score on power720-2: 0 clone_color: export_home_ocfs2:0 allocation score on power720-4: 0 clone_color: export_home_ocfs2:1 allocation score on power720-1: 0 clone_color: export_home_ocfs2:1 allocation score on power720-2: 1 clone_color: export_home_ocfs2:1 allocation score on power720-4: 0 clone_color: export_home_ocfs2:2 allocation score on power720-1: 0 clone_color: export_home_ocfs2:2 allocation score on power720-2: 0 clone_color: export_home_ocfs2:2 allocation score on power720-4: 0 native_color: export_home_ocfs2:1 allocation score on power720-1: 0 native_color: export_home_ocfs2:1 allocation score on power720-2: 1 native_color: export_home_ocfs2:1 allocation score on power720-4: -1000000 native_color: export_home_ocfs2:0 allocation score on power720-1: 0 native_color: export_home_ocfs2:0 allocation score on power720-2: -1000000 native_color: export_home_ocfs2:0 allocation score on power720-4: -1000000 native_color: export_home_ocfs2:2 allocation score on power720-1: -1000000 native_color: export_home_ocfs2:2 allocation score on power720-2: -1000000 native_color: export_home_ocfs2:2 allocation score on power720-4: -1000000 -group_color: group_nfs allocation score on power720-1: 0 +group_color: group_nfs allocation score on power720-1: 1000000 group_color: group_nfs allocation score on power720-2: 0 group_color: group_nfs allocation score on power720-4: 0 group_color: resource_ipaddr1_single allocation score on power720-1: 1000000 group_color: resource_ipaddr1_single allocation score on power720-2: 1000 group_color: resource_ipaddr1_single allocation score on power720-4: 0 group_color: resource_nfsserver_single allocation score on power720-1: 0 group_color: resource_nfsserver_single allocation score on power720-2: 1000 group_color: resource_nfsserver_single allocation score on power720-4: 0 native_color: resource_ipaddr1_single allocation score on power720-1: 1000000 native_color: resource_ipaddr1_single allocation score on power720-2: 2001 native_color: resource_ipaddr1_single allocation score on power720-4: -1000000 native_color: resource_nfsserver_single allocation score on power720-1: 0 native_color: resource_nfsserver_single allocation score on power720-2: -1000000 native_color: resource_nfsserver_single allocation score on power720-4: -1000000 diff --git a/pengine/test10/clone-anon-dup.dot b/pengine/test10/clone-anon-dup.dot index b010154af5..c8cc41194e 100644 --- a/pengine/test10/clone-anon-dup.dot +++ b/pengine/test10/clone-anon-dup.dot @@ -1,35 +1,30 @@ digraph "g" { "all_stopped" [ style=bold color="green" fontcolor="orange" ] -"apache2:0_monitor_0 wc02" -> "probe_complete wc02" [ style = bold] -"apache2:0_monitor_0 wc02" [ style=bold color="green" fontcolor="black" ] "apache2:2_stop_0 wc02" -> "all_stopped" [ style = bold] "apache2:2_stop_0 wc02" -> "group_webservice:2_stopped_0" [ style = bold] "apache2:2_stop_0 wc02" [ style=bold color="green" fontcolor="black" ] "clone_webservice_stop_0" -> "clone_webservice_stopped_0" [ style = bold] "clone_webservice_stop_0" -> "group_webservice:2_stop_0" [ style = bold] "clone_webservice_stop_0" [ style=bold color="green" fontcolor="orange" ] "clone_webservice_stopped_0" [ style=bold color="green" fontcolor="orange" ] "group_webservice:2_stop_0" -> "apache2:2_stop_0 wc02" [ style = bold] "group_webservice:2_stop_0" -> "group_webservice:2_stopped_0" [ style = bold] "group_webservice:2_stop_0" [ style=bold color="green" fontcolor="orange" ] "group_webservice:2_stopped_0" -> "clone_webservice_stopped_0" [ style = bold] "group_webservice:2_stopped_0" [ style=bold color="green" fontcolor="orange" ] "probe_complete wc01" -> "probe_complete" [ style = bold] "probe_complete wc01" [ style=bold color="green" fontcolor="black" ] "probe_complete wc02" -> "probe_complete" [ style = bold] "probe_complete wc02" [ style=bold color="green" fontcolor="black" ] "probe_complete wc03" -> "probe_complete" [ style = bold] "probe_complete wc03" [ style=bold color="green" fontcolor="black" ] -"probe_complete" -> "apache2:2_stop_0 wc02" [ style = bold] -"probe_complete" -> "clone_webservice_stop_0" [ style = bold] -"probe_complete" -> "group_webservice:2_stop_0" [ style = bold] "probe_complete" -> "stonith-1_start_0 wc01" [ style = bold] "probe_complete" [ style=bold color="green" fontcolor="orange" ] "stonith-1_monitor_0 wc01" -> "probe_complete wc01" [ style = bold] "stonith-1_monitor_0 wc01" [ style=bold color="green" fontcolor="black" ] "stonith-1_monitor_0 wc02" -> "probe_complete wc02" [ style = bold] "stonith-1_monitor_0 wc02" [ style=bold color="green" fontcolor="black" ] "stonith-1_monitor_0 wc03" -> "probe_complete wc03" [ style = bold] "stonith-1_monitor_0 wc03" [ style=bold color="green" fontcolor="black" ] "stonith-1_start_0 wc01" [ style=bold color="green" fontcolor="black" ] } diff --git a/pengine/test10/clone-anon-dup.exp b/pengine/test10/clone-anon-dup.exp index d19d86b1c7..ac85111e01 100644 --- a/pengine/test10/clone-anon-dup.exp +++ b/pengine/test10/clone-anon-dup.exp @@ -1,194 +1,172 @@ - + - + - - - - - - - - - - + - - - - + - + - + - + - + - + - + - - - - + - + - + - - - - - + - + - + - + - + - + - + - + - + - + - + - - - - + - + - + diff --git a/pengine/test10/coloc-attr.scores b/pengine/test10/coloc-attr.scores index 21a117102c..06bffb9d84 100644 --- a/pengine/test10/coloc-attr.scores +++ b/pengine/test10/coloc-attr.scores @@ -1,25 +1,25 @@ Allocation scores: group_color: group_test1 allocation score on power720-1: 0 -group_color: group_test1 allocation score on power720-2: 0 +group_color: group_test1 allocation score on power720-2: -1000000 group_color: group_test1 allocation score on power720-3: 0 -group_color: group_test1 allocation score on power720-4: 0 +group_color: group_test1 allocation score on power720-4: -1000000 group_color: resource_t11 allocation score on power720-1: 0 group_color: resource_t11 allocation score on power720-2: -1000000 group_color: resource_t11 allocation score on power720-3: 0 group_color: resource_t11 allocation score on power720-4: -1000000 native_color: resource_t11 allocation score on power720-1: -1000000 native_color: resource_t11 allocation score on power720-2: -1000000 native_color: resource_t11 allocation score on power720-3: 0 native_color: resource_t11 allocation score on power720-4: -1000000 -group_color: group_test2 allocation score on power720-1: 0 -group_color: group_test2 allocation score on power720-2: 0 -group_color: group_test2 allocation score on power720-3: 0 +group_color: group_test2 allocation score on power720-1: -1000000 +group_color: group_test2 allocation score on power720-2: -1000000 +group_color: group_test2 allocation score on power720-3: -1000000 group_color: group_test2 allocation score on power720-4: 0 group_color: resource_t21 allocation score on power720-1: -1000000 group_color: resource_t21 allocation score on power720-2: -1000000 group_color: resource_t21 allocation score on power720-3: -1000000 group_color: resource_t21 allocation score on power720-4: 0 native_color: resource_t21 allocation score on power720-1: -1000000 native_color: resource_t21 allocation score on power720-2: -1000000 native_color: resource_t21 allocation score on power720-3: -1000000 native_color: resource_t21 allocation score on power720-4: 0 diff --git a/pengine/test10/date-2.scores b/pengine/test10/date-2.scores index 5111dddd18..5e200d0987 100644 --- a/pengine/test10/date-2.scores +++ b/pengine/test10/date-2.scores @@ -1,11 +1,11 @@ Allocation scores: -group_color: test allocation score on router1: 0 +group_color: test allocation score on router1: 100 group_color: test allocation score on router2: 0 group_color: test_ip allocation score on router1: 100 group_color: test_ip allocation score on router2: 0 group_color: test_mailto allocation score on router1: 0 group_color: test_mailto allocation score on router2: 0 native_color: test_ip allocation score on router1: 100 native_color: test_ip allocation score on router2: 0 native_color: test_mailto allocation score on router1: -1000000 native_color: test_mailto allocation score on router2: -1000000 diff --git a/pengine/test10/date-3.scores b/pengine/test10/date-3.scores index 5111dddd18..5e200d0987 100644 --- a/pengine/test10/date-3.scores +++ b/pengine/test10/date-3.scores @@ -1,11 +1,11 @@ Allocation scores: -group_color: test allocation score on router1: 0 +group_color: test allocation score on router1: 100 group_color: test allocation score on router2: 0 group_color: test_ip allocation score on router1: 100 group_color: test_ip allocation score on router2: 0 group_color: test_mailto allocation score on router1: 0 group_color: test_mailto allocation score on router2: 0 native_color: test_ip allocation score on router1: 100 native_color: test_ip allocation score on router2: 0 native_color: test_mailto allocation score on router1: -1000000 native_color: test_mailto allocation score on router2: -1000000 diff --git a/pengine/test10/group4.scores b/pengine/test10/group4.scores index f24c6fe2c7..25b4163c24 100644 --- a/pengine/test10/group4.scores +++ b/pengine/test10/group4.scores @@ -1,19 +1,19 @@ Allocation scores: native_color: rsc1 allocation score on node1: 0 native_color: rsc1 allocation score on node2: 1 group_color: rsc2 allocation score on node1: 0 -group_color: rsc2 allocation score on node2: 0 +group_color: rsc2 allocation score on node2: 1 group_color: child_rsc1 allocation score on node1: 0 group_color: child_rsc1 allocation score on node2: 1 group_color: child_rsc2 allocation score on node1: 0 group_color: child_rsc2 allocation score on node2: 0 group_color: child_rsc3 allocation score on node1: 0 group_color: child_rsc3 allocation score on node2: 0 native_color: child_rsc1 allocation score on node1: 0 native_color: child_rsc1 allocation score on node2: 1 native_color: child_rsc2 allocation score on node1: -1000000 native_color: child_rsc2 allocation score on node2: 0 native_color: child_rsc3 allocation score on node1: -1000000 native_color: child_rsc3 allocation score on node2: 0 native_color: rsc3 allocation score on node1: 0 native_color: rsc3 allocation score on node2: 1 diff --git a/pengine/test10/group5.scores b/pengine/test10/group5.scores index f24c6fe2c7..25b4163c24 100644 --- a/pengine/test10/group5.scores +++ b/pengine/test10/group5.scores @@ -1,19 +1,19 @@ Allocation scores: native_color: rsc1 allocation score on node1: 0 native_color: rsc1 allocation score on node2: 1 group_color: rsc2 allocation score on node1: 0 -group_color: rsc2 allocation score on node2: 0 +group_color: rsc2 allocation score on node2: 1 group_color: child_rsc1 allocation score on node1: 0 group_color: child_rsc1 allocation score on node2: 1 group_color: child_rsc2 allocation score on node1: 0 group_color: child_rsc2 allocation score on node2: 0 group_color: child_rsc3 allocation score on node1: 0 group_color: child_rsc3 allocation score on node2: 0 native_color: child_rsc1 allocation score on node1: 0 native_color: child_rsc1 allocation score on node2: 1 native_color: child_rsc2 allocation score on node1: -1000000 native_color: child_rsc2 allocation score on node2: 0 native_color: child_rsc3 allocation score on node1: -1000000 native_color: child_rsc3 allocation score on node2: 0 native_color: rsc3 allocation score on node1: 0 native_color: rsc3 allocation score on node2: 1 diff --git a/pengine/test10/group6.scores b/pengine/test10/group6.scores index b974147e6c..43f5186d82 100644 --- a/pengine/test10/group6.scores +++ b/pengine/test10/group6.scores @@ -1,29 +1,29 @@ Allocation scores: group_color: rsc1 allocation score on node1: 0 -group_color: rsc1 allocation score on node2: 0 +group_color: rsc1 allocation score on node2: 1 group_color: child_rsc1 allocation score on node1: 0 group_color: child_rsc1 allocation score on node2: 1 group_color: child_rsc2 allocation score on node1: 0 group_color: child_rsc2 allocation score on node2: 0 group_color: child_rsc3 allocation score on node1: 0 group_color: child_rsc3 allocation score on node2: 0 native_color: child_rsc1 allocation score on node1: 0 native_color: child_rsc1 allocation score on node2: 1 native_color: child_rsc2 allocation score on node1: -1000000 native_color: child_rsc2 allocation score on node2: 0 native_color: child_rsc3 allocation score on node1: -1000000 native_color: child_rsc3 allocation score on node2: 0 group_color: rsc2 allocation score on node1: 0 -group_color: rsc2 allocation score on node2: 0 +group_color: rsc2 allocation score on node2: 1 group_color: child_rsc4 allocation score on node1: 0 group_color: child_rsc4 allocation score on node2: 1 group_color: child_rsc5 allocation score on node1: 0 group_color: child_rsc5 allocation score on node2: 0 group_color: child_rsc6 allocation score on node1: 0 group_color: child_rsc6 allocation score on node2: 0 native_color: child_rsc4 allocation score on node1: 0 native_color: child_rsc4 allocation score on node2: 1 native_color: child_rsc5 allocation score on node1: -1000000 native_color: child_rsc5 allocation score on node2: 0 native_color: child_rsc6 allocation score on node1: -1000000 native_color: child_rsc6 allocation score on node2: 0 diff --git a/pengine/test10/interleave-pseudo-stop.dot b/pengine/test10/interleave-pseudo-stop.dot index 5e870280ee..904b130836 100644 --- a/pengine/test10/interleave-pseudo-stop.dot +++ b/pengine/test10/interleave-pseudo-stop.dot @@ -1,113 +1,116 @@ digraph "g" { "all_stopped" [ style=bold color="green" fontcolor="orange" ] "configstoreclone:0_confirmed-post_notify_stonith_0" -> "all_stopped" [ style = bold] "configstoreclone:0_confirmed-post_notify_stonith_0" [ style=bold color="green" fontcolor="orange" ] "configstoreclone:0_post_notify_stonith_0" -> "configstoreclone:0_confirmed-post_notify_stonith_0" [ style = bold] "configstoreclone:0_post_notify_stonith_0" -> "configstoreclone:1_post_notify_stop_0 node2" [ style = bold] "configstoreclone:0_post_notify_stonith_0" [ style=bold color="green" fontcolor="orange" ] "configstoreclone:0_stop_0 node1" -> "all_stopped" [ style = bold] "configstoreclone:0_stop_0 node1" -> "configstorecloneset_stopped_0" [ style = bold] "configstoreclone:0_stop_0 node1" -> "evmsclone:0_stop_0 node1" [ style = bold] "configstoreclone:0_stop_0 node1" [ style=bold color="green" fontcolor="orange" ] "configstoreclone:1_post_notify_stop_0 node2" -> "configstoreclone:0_confirmed-post_notify_stonith_0" [ style = bold] "configstoreclone:1_post_notify_stop_0 node2" -> "configstorecloneset_confirmed-post_notify_stopped_0" [ style = bold] "configstoreclone:1_post_notify_stop_0 node2" [ style=bold color="green" fontcolor="black" ] "configstoreclone:1_pre_notify_stop_0 node2" -> "configstorecloneset_confirmed-pre_notify_stop_0" [ style = bold] "configstoreclone:1_pre_notify_stop_0 node2" [ style=bold color="green" fontcolor="black" ] "configstorecloneset_confirmed-post_notify_stopped_0" -> "all_stopped" [ style = bold] "configstorecloneset_confirmed-post_notify_stopped_0" -> "evmscloneset_stop_0" [ style = bold] "configstorecloneset_confirmed-post_notify_stopped_0" [ style=bold color="green" fontcolor="orange" ] "configstorecloneset_confirmed-pre_notify_stop_0" -> "configstorecloneset_post_notify_stopped_0" [ style = bold] "configstorecloneset_confirmed-pre_notify_stop_0" -> "configstorecloneset_stop_0" [ style = bold] "configstorecloneset_confirmed-pre_notify_stop_0" [ style=bold color="green" fontcolor="orange" ] "configstorecloneset_post_notify_stopped_0" -> "configstoreclone:1_post_notify_stop_0 node2" [ style = bold] "configstorecloneset_post_notify_stopped_0" -> "configstorecloneset_confirmed-post_notify_stopped_0" [ style = bold] "configstorecloneset_post_notify_stopped_0" [ style=bold color="green" fontcolor="orange" ] "configstorecloneset_pre_notify_stop_0" -> "configstoreclone:1_pre_notify_stop_0 node2" [ style = bold] "configstorecloneset_pre_notify_stop_0" -> "configstorecloneset_confirmed-pre_notify_stop_0" [ style = bold] "configstorecloneset_pre_notify_stop_0" [ style=bold color="green" fontcolor="orange" ] "configstorecloneset_stop_0" -> "configstoreclone:0_stop_0 node1" [ style = bold] "configstorecloneset_stop_0" -> "configstorecloneset_stopped_0" [ style = bold] "configstorecloneset_stop_0" [ style=bold color="green" fontcolor="orange" ] "configstorecloneset_stopped_0" -> "configstorecloneset_post_notify_stopped_0" [ style = bold] "configstorecloneset_stopped_0" [ style=bold color="green" fontcolor="orange" ] "evmsclone:0_confirmed-post_notify_stonith_0" -> "all_stopped" [ style = bold] "evmsclone:0_confirmed-post_notify_stonith_0" [ style=bold color="green" fontcolor="orange" ] "evmsclone:0_post_notify_stonith_0" -> "evmsclone:0_confirmed-post_notify_stonith_0" [ style = bold] "evmsclone:0_post_notify_stonith_0" -> "evmsclone:1_post_notify_stop_0 node2" [ style = bold] "evmsclone:0_post_notify_stonith_0" [ style=bold color="green" fontcolor="orange" ] "evmsclone:0_stop_0 node1" -> "all_stopped" [ style = bold] "evmsclone:0_stop_0 node1" -> "evmscloneset_stopped_0" [ style = bold] "evmsclone:0_stop_0 node1" [ style=bold color="green" fontcolor="orange" ] "evmsclone:1_post_notify_stop_0 node2" -> "evmsclone:0_confirmed-post_notify_stonith_0" [ style = bold] "evmsclone:1_post_notify_stop_0 node2" -> "evmscloneset_confirmed-post_notify_stopped_0" [ style = bold] "evmsclone:1_post_notify_stop_0 node2" [ style=bold color="green" fontcolor="black" ] "evmsclone:1_pre_notify_stop_0 node2" -> "evmscloneset_confirmed-pre_notify_stop_0" [ style = bold] "evmsclone:1_pre_notify_stop_0 node2" [ style=bold color="green" fontcolor="black" ] "evmscloneset_confirmed-post_notify_stopped_0" -> "all_stopped" [ style = bold] "evmscloneset_confirmed-post_notify_stopped_0" [ style=bold color="green" fontcolor="orange" ] "evmscloneset_confirmed-pre_notify_stop_0" -> "evmscloneset_post_notify_stopped_0" [ style = bold] "evmscloneset_confirmed-pre_notify_stop_0" -> "evmscloneset_stop_0" [ style = bold] "evmscloneset_confirmed-pre_notify_stop_0" [ style=bold color="green" fontcolor="orange" ] "evmscloneset_post_notify_stopped_0" -> "evmsclone:1_post_notify_stop_0 node2" [ style = bold] "evmscloneset_post_notify_stopped_0" -> "evmscloneset_confirmed-post_notify_stopped_0" [ style = bold] "evmscloneset_post_notify_stopped_0" [ style=bold color="green" fontcolor="orange" ] "evmscloneset_pre_notify_stop_0" -> "evmsclone:1_pre_notify_stop_0 node2" [ style = bold] "evmscloneset_pre_notify_stop_0" -> "evmscloneset_confirmed-pre_notify_stop_0" [ style = bold] "evmscloneset_pre_notify_stop_0" [ style=bold color="green" fontcolor="orange" ] "evmscloneset_stop_0" -> "evmsclone:0_stop_0 node1" [ style = bold] "evmscloneset_stop_0" -> "evmscloneset_stopped_0" [ style = bold] "evmscloneset_stop_0" [ style=bold color="green" fontcolor="orange" ] "evmscloneset_stopped_0" -> "evmscloneset_post_notify_stopped_0" [ style = bold] "evmscloneset_stopped_0" [ style=bold color="green" fontcolor="orange" ] "imagestoreclone:0_confirmed-post_notify_stonith_0" -> "all_stopped" [ style = bold] "imagestoreclone:0_confirmed-post_notify_stonith_0" [ style=bold color="green" fontcolor="orange" ] "imagestoreclone:0_post_notify_stonith_0" -> "imagestoreclone:0_confirmed-post_notify_stonith_0" [ style = bold] "imagestoreclone:0_post_notify_stonith_0" -> "imagestoreclone:1_post_notify_stop_0 node2" [ style = bold] "imagestoreclone:0_post_notify_stonith_0" [ style=bold color="green" fontcolor="orange" ] "imagestoreclone:0_stop_0 node1" -> "all_stopped" [ style = bold] "imagestoreclone:0_stop_0 node1" -> "evmsclone:0_stop_0 node1" [ style = bold] "imagestoreclone:0_stop_0 node1" -> "imagestorecloneset_stopped_0" [ style = bold] "imagestoreclone:0_stop_0 node1" [ style=bold color="green" fontcolor="orange" ] "imagestoreclone:1_post_notify_stop_0 node2" -> "imagestoreclone:0_confirmed-post_notify_stonith_0" [ style = bold] "imagestoreclone:1_post_notify_stop_0 node2" -> "imagestorecloneset_confirmed-post_notify_stopped_0" [ style = bold] "imagestoreclone:1_post_notify_stop_0 node2" [ style=bold color="green" fontcolor="black" ] "imagestoreclone:1_pre_notify_stop_0 node2" -> "imagestorecloneset_confirmed-pre_notify_stop_0" [ style = bold] "imagestoreclone:1_pre_notify_stop_0 node2" [ style=bold color="green" fontcolor="black" ] "imagestorecloneset_confirmed-post_notify_stopped_0" -> "all_stopped" [ style = bold] "imagestorecloneset_confirmed-post_notify_stopped_0" -> "evmscloneset_stop_0" [ style = bold] "imagestorecloneset_confirmed-post_notify_stopped_0" [ style=bold color="green" fontcolor="orange" ] "imagestorecloneset_confirmed-pre_notify_stop_0" -> "imagestorecloneset_post_notify_stopped_0" [ style = bold] "imagestorecloneset_confirmed-pre_notify_stop_0" -> "imagestorecloneset_stop_0" [ style = bold] "imagestorecloneset_confirmed-pre_notify_stop_0" [ style=bold color="green" fontcolor="orange" ] "imagestorecloneset_post_notify_stopped_0" -> "imagestoreclone:1_post_notify_stop_0 node2" [ style = bold] "imagestorecloneset_post_notify_stopped_0" -> "imagestorecloneset_confirmed-post_notify_stopped_0" [ style = bold] "imagestorecloneset_post_notify_stopped_0" [ style=bold color="green" fontcolor="orange" ] "imagestorecloneset_pre_notify_stop_0" -> "imagestoreclone:1_pre_notify_stop_0 node2" [ style = bold] "imagestorecloneset_pre_notify_stop_0" -> "imagestorecloneset_confirmed-pre_notify_stop_0" [ style = bold] "imagestorecloneset_pre_notify_stop_0" [ style=bold color="green" fontcolor="orange" ] "imagestorecloneset_stop_0" -> "imagestoreclone:0_stop_0 node1" [ style = bold] "imagestorecloneset_stop_0" -> "imagestorecloneset_stopped_0" [ style = bold] "imagestorecloneset_stop_0" [ style=bold color="green" fontcolor="orange" ] "imagestorecloneset_stopped_0" -> "imagestorecloneset_post_notify_stopped_0" [ style = bold] "imagestorecloneset_stopped_0" [ style=bold color="green" fontcolor="orange" ] "stonith node1" -> "all_stopped" [ style = bold] "stonith node1" -> "configstoreclone:0_post_notify_stonith_0" [ style = bold] "stonith node1" -> "configstoreclone:0_stop_0 node1" [ style = bold] +"stonith node1" -> "configstorecloneset_stop_0" [ style = bold] "stonith node1" -> "evmsclone:0_post_notify_stonith_0" [ style = bold] "stonith node1" -> "evmsclone:0_stop_0 node1" [ style = bold] +"stonith node1" -> "evmscloneset_stop_0" [ style = bold] "stonith node1" -> "imagestoreclone:0_post_notify_stonith_0" [ style = bold] "stonith node1" -> "imagestoreclone:0_stop_0 node1" [ style = bold] +"stonith node1" -> "imagestorecloneset_stop_0" [ style = bold] "stonith node1" -> "stonith_complete" [ style = bold] "stonith node1" [ style=bold color="green" fontcolor="black" ] "stonith_complete" [ style=bold color="green" fontcolor="orange" ] "stonith_up" -> "stonith node1" [ style = bold] "stonith_up" -> "stonith_complete" [ style = bold] "stonith_up" [ style=bold color="green" fontcolor="orange" ] "stonithclone:0_stop_0 node1" -> "stonithcloneset_stopped_0" [ style = bold] "stonithclone:0_stop_0 node1" [ style=bold color="green" fontcolor="orange" ] "stonithcloneset_stop_0" -> "stonithclone:0_stop_0 node1" [ style = bold] "stonithcloneset_stop_0" -> "stonithcloneset_stopped_0" [ style = bold] "stonithcloneset_stop_0" [ style=bold color="green" fontcolor="orange" ] "stonithcloneset_stopped_0" [ style=bold color="green" fontcolor="orange" ] } diff --git a/pengine/test10/interleave-pseudo-stop.exp b/pengine/test10/interleave-pseudo-stop.exp index 224f7ecef1..346b27a383 100644 --- a/pengine/test10/interleave-pseudo-stop.exp +++ b/pengine/test10/interleave-pseudo-stop.exp @@ -1,577 +1,586 @@ + + + + + + + + + diff --git a/pengine/test10/master-7.dot b/pengine/test10/master-7.dot index 0881b61521..9a0791cc5c 100644 --- a/pengine/test10/master-7.dot +++ b/pengine/test10/master-7.dot @@ -1,139 +1,140 @@ digraph "g" { "DcIPaddr_monitor_5000 c001n03" [ style=bold color="green" fontcolor="black" ] "DcIPaddr_start_0 c001n03" -> "DcIPaddr_monitor_5000 c001n03" [ style = bold] "DcIPaddr_start_0 c001n03" [ style=bold color="green" fontcolor="black" ] "DcIPaddr_stop_0 c001n01" -> "DcIPaddr_start_0 c001n03" [ style = bold] "DcIPaddr_stop_0 c001n01" -> "all_stopped" [ style = bold] "DcIPaddr_stop_0 c001n01" [ style=bold color="green" fontcolor="orange" ] "DoFencing_stop_0" -> "DoFencing_stopped_0" [ style = bold] "DoFencing_stop_0" -> "child_DoFencing:0_stop_0 c001n01" [ style = bold] "DoFencing_stop_0" [ style=bold color="green" fontcolor="orange" ] "DoFencing_stopped_0" [ style=bold color="green" fontcolor="orange" ] "all_stopped" [ style=bold color="green" fontcolor="orange" ] "child_DoFencing:0_stop_0 c001n01" -> "DoFencing_stopped_0" [ style = bold] "child_DoFencing:0_stop_0 c001n01" [ style=bold color="green" fontcolor="orange" ] "child_DoFencing:2_monitor_0 c001n03" -> "probe_complete c001n03" [ style = bold] "child_DoFencing:2_monitor_0 c001n03" [ style=bold color="green" fontcolor="black" ] "child_DoFencing:2_monitor_0 c001n08" -> "probe_complete c001n08" [ style = bold] "child_DoFencing:2_monitor_0 c001n08" [ style=bold color="green" fontcolor="black" ] "child_DoFencing:3_monitor_0 c001n02" -> "probe_complete c001n02" [ style = bold] "child_DoFencing:3_monitor_0 c001n02" [ style=bold color="green" fontcolor="black" ] "child_DoFencing:3_monitor_0 c001n03" -> "probe_complete c001n03" [ style = bold] "child_DoFencing:3_monitor_0 c001n03" [ style=bold color="green" fontcolor="black" ] "group-1_running_0" [ style=bold color="green" fontcolor="orange" ] "group-1_start_0" -> "group-1_running_0" [ style = bold] "group-1_start_0" -> "heartbeat_192.168.100.182_start_0 c001n02" [ style = bold] "group-1_start_0" -> "ocf_192.168.100.181_start_0 c001n02" [ style = bold] "group-1_start_0" -> "ocf_192.168.100.183_start_0 c001n02" [ style = bold] "group-1_start_0" [ style=bold color="green" fontcolor="orange" ] "group-1_stop_0" -> "group-1_start_0" [ style = bold] "group-1_stop_0" -> "group-1_stopped_0" [ style = bold] "group-1_stop_0" -> "heartbeat_192.168.100.182_stop_0 c001n03" [ style = bold] "group-1_stop_0" -> "ocf_192.168.100.181_stop_0 c001n03" [ style = bold] "group-1_stop_0" -> "ocf_192.168.100.183_stop_0 c001n03" [ style = bold] "group-1_stop_0" [ style=bold color="green" fontcolor="orange" ] "group-1_stopped_0" -> "group-1_start_0" [ style = bold] "group-1_stopped_0" [ style=bold color="green" fontcolor="orange" ] "heartbeat_192.168.100.182_monitor_5000 c001n02" [ style=bold color="green" fontcolor="black" ] "heartbeat_192.168.100.182_start_0 c001n02" -> "group-1_running_0" [ style = bold] "heartbeat_192.168.100.182_start_0 c001n02" -> "heartbeat_192.168.100.182_monitor_5000 c001n02" [ style = bold] "heartbeat_192.168.100.182_start_0 c001n02" -> "ocf_192.168.100.183_start_0 c001n02" [ style = bold] "heartbeat_192.168.100.182_start_0 c001n02" [ style=bold color="green" fontcolor="black" ] "heartbeat_192.168.100.182_stop_0 c001n03" -> "all_stopped" [ style = bold] "heartbeat_192.168.100.182_stop_0 c001n03" -> "group-1_stopped_0" [ style = bold] "heartbeat_192.168.100.182_stop_0 c001n03" -> "heartbeat_192.168.100.182_start_0 c001n02" [ style = bold] "heartbeat_192.168.100.182_stop_0 c001n03" -> "ocf_192.168.100.181_stop_0 c001n03" [ style = bold] "heartbeat_192.168.100.182_stop_0 c001n03" [ style=bold color="green" fontcolor="black" ] "lsb_dummy_monitor_5000 c001n08" [ style=bold color="green" fontcolor="black" ] "lsb_dummy_start_0 c001n08" -> "lsb_dummy_monitor_5000 c001n08" [ style = bold] "lsb_dummy_start_0 c001n08" [ style=bold color="green" fontcolor="black" ] "lsb_dummy_stop_0 c001n02" -> "all_stopped" [ style = bold] "lsb_dummy_stop_0 c001n02" -> "lsb_dummy_start_0 c001n08" [ style = bold] "lsb_dummy_stop_0 c001n02" [ style=bold color="green" fontcolor="black" ] "master_rsc_1_demote_0" -> "master_rsc_1_demoted_0" [ style = bold] "master_rsc_1_demote_0" -> "master_rsc_1_stop_0" [ style = bold] "master_rsc_1_demote_0" -> "ocf_msdummy:0_demote_0 c001n01" [ style = bold] "master_rsc_1_demote_0" [ style=bold color="green" fontcolor="orange" ] "master_rsc_1_demoted_0" -> "master_rsc_1_stop_0" [ style = bold] "master_rsc_1_demoted_0" [ style=bold color="green" fontcolor="orange" ] "master_rsc_1_stop_0" -> "master_rsc_1_stopped_0" [ style = bold] "master_rsc_1_stop_0" -> "ocf_msdummy:0_stop_0 c001n01" [ style = bold] "master_rsc_1_stop_0" -> "ocf_msdummy:4_stop_0 c001n01" [ style = bold] "master_rsc_1_stop_0" [ style=bold color="green" fontcolor="orange" ] "master_rsc_1_stopped_0" [ style=bold color="green" fontcolor="orange" ] "ocf_192.168.100.181_monitor_5000 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_192.168.100.181_start_0 c001n02" -> "group-1_running_0" [ style = bold] "ocf_192.168.100.181_start_0 c001n02" -> "heartbeat_192.168.100.182_start_0 c001n02" [ style = bold] "ocf_192.168.100.181_start_0 c001n02" -> "ocf_192.168.100.181_monitor_5000 c001n02" [ style = bold] "ocf_192.168.100.181_start_0 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_192.168.100.181_stop_0 c001n03" -> "all_stopped" [ style = bold] "ocf_192.168.100.181_stop_0 c001n03" -> "group-1_stopped_0" [ style = bold] "ocf_192.168.100.181_stop_0 c001n03" -> "ocf_192.168.100.181_start_0 c001n02" [ style = bold] "ocf_192.168.100.181_stop_0 c001n03" [ style=bold color="green" fontcolor="black" ] "ocf_192.168.100.183_monitor_5000 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_192.168.100.183_start_0 c001n02" -> "group-1_running_0" [ style = bold] "ocf_192.168.100.183_start_0 c001n02" -> "ocf_192.168.100.183_monitor_5000 c001n02" [ style = bold] "ocf_192.168.100.183_start_0 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_192.168.100.183_stop_0 c001n03" -> "all_stopped" [ style = bold] "ocf_192.168.100.183_stop_0 c001n03" -> "group-1_stopped_0" [ style = bold] "ocf_192.168.100.183_stop_0 c001n03" -> "heartbeat_192.168.100.182_stop_0 c001n03" [ style = bold] "ocf_192.168.100.183_stop_0 c001n03" -> "ocf_192.168.100.183_start_0 c001n02" [ style = bold] "ocf_192.168.100.183_stop_0 c001n03" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:0_demote_0 c001n01" -> "master_rsc_1_demoted_0" [ style = bold] "ocf_msdummy:0_demote_0 c001n01" -> "ocf_msdummy:0_stop_0 c001n01" [ style = bold] "ocf_msdummy:0_demote_0 c001n01" [ style=bold color="green" fontcolor="orange" ] "ocf_msdummy:0_stop_0 c001n01" -> "all_stopped" [ style = bold] "ocf_msdummy:0_stop_0 c001n01" -> "master_rsc_1_stopped_0" [ style = bold] "ocf_msdummy:0_stop_0 c001n01" [ style=bold color="green" fontcolor="orange" ] "ocf_msdummy:4_monitor_0 c001n02" -> "probe_complete c001n02" [ style = bold] "ocf_msdummy:4_monitor_0 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:4_monitor_0 c001n03" -> "probe_complete c001n03" [ style = bold] "ocf_msdummy:4_monitor_0 c001n03" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:4_monitor_0 c001n08" -> "probe_complete c001n08" [ style = bold] "ocf_msdummy:4_monitor_0 c001n08" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:4_stop_0 c001n01" -> "all_stopped" [ style = bold] "ocf_msdummy:4_stop_0 c001n01" -> "master_rsc_1_stopped_0" [ style = bold] "ocf_msdummy:4_stop_0 c001n01" [ style=bold color="green" fontcolor="orange" ] "ocf_msdummy:5_monitor_0 c001n02" -> "probe_complete c001n02" [ style = bold] "ocf_msdummy:5_monitor_0 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:5_monitor_0 c001n08" -> "probe_complete c001n08" [ style = bold] "ocf_msdummy:5_monitor_0 c001n08" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:6_monitor_0 c001n03" -> "probe_complete c001n03" [ style = bold] "ocf_msdummy:6_monitor_0 c001n03" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:6_monitor_0 c001n08" -> "probe_complete c001n08" [ style = bold] "ocf_msdummy:6_monitor_0 c001n08" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:7_monitor_0 c001n02" -> "probe_complete c001n02" [ style = bold] "ocf_msdummy:7_monitor_0 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:7_monitor_0 c001n03" -> "probe_complete c001n03" [ style = bold] "ocf_msdummy:7_monitor_0 c001n03" [ style=bold color="green" fontcolor="black" ] "probe_complete c001n02" -> "probe_complete" [ style = bold] "probe_complete c001n02" [ style=bold color="green" fontcolor="black" ] "probe_complete c001n03" -> "probe_complete" [ style = bold] "probe_complete c001n03" [ style=bold color="green" fontcolor="black" ] "probe_complete c001n08" -> "probe_complete" [ style = bold] "probe_complete c001n08" [ style=bold color="green" fontcolor="black" ] "probe_complete" -> "DoFencing_stop_0" [ style = bold] "probe_complete" -> "child_DoFencing:0_stop_0 c001n01" [ style = bold] "probe_complete" -> "master_rsc_1_stop_0" [ style = bold] "probe_complete" -> "ocf_msdummy:0_stop_0 c001n01" [ style = bold] "probe_complete" -> "ocf_msdummy:4_stop_0 c001n01" [ style = bold] "probe_complete" [ style=bold color="green" fontcolor="orange" ] "rsc_c001n01_monitor_5000 c001n03" [ style=bold color="green" fontcolor="black" ] "rsc_c001n01_start_0 c001n03" -> "rsc_c001n01_monitor_5000 c001n03" [ style = bold] "rsc_c001n01_start_0 c001n03" [ style=bold color="green" fontcolor="black" ] "rsc_c001n01_stop_0 c001n01" -> "all_stopped" [ style = bold] "rsc_c001n01_stop_0 c001n01" -> "rsc_c001n01_start_0 c001n03" [ style = bold] "rsc_c001n01_stop_0 c001n01" [ style=bold color="green" fontcolor="orange" ] "stonith c001n01" -> "DcIPaddr_stop_0 c001n01" [ style = bold] "stonith c001n01" -> "all_stopped" [ style = bold] +"stonith c001n01" -> "master_rsc_1_stop_0" [ style = bold] "stonith c001n01" -> "ocf_msdummy:0_demote_0 c001n01" [ style = bold] "stonith c001n01" -> "ocf_msdummy:0_stop_0 c001n01" [ style = bold] "stonith c001n01" -> "ocf_msdummy:4_stop_0 c001n01" [ style = bold] "stonith c001n01" -> "rsc_c001n01_stop_0 c001n01" [ style = bold] "stonith c001n01" -> "stonith_complete" [ style = bold] "stonith c001n01" [ style=bold color="green" fontcolor="black" ] "stonith_complete" [ style=bold color="green" fontcolor="orange" ] "stonith_up" -> "stonith c001n01" [ style = bold] "stonith_up" -> "stonith_complete" [ style = bold] "stonith_up" [ style=bold color="green" fontcolor="orange" ] } diff --git a/pengine/test10/master-7.exp b/pengine/test10/master-7.exp index 626fbf3438..7dc807ceb3 100644 --- a/pengine/test10/master-7.exp +++ b/pengine/test10/master-7.exp @@ -1,748 +1,751 @@ + + + diff --git a/pengine/test10/master-8.dot b/pengine/test10/master-8.dot index 278c352205..f30565b4ba 100644 --- a/pengine/test10/master-8.dot +++ b/pengine/test10/master-8.dot @@ -1,150 +1,151 @@ digraph "g" { "DcIPaddr_monitor_5000 c001n03" [ style=bold color="green" fontcolor="black" ] "DcIPaddr_start_0 c001n03" -> "DcIPaddr_monitor_5000 c001n03" [ style = bold] "DcIPaddr_start_0 c001n03" [ style=bold color="green" fontcolor="black" ] "DcIPaddr_stop_0 c001n01" -> "DcIPaddr_start_0 c001n03" [ style = bold] "DcIPaddr_stop_0 c001n01" -> "all_stopped" [ style = bold] "DcIPaddr_stop_0 c001n01" [ style=bold color="green" fontcolor="orange" ] "DoFencing_stop_0" -> "DoFencing_stopped_0" [ style = bold] "DoFencing_stop_0" -> "child_DoFencing:0_stop_0 c001n01" [ style = bold] "DoFencing_stop_0" [ style=bold color="green" fontcolor="orange" ] "DoFencing_stopped_0" [ style=bold color="green" fontcolor="orange" ] "all_stopped" [ style=bold color="green" fontcolor="orange" ] "child_DoFencing:0_stop_0 c001n01" -> "DoFencing_stopped_0" [ style = bold] "child_DoFencing:0_stop_0 c001n01" [ style=bold color="green" fontcolor="orange" ] "child_DoFencing:2_monitor_0 c001n03" -> "probe_complete c001n03" [ style = bold] "child_DoFencing:2_monitor_0 c001n03" [ style=bold color="green" fontcolor="black" ] "child_DoFencing:2_monitor_0 c001n08" -> "probe_complete c001n08" [ style = bold] "child_DoFencing:2_monitor_0 c001n08" [ style=bold color="green" fontcolor="black" ] "child_DoFencing:3_monitor_0 c001n02" -> "probe_complete c001n02" [ style = bold] "child_DoFencing:3_monitor_0 c001n02" [ style=bold color="green" fontcolor="black" ] "child_DoFencing:3_monitor_0 c001n03" -> "probe_complete c001n03" [ style = bold] "child_DoFencing:3_monitor_0 c001n03" [ style=bold color="green" fontcolor="black" ] "group-1_running_0" [ style=bold color="green" fontcolor="orange" ] "group-1_start_0" -> "group-1_running_0" [ style = bold] "group-1_start_0" -> "heartbeat_192.168.100.182_start_0 c001n02" [ style = bold] "group-1_start_0" -> "ocf_192.168.100.181_start_0 c001n02" [ style = bold] "group-1_start_0" -> "ocf_192.168.100.183_start_0 c001n02" [ style = bold] "group-1_start_0" [ style=bold color="green" fontcolor="orange" ] "group-1_stop_0" -> "group-1_start_0" [ style = bold] "group-1_stop_0" -> "group-1_stopped_0" [ style = bold] "group-1_stop_0" -> "heartbeat_192.168.100.182_stop_0 c001n03" [ style = bold] "group-1_stop_0" -> "ocf_192.168.100.181_stop_0 c001n03" [ style = bold] "group-1_stop_0" -> "ocf_192.168.100.183_stop_0 c001n03" [ style = bold] "group-1_stop_0" [ style=bold color="green" fontcolor="orange" ] "group-1_stopped_0" -> "group-1_start_0" [ style = bold] "group-1_stopped_0" [ style=bold color="green" fontcolor="orange" ] "heartbeat_192.168.100.182_monitor_5000 c001n02" [ style=bold color="green" fontcolor="black" ] "heartbeat_192.168.100.182_start_0 c001n02" -> "group-1_running_0" [ style = bold] "heartbeat_192.168.100.182_start_0 c001n02" -> "heartbeat_192.168.100.182_monitor_5000 c001n02" [ style = bold] "heartbeat_192.168.100.182_start_0 c001n02" -> "ocf_192.168.100.183_start_0 c001n02" [ style = bold] "heartbeat_192.168.100.182_start_0 c001n02" [ style=bold color="green" fontcolor="black" ] "heartbeat_192.168.100.182_stop_0 c001n03" -> "all_stopped" [ style = bold] "heartbeat_192.168.100.182_stop_0 c001n03" -> "group-1_stopped_0" [ style = bold] "heartbeat_192.168.100.182_stop_0 c001n03" -> "heartbeat_192.168.100.182_start_0 c001n02" [ style = bold] "heartbeat_192.168.100.182_stop_0 c001n03" -> "ocf_192.168.100.181_stop_0 c001n03" [ style = bold] "heartbeat_192.168.100.182_stop_0 c001n03" [ style=bold color="green" fontcolor="black" ] "lsb_dummy_monitor_5000 c001n08" [ style=bold color="green" fontcolor="black" ] "lsb_dummy_start_0 c001n08" -> "lsb_dummy_monitor_5000 c001n08" [ style = bold] "lsb_dummy_start_0 c001n08" [ style=bold color="green" fontcolor="black" ] "lsb_dummy_stop_0 c001n02" -> "all_stopped" [ style = bold] "lsb_dummy_stop_0 c001n02" -> "lsb_dummy_start_0 c001n08" [ style = bold] "lsb_dummy_stop_0 c001n02" [ style=bold color="green" fontcolor="black" ] "master_rsc_1_demote_0" -> "master_rsc_1_demoted_0" [ style = bold] "master_rsc_1_demote_0" -> "master_rsc_1_stop_0" [ style = bold] "master_rsc_1_demote_0" -> "ocf_msdummy:0_demote_0 c001n01" [ style = bold] "master_rsc_1_demote_0" [ style=bold color="green" fontcolor="orange" ] "master_rsc_1_demoted_0" -> "master_rsc_1_start_0" [ style = bold] "master_rsc_1_demoted_0" -> "master_rsc_1_stop_0" [ style = bold] "master_rsc_1_demoted_0" [ style=bold color="green" fontcolor="orange" ] "master_rsc_1_running_0" [ style=bold color="green" fontcolor="orange" ] "master_rsc_1_start_0" -> "master_rsc_1_running_0" [ style = bold] "master_rsc_1_start_0" -> "ocf_msdummy:0_start_0 c001n03" [ style = bold] "master_rsc_1_start_0" [ style=bold color="green" fontcolor="orange" ] "master_rsc_1_stop_0" -> "master_rsc_1_start_0" [ style = bold] "master_rsc_1_stop_0" -> "master_rsc_1_stopped_0" [ style = bold] "master_rsc_1_stop_0" -> "ocf_msdummy:0_stop_0 c001n01" [ style = bold] "master_rsc_1_stop_0" [ style=bold color="green" fontcolor="orange" ] "master_rsc_1_stopped_0" -> "master_rsc_1_start_0" [ style = bold] "master_rsc_1_stopped_0" [ style=bold color="green" fontcolor="orange" ] "ocf_192.168.100.181_monitor_5000 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_192.168.100.181_start_0 c001n02" -> "group-1_running_0" [ style = bold] "ocf_192.168.100.181_start_0 c001n02" -> "heartbeat_192.168.100.182_start_0 c001n02" [ style = bold] "ocf_192.168.100.181_start_0 c001n02" -> "ocf_192.168.100.181_monitor_5000 c001n02" [ style = bold] "ocf_192.168.100.181_start_0 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_192.168.100.181_stop_0 c001n03" -> "all_stopped" [ style = bold] "ocf_192.168.100.181_stop_0 c001n03" -> "group-1_stopped_0" [ style = bold] "ocf_192.168.100.181_stop_0 c001n03" -> "ocf_192.168.100.181_start_0 c001n02" [ style = bold] "ocf_192.168.100.181_stop_0 c001n03" [ style=bold color="green" fontcolor="black" ] "ocf_192.168.100.183_monitor_5000 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_192.168.100.183_start_0 c001n02" -> "group-1_running_0" [ style = bold] "ocf_192.168.100.183_start_0 c001n02" -> "ocf_192.168.100.183_monitor_5000 c001n02" [ style = bold] "ocf_192.168.100.183_start_0 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_192.168.100.183_stop_0 c001n03" -> "all_stopped" [ style = bold] "ocf_192.168.100.183_stop_0 c001n03" -> "group-1_stopped_0" [ style = bold] "ocf_192.168.100.183_stop_0 c001n03" -> "heartbeat_192.168.100.182_stop_0 c001n03" [ style = bold] "ocf_192.168.100.183_stop_0 c001n03" -> "ocf_192.168.100.183_start_0 c001n02" [ style = bold] "ocf_192.168.100.183_stop_0 c001n03" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:0_demote_0 c001n01" -> "master_rsc_1_demoted_0" [ style = bold] "ocf_msdummy:0_demote_0 c001n01" -> "ocf_msdummy:0_monitor_5000 c001n03" [ style = bold] "ocf_msdummy:0_demote_0 c001n01" -> "ocf_msdummy:0_stop_0 c001n01" [ style = bold] "ocf_msdummy:0_demote_0 c001n01" [ style=bold color="green" fontcolor="orange" ] "ocf_msdummy:0_monitor_5000 c001n03" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:0_start_0 c001n03" -> "master_rsc_1_running_0" [ style = bold] "ocf_msdummy:0_start_0 c001n03" -> "ocf_msdummy:0_monitor_5000 c001n03" [ style = bold] "ocf_msdummy:0_start_0 c001n03" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:0_stop_0 c001n01" -> "all_stopped" [ style = bold] "ocf_msdummy:0_stop_0 c001n01" -> "master_rsc_1_stopped_0" [ style = bold] "ocf_msdummy:0_stop_0 c001n01" -> "ocf_msdummy:0_start_0 c001n03" [ style = bold] "ocf_msdummy:0_stop_0 c001n01" [ style=bold color="green" fontcolor="orange" ] "ocf_msdummy:4_monitor_0 c001n02" -> "probe_complete c001n02" [ style = bold] "ocf_msdummy:4_monitor_0 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:4_monitor_0 c001n03" -> "probe_complete c001n03" [ style = bold] "ocf_msdummy:4_monitor_0 c001n03" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:4_monitor_0 c001n08" -> "probe_complete c001n08" [ style = bold] "ocf_msdummy:4_monitor_0 c001n08" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:5_monitor_0 c001n02" -> "probe_complete c001n02" [ style = bold] "ocf_msdummy:5_monitor_0 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:5_monitor_0 c001n03" -> "probe_complete c001n03" [ style = bold] "ocf_msdummy:5_monitor_0 c001n03" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:5_monitor_0 c001n08" -> "probe_complete c001n08" [ style = bold] "ocf_msdummy:5_monitor_0 c001n08" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:6_monitor_0 c001n03" -> "probe_complete c001n03" [ style = bold] "ocf_msdummy:6_monitor_0 c001n03" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:6_monitor_0 c001n08" -> "probe_complete c001n08" [ style = bold] "ocf_msdummy:6_monitor_0 c001n08" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:7_monitor_0 c001n02" -> "probe_complete c001n02" [ style = bold] "ocf_msdummy:7_monitor_0 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:7_monitor_0 c001n03" -> "probe_complete c001n03" [ style = bold] "ocf_msdummy:7_monitor_0 c001n03" [ style=bold color="green" fontcolor="black" ] "probe_complete c001n02" -> "probe_complete" [ style = bold] "probe_complete c001n02" [ style=bold color="green" fontcolor="black" ] "probe_complete c001n03" -> "probe_complete" [ style = bold] "probe_complete c001n03" [ style=bold color="green" fontcolor="black" ] "probe_complete c001n08" -> "probe_complete" [ style = bold] "probe_complete c001n08" [ style=bold color="green" fontcolor="black" ] "probe_complete" -> "DoFencing_stop_0" [ style = bold] "probe_complete" -> "child_DoFencing:0_stop_0 c001n01" [ style = bold] "probe_complete" -> "master_rsc_1_start_0" [ style = bold] "probe_complete" -> "master_rsc_1_stop_0" [ style = bold] "probe_complete" -> "ocf_msdummy:0_start_0 c001n03" [ style = bold] "probe_complete" -> "ocf_msdummy:0_stop_0 c001n01" [ style = bold] "probe_complete" [ style=bold color="green" fontcolor="orange" ] "rsc_c001n01_monitor_5000 c001n03" [ style=bold color="green" fontcolor="black" ] "rsc_c001n01_start_0 c001n03" -> "rsc_c001n01_monitor_5000 c001n03" [ style = bold] "rsc_c001n01_start_0 c001n03" [ style=bold color="green" fontcolor="black" ] "rsc_c001n01_stop_0 c001n01" -> "all_stopped" [ style = bold] "rsc_c001n01_stop_0 c001n01" -> "rsc_c001n01_start_0 c001n03" [ style = bold] "rsc_c001n01_stop_0 c001n01" [ style=bold color="green" fontcolor="orange" ] "stonith c001n01" -> "DcIPaddr_stop_0 c001n01" [ style = bold] "stonith c001n01" -> "all_stopped" [ style = bold] +"stonith c001n01" -> "master_rsc_1_stop_0" [ style = bold] "stonith c001n01" -> "ocf_msdummy:0_demote_0 c001n01" [ style = bold] "stonith c001n01" -> "ocf_msdummy:0_stop_0 c001n01" [ style = bold] "stonith c001n01" -> "rsc_c001n01_stop_0 c001n01" [ style = bold] "stonith c001n01" -> "stonith_complete" [ style = bold] "stonith c001n01" [ style=bold color="green" fontcolor="black" ] "stonith_complete" [ style=bold color="green" fontcolor="orange" ] "stonith_up" -> "stonith c001n01" [ style = bold] "stonith_up" -> "stonith_complete" [ style = bold] "stonith_up" [ style=bold color="green" fontcolor="orange" ] } diff --git a/pengine/test10/master-8.exp b/pengine/test10/master-8.exp index af767c78a7..88bc161748 100644 --- a/pengine/test10/master-8.exp +++ b/pengine/test10/master-8.exp @@ -1,807 +1,810 @@ + + + diff --git a/pengine/test10/master-group.scores b/pengine/test10/master-group.scores index 88cb4c87ff..16636b9302 100644 --- a/pengine/test10/master-group.scores +++ b/pengine/test10/master-group.scores @@ -1,31 +1,31 @@ Allocation scores: -group_color: test allocation score on rh44-1: 0 -group_color: test allocation score on rh44-2: 0 +group_color: test allocation score on rh44-1: 200 +group_color: test allocation score on rh44-2: 100 group_color: resource_1 allocation score on rh44-1: 1000000 group_color: resource_1 allocation score on rh44-2: 100 native_color: resource_1 allocation score on rh44-1: 1000000 native_color: resource_1 allocation score on rh44-2: 100 clone_color: ms-sf allocation score on rh44-1: 0 clone_color: ms-sf allocation score on rh44-2: 0 clone_color: grp_ms_sf:0 allocation score on rh44-1: 0 clone_color: grp_ms_sf:0 allocation score on rh44-2: 0 clone_color: master_slave_Stateful:0 allocation score on rh44-1: 0 clone_color: master_slave_Stateful:0 allocation score on rh44-2: 1 clone_color: grp_ms_sf:1 allocation score on rh44-1: 0 clone_color: grp_ms_sf:1 allocation score on rh44-2: 0 clone_color: master_slave_Stateful:1 allocation score on rh44-1: 1 clone_color: master_slave_Stateful:1 allocation score on rh44-2: 0 group_color: grp_ms_sf:0 allocation score on rh44-1: 0 group_color: grp_ms_sf:0 allocation score on rh44-2: 0 group_color: master_slave_Stateful:0 allocation score on rh44-1: 0 group_color: master_slave_Stateful:0 allocation score on rh44-2: 1 native_color: master_slave_Stateful:0 allocation score on rh44-1: 0 native_color: master_slave_Stateful:0 allocation score on rh44-2: 1 group_color: grp_ms_sf:1 allocation score on rh44-1: 0 group_color: grp_ms_sf:1 allocation score on rh44-2: -1000000 group_color: master_slave_Stateful:1 allocation score on rh44-1: 1 group_color: master_slave_Stateful:1 allocation score on rh44-2: -1000000 native_color: master_slave_Stateful:1 allocation score on rh44-1: 1 native_color: master_slave_Stateful:1 allocation score on rh44-2: -1000000 grp_ms_sf:1 promotion score on rh44-1: 99 grp_ms_sf:0 promotion score on rh44-2: 49 diff --git a/pengine/test10/master-ordering.scores b/pengine/test10/master-ordering.scores index a732c9e5fb..a2e86c2598 100644 --- a/pengine/test10/master-ordering.scores +++ b/pengine/test10/master-ordering.scores @@ -1,93 +1,93 @@ Allocation scores: clone_color: ms_drbd_mysql allocation score on webcluster01: 100 clone_color: ms_drbd_mysql allocation score on webcluster02: -1000000 clone_color: drbd_mysql:0 allocation score on webcluster01: 0 clone_color: drbd_mysql:0 allocation score on webcluster02: 0 clone_color: drbd_mysql:1 allocation score on webcluster01: 0 clone_color: drbd_mysql:1 allocation score on webcluster02: 0 native_color: drbd_mysql:0 allocation score on webcluster01: 0 native_color: drbd_mysql:0 allocation score on webcluster02: -1000000 native_color: drbd_mysql:1 allocation score on webcluster01: -1000000 native_color: drbd_mysql:1 allocation score on webcluster02: -1000000 drbd_mysql:1 promotion score on none: 0 drbd_mysql:0 promotion score on webcluster01: -1 native_color: fs_mysql allocation score on webcluster01: -1000000 native_color: fs_mysql allocation score on webcluster02: -1000000 native_color: mysql-server allocation score on webcluster01: -1000000 native_color: mysql-server allocation score on webcluster02: -1000000 native_color: extip_1 allocation score on webcluster01: 100 native_color: extip_1 allocation score on webcluster02: 0 native_color: extip_2 allocation score on webcluster01: 0 native_color: extip_2 allocation score on webcluster02: 100 -group_color: group_main allocation score on webcluster01: 0 +group_color: group_main allocation score on webcluster01: 100 group_color: group_main allocation score on webcluster02: 0 group_color: intip_0_main allocation score on webcluster01: 100 group_color: intip_0_main allocation score on webcluster02: 0 native_color: intip_0_main allocation score on webcluster01: -1000000 native_color: intip_0_main allocation score on webcluster02: -1000000 native_color: intip_1_master allocation score on webcluster01: 200 native_color: intip_1_master allocation score on webcluster02: 0 native_color: intip_2_slave allocation score on webcluster01: 0 native_color: intip_2_slave allocation score on webcluster02: 100 clone_color: ms_drbd_www allocation score on webcluster01: 0 clone_color: ms_drbd_www allocation score on webcluster02: -1000000 clone_color: drbd_www:0 allocation score on webcluster01: 0 clone_color: drbd_www:0 allocation score on webcluster02: 0 clone_color: drbd_www:1 allocation score on webcluster01: 0 clone_color: drbd_www:1 allocation score on webcluster02: 0 native_color: drbd_www:0 allocation score on webcluster01: 0 native_color: drbd_www:0 allocation score on webcluster02: -1000000 native_color: drbd_www:1 allocation score on webcluster01: -1000000 native_color: drbd_www:1 allocation score on webcluster02: -1000000 drbd_www:1 promotion score on none: 0 drbd_www:0 promotion score on webcluster01: -1 clone_color: clone_ocfs2_www allocation score on webcluster01: 0 clone_color: clone_ocfs2_www allocation score on webcluster02: -1000000 clone_color: ocfs2_www:0 allocation score on webcluster01: 0 clone_color: ocfs2_www:0 allocation score on webcluster02: 0 clone_color: ocfs2_www:1 allocation score on webcluster01: 0 clone_color: ocfs2_www:1 allocation score on webcluster02: 0 drbd_www:1 promotion score on none: 0 drbd_www:0 promotion score on webcluster01: -1000000 native_color: ocfs2_www:0 allocation score on webcluster01: -1000000 native_color: ocfs2_www:0 allocation score on webcluster02: -1000000 drbd_www:1 promotion score on none: 0 drbd_www:0 promotion score on webcluster01: -1000000 native_color: ocfs2_www:1 allocation score on webcluster01: -1000000 native_color: ocfs2_www:1 allocation score on webcluster02: -1000000 clone_color: clone_webservice allocation score on webcluster01: 0 clone_color: clone_webservice allocation score on webcluster02: 0 clone_color: group_webservice:0 allocation score on webcluster01: 0 clone_color: group_webservice:0 allocation score on webcluster02: 0 clone_color: apache2:0 allocation score on webcluster01: 0 clone_color: apache2:0 allocation score on webcluster02: 0 clone_color: mysql-proxy:0 allocation score on webcluster01: 0 clone_color: mysql-proxy:0 allocation score on webcluster02: 0 clone_color: group_webservice:1 allocation score on webcluster01: 0 clone_color: group_webservice:1 allocation score on webcluster02: 0 clone_color: apache2:1 allocation score on webcluster01: 0 clone_color: apache2:1 allocation score on webcluster02: 0 clone_color: mysql-proxy:1 allocation score on webcluster01: 0 clone_color: mysql-proxy:1 allocation score on webcluster02: 0 group_color: group_webservice:0 allocation score on webcluster01: 0 group_color: group_webservice:0 allocation score on webcluster02: -1000000 group_color: apache2:0 allocation score on webcluster01: 0 group_color: apache2:0 allocation score on webcluster02: -1000000 group_color: mysql-proxy:0 allocation score on webcluster01: 0 group_color: mysql-proxy:0 allocation score on webcluster02: -1000000 native_color: apache2:0 allocation score on webcluster01: -1000000 native_color: apache2:0 allocation score on webcluster02: -1000000 native_color: mysql-proxy:0 allocation score on webcluster01: -1000000 native_color: mysql-proxy:0 allocation score on webcluster02: -1000000 group_color: group_webservice:1 allocation score on webcluster01: 0 group_color: group_webservice:1 allocation score on webcluster02: -1000000 group_color: apache2:1 allocation score on webcluster01: 0 group_color: apache2:1 allocation score on webcluster02: -1000000 group_color: mysql-proxy:1 allocation score on webcluster01: 0 group_color: mysql-proxy:1 allocation score on webcluster02: -1000000 native_color: apache2:1 allocation score on webcluster01: -1000000 native_color: apache2:1 allocation score on webcluster02: -1000000 native_color: mysql-proxy:1 allocation score on webcluster01: -1000000 native_color: mysql-proxy:1 allocation score on webcluster02: -1000000 drbd_mysql:1 promotion score on none: 0 drbd_mysql:0 promotion score on webcluster01: -1000000 diff --git a/pengine/test10/master-reattach.scores b/pengine/test10/master-reattach.scores index 8f03a40f63..43154f340b 100644 --- a/pengine/test10/master-reattach.scores +++ b/pengine/test10/master-reattach.scores @@ -1,29 +1,29 @@ Allocation scores: clone_color: ms-drbd1 allocation score on dktest1: 1000000 clone_color: ms-drbd1 allocation score on dktest2: 0 clone_color: drbd1:0 allocation score on dktest1: 1000000 clone_color: drbd1:0 allocation score on dktest2: 0 clone_color: drbd1:1 allocation score on dktest1: 0 clone_color: drbd1:1 allocation score on dktest2: 1000000 native_color: drbd1:0 allocation score on dktest1: 1000000 native_color: drbd1:0 allocation score on dktest2: 0 native_color: drbd1:1 allocation score on dktest1: -1000000 native_color: drbd1:1 allocation score on dktest2: 1000000 drbd1:0 promotion score on dktest1: 1000000 drbd1:1 promotion score on dktest2: -1 -group_color: apache allocation score on dktest1: 0 +group_color: apache allocation score on dktest1: 500 group_color: apache allocation score on dktest2: 0 group_color: apache-vip allocation score on dktest1: 1000000 group_color: apache-vip allocation score on dktest2: 0 group_color: mount allocation score on dktest1: 1000000 group_color: mount allocation score on dktest2: 0 group_color: webserver allocation score on dktest1: 1000000 group_color: webserver allocation score on dktest2: 0 drbd1:0 promotion score on dktest1: 1000000 drbd1:1 promotion score on dktest2: -1000000 native_color: apache-vip allocation score on dktest1: 1000000 native_color: apache-vip allocation score on dktest2: -1000000 native_color: mount allocation score on dktest1: 1000000 native_color: mount allocation score on dktest2: -1000000 native_color: webserver allocation score on dktest1: 1000000 native_color: webserver allocation score on dktest2: -1000000 diff --git a/pengine/test10/order-clone.dot b/pengine/test10/order-clone.dot new file mode 100644 index 0000000000..8abcf0e79f --- /dev/null +++ b/pengine/test10/order-clone.dot @@ -0,0 +1,114 @@ +digraph "g" { +"clvm-clone_running_0" -> "vg1-clone_start_0" [ style = dashed] +"clvm-clone_running_0" [ style=dashed color="red" fontcolor="orange" ] +"clvm-clone_start_0" -> "clvm-clone_running_0" [ style = dashed] +"clvm-clone_start_0" -> "clvm:0_start_0 hex-8" [ style = dashed] +"clvm-clone_start_0" -> "clvm:1_start_0 hex-9" [ style = dashed] +"clvm-clone_start_0" -> "clvm:2_start_0 hex-0" [ style = dashed] +"clvm-clone_start_0" -> "clvm:3_start_0 hex-7" [ style = dashed] +"clvm-clone_start_0" [ style=dashed color="red" fontcolor="orange" ] +"clvm:0_start_0 hex-8" -> "clvm-clone_running_0" [ style = dashed] +"clvm:0_start_0 hex-8" -> "clvm:1_start_0 hex-9" [ style = dashed] +"clvm:0_start_0 hex-8" -> "vg1:0_start_0 hex-8" [ style = dashed] +"clvm:0_start_0 hex-8" [ style=dashed color="red" fontcolor="black" ] +"clvm:1_start_0 hex-9" -> "clvm-clone_running_0" [ style = dashed] +"clvm:1_start_0 hex-9" -> "clvm:2_start_0 hex-0" [ style = dashed] +"clvm:1_start_0 hex-9" -> "vg1:1_start_0 hex-9" [ style = dashed] +"clvm:1_start_0 hex-9" [ style=dashed color="red" fontcolor="black" ] +"clvm:2_start_0 hex-0" -> "clvm-clone_running_0" [ style = dashed] +"clvm:2_start_0 hex-0" -> "clvm:3_start_0 hex-7" [ style = dashed] +"clvm:2_start_0 hex-0" -> "vg1:2_start_0 hex-0" [ style = dashed] +"clvm:2_start_0 hex-0" [ style=dashed color="red" fontcolor="black" ] +"clvm:3_start_0 hex-7" -> "clvm-clone_running_0" [ style = dashed] +"clvm:3_start_0 hex-7" -> "vg1:3_start_0 hex-7" [ style = dashed] +"clvm:3_start_0 hex-7" [ style=dashed color="red" fontcolor="black" ] +"fencing-sbd_start_0 hex-7" [ style=bold color="green" fontcolor="black" ] +"fs1-clone_running_0" [ style=bold color="green" fontcolor="orange" ] +"fs1-clone_start_0" -> "fs1-clone_running_0" [ style = bold] +"fs1-clone_start_0" -> "ocfs2-1:0_start_0 hex-8" [ style = dashed] +"fs1-clone_start_0" -> "ocfs2-1:1_start_0 hex-9" [ style = dashed] +"fs1-clone_start_0" -> "ocfs2-1:2_start_0 hex-0" [ style = dashed] +"fs1-clone_start_0" -> "ocfs2-1:3_start_0 hex-7" [ style = dashed] +"fs1-clone_start_0" [ style=bold color="green" fontcolor="orange" ] +"fs2-clone_running_0" [ style=bold color="green" fontcolor="orange" ] +"fs2-clone_start_0" -> "fs2-clone_running_0" [ style = bold] +"fs2-clone_start_0" -> "ocfs2-2:0_start_0 hex-8" [ style = dashed] +"fs2-clone_start_0" -> "ocfs2-2:1_start_0 hex-9" [ style = dashed] +"fs2-clone_start_0" -> "ocfs2-2:2_start_0 hex-0" [ style = dashed] +"fs2-clone_start_0" -> "ocfs2-2:3_start_0 hex-7" [ style = dashed] +"fs2-clone_start_0" [ style=bold color="green" fontcolor="orange" ] +"o2cb-clone_running_0" [ style=dashed color="red" fontcolor="orange" ] +"o2cb-clone_start_0" -> "o2cb-clone_running_0" [ style = dashed] +"o2cb-clone_start_0" -> "o2cb:0_start_0 hex-8" [ style = dashed] +"o2cb-clone_start_0" -> "o2cb:1_start_0 hex-9" [ style = dashed] +"o2cb-clone_start_0" -> "o2cb:2_start_0 hex-0" [ style = dashed] +"o2cb-clone_start_0" -> "o2cb:3_start_0 hex-7" [ style = dashed] +"o2cb-clone_start_0" [ style=dashed color="red" fontcolor="orange" ] +"o2cb:0_start_0 hex-8" -> "o2cb-clone_running_0" [ style = dashed] +"o2cb:0_start_0 hex-8" -> "vg1:0_start_0 hex-8" [ style = dashed] +"o2cb:0_start_0 hex-8" [ style=dashed color="red" fontcolor="black" ] +"o2cb:1_start_0 hex-9" -> "o2cb-clone_running_0" [ style = dashed] +"o2cb:1_start_0 hex-9" -> "vg1:1_start_0 hex-9" [ style = dashed] +"o2cb:1_start_0 hex-9" [ style=dashed color="red" fontcolor="black" ] +"o2cb:2_start_0 hex-0" -> "o2cb-clone_running_0" [ style = dashed] +"o2cb:2_start_0 hex-0" -> "vg1:2_start_0 hex-0" [ style = dashed] +"o2cb:2_start_0 hex-0" [ style=dashed color="red" fontcolor="black" ] +"o2cb:3_start_0 hex-7" -> "o2cb-clone_running_0" [ style = dashed] +"o2cb:3_start_0 hex-7" -> "vg1:3_start_0 hex-7" [ style = dashed] +"o2cb:3_start_0 hex-7" [ style=dashed color="red" fontcolor="black" ] +"ocfs2-1:0_monitor_20000 hex-8" [ style=dashed color="red" fontcolor="black" ] +"ocfs2-1:0_start_0 hex-8" -> "fs1-clone_running_0" [ style = dashed] +"ocfs2-1:0_start_0 hex-8" -> "ocfs2-1:0_monitor_20000 hex-8" [ style = dashed] +"ocfs2-1:0_start_0 hex-8" -> "ocfs2-2:0_start_0 hex-8" [ style = dashed] +"ocfs2-1:0_start_0 hex-8" [ style=dashed color="red" fontcolor="black" ] +"ocfs2-1:1_monitor_20000 hex-9" [ style=dashed color="red" fontcolor="black" ] +"ocfs2-1:1_start_0 hex-9" -> "fs1-clone_running_0" [ style = dashed] +"ocfs2-1:1_start_0 hex-9" -> "ocfs2-1:1_monitor_20000 hex-9" [ style = dashed] +"ocfs2-1:1_start_0 hex-9" -> "ocfs2-2:1_start_0 hex-9" [ style = dashed] +"ocfs2-1:1_start_0 hex-9" [ style=dashed color="red" fontcolor="black" ] +"ocfs2-1:2_monitor_20000 hex-0" [ style=dashed color="red" fontcolor="black" ] +"ocfs2-1:2_start_0 hex-0" -> "fs1-clone_running_0" [ style = dashed] +"ocfs2-1:2_start_0 hex-0" -> "ocfs2-1:2_monitor_20000 hex-0" [ style = dashed] +"ocfs2-1:2_start_0 hex-0" -> "ocfs2-2:2_start_0 hex-0" [ style = dashed] +"ocfs2-1:2_start_0 hex-0" [ style=dashed color="red" fontcolor="black" ] +"ocfs2-1:3_monitor_20000 hex-7" [ style=dashed color="red" fontcolor="black" ] +"ocfs2-1:3_start_0 hex-7" -> "fs1-clone_running_0" [ style = dashed] +"ocfs2-1:3_start_0 hex-7" -> "ocfs2-1:3_monitor_20000 hex-7" [ style = dashed] +"ocfs2-1:3_start_0 hex-7" -> "ocfs2-2:3_start_0 hex-7" [ style = dashed] +"ocfs2-1:3_start_0 hex-7" [ style=dashed color="red" fontcolor="black" ] +"ocfs2-2:0_monitor_20000 hex-8" [ style=dashed color="red" fontcolor="black" ] +"ocfs2-2:0_start_0 hex-8" -> "fs2-clone_running_0" [ style = dashed] +"ocfs2-2:0_start_0 hex-8" -> "ocfs2-2:0_monitor_20000 hex-8" [ style = dashed] +"ocfs2-2:0_start_0 hex-8" [ style=dashed color="red" fontcolor="black" ] +"ocfs2-2:1_monitor_20000 hex-9" [ style=dashed color="red" fontcolor="black" ] +"ocfs2-2:1_start_0 hex-9" -> "fs2-clone_running_0" [ style = dashed] +"ocfs2-2:1_start_0 hex-9" -> "ocfs2-2:1_monitor_20000 hex-9" [ style = dashed] +"ocfs2-2:1_start_0 hex-9" [ style=dashed color="red" fontcolor="black" ] +"ocfs2-2:2_monitor_20000 hex-0" [ style=dashed color="red" fontcolor="black" ] +"ocfs2-2:2_start_0 hex-0" -> "fs2-clone_running_0" [ style = dashed] +"ocfs2-2:2_start_0 hex-0" -> "ocfs2-2:2_monitor_20000 hex-0" [ style = dashed] +"ocfs2-2:2_start_0 hex-0" [ style=dashed color="red" fontcolor="black" ] +"ocfs2-2:3_monitor_20000 hex-7" [ style=dashed color="red" fontcolor="black" ] +"ocfs2-2:3_start_0 hex-7" -> "fs2-clone_running_0" [ style = dashed] +"ocfs2-2:3_start_0 hex-7" -> "ocfs2-2:3_monitor_20000 hex-7" [ style = dashed] +"ocfs2-2:3_start_0 hex-7" [ style=dashed color="red" fontcolor="black" ] +"vg1-clone_running_0" [ style=dashed color="red" fontcolor="orange" ] +"vg1-clone_start_0" -> "vg1-clone_running_0" [ style = dashed] +"vg1-clone_start_0" -> "vg1:0_start_0 hex-8" [ style = dashed] +"vg1-clone_start_0" -> "vg1:1_start_0 hex-9" [ style = dashed] +"vg1-clone_start_0" -> "vg1:2_start_0 hex-0" [ style = dashed] +"vg1-clone_start_0" -> "vg1:3_start_0 hex-7" [ style = dashed] +"vg1-clone_start_0" [ style=dashed color="red" fontcolor="orange" ] +"vg1:0_start_0 hex-8" -> "ocfs2-1:0_start_0 hex-8" [ style = dashed] +"vg1:0_start_0 hex-8" -> "vg1-clone_running_0" [ style = dashed] +"vg1:0_start_0 hex-8" [ style=dashed color="red" fontcolor="black" ] +"vg1:1_start_0 hex-9" -> "ocfs2-1:1_start_0 hex-9" [ style = dashed] +"vg1:1_start_0 hex-9" -> "vg1-clone_running_0" [ style = dashed] +"vg1:1_start_0 hex-9" [ style=dashed color="red" fontcolor="black" ] +"vg1:2_start_0 hex-0" -> "ocfs2-1:2_start_0 hex-0" [ style = dashed] +"vg1:2_start_0 hex-0" -> "vg1-clone_running_0" [ style = dashed] +"vg1:2_start_0 hex-0" [ style=dashed color="red" fontcolor="black" ] +"vg1:3_start_0 hex-7" -> "ocfs2-1:3_start_0 hex-7" [ style = dashed] +"vg1:3_start_0 hex-7" -> "vg1-clone_running_0" [ style = dashed] +"vg1:3_start_0 hex-7" [ style=dashed color="red" fontcolor="black" ] +} diff --git a/pengine/test10/order-clone.exp b/pengine/test10/order-clone.exp new file mode 100644 index 0000000000..c30506e843 --- /dev/null +++ b/pengine/test10/order-clone.exp @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pengine/test10/order-clone.scores b/pengine/test10/order-clone.scores new file mode 100644 index 0000000000..133f19c2d4 --- /dev/null +++ b/pengine/test10/order-clone.scores @@ -0,0 +1,221 @@ +Allocation scores: +native_color: fencing-sbd allocation score on hex-7: 0 +native_color: fencing-sbd allocation score on hex-8: 0 +native_color: fencing-sbd allocation score on hex-9: 0 +native_color: fencing-sbd allocation score on hex-0: 0 +clone_color: o2cb-clone allocation score on hex-7: 0 +clone_color: o2cb-clone allocation score on hex-8: 0 +clone_color: o2cb-clone allocation score on hex-9: 0 +clone_color: o2cb-clone allocation score on hex-0: 0 +clone_color: o2cb:0 allocation score on hex-7: 0 +clone_color: o2cb:0 allocation score on hex-8: 0 +clone_color: o2cb:0 allocation score on hex-9: 0 +clone_color: o2cb:0 allocation score on hex-0: 0 +clone_color: o2cb:1 allocation score on hex-7: 0 +clone_color: o2cb:1 allocation score on hex-8: 0 +clone_color: o2cb:1 allocation score on hex-9: 0 +clone_color: o2cb:1 allocation score on hex-0: 0 +clone_color: o2cb:2 allocation score on hex-7: 0 +clone_color: o2cb:2 allocation score on hex-8: 0 +clone_color: o2cb:2 allocation score on hex-9: 0 +clone_color: o2cb:2 allocation score on hex-0: 0 +clone_color: o2cb:3 allocation score on hex-7: 0 +clone_color: o2cb:3 allocation score on hex-8: 0 +clone_color: o2cb:3 allocation score on hex-9: 0 +clone_color: o2cb:3 allocation score on hex-0: 0 +clone_color: vg1-clone allocation score on hex-7: 0 +clone_color: vg1-clone allocation score on hex-8: 0 +clone_color: vg1-clone allocation score on hex-9: 0 +clone_color: vg1-clone allocation score on hex-0: 0 +clone_color: vg1:0 allocation score on hex-7: 0 +clone_color: vg1:0 allocation score on hex-8: 0 +clone_color: vg1:0 allocation score on hex-9: 0 +clone_color: vg1:0 allocation score on hex-0: 0 +clone_color: vg1:1 allocation score on hex-7: 0 +clone_color: vg1:1 allocation score on hex-8: 0 +clone_color: vg1:1 allocation score on hex-9: 0 +clone_color: vg1:1 allocation score on hex-0: 0 +clone_color: vg1:2 allocation score on hex-7: 0 +clone_color: vg1:2 allocation score on hex-8: 0 +clone_color: vg1:2 allocation score on hex-9: 0 +clone_color: vg1:2 allocation score on hex-0: 0 +clone_color: vg1:3 allocation score on hex-7: 0 +clone_color: vg1:3 allocation score on hex-8: 0 +clone_color: vg1:3 allocation score on hex-9: 0 +clone_color: vg1:3 allocation score on hex-0: 0 +clone_color: fs1-clone allocation score on hex-7: 0 +clone_color: fs1-clone allocation score on hex-8: 0 +clone_color: fs1-clone allocation score on hex-9: 0 +clone_color: fs1-clone allocation score on hex-0: 0 +clone_color: ocfs2-1:0 allocation score on hex-7: 0 +clone_color: ocfs2-1:0 allocation score on hex-8: 0 +clone_color: ocfs2-1:0 allocation score on hex-9: 0 +clone_color: ocfs2-1:0 allocation score on hex-0: 0 +clone_color: ocfs2-1:1 allocation score on hex-7: 0 +clone_color: ocfs2-1:1 allocation score on hex-8: 0 +clone_color: ocfs2-1:1 allocation score on hex-9: 0 +clone_color: ocfs2-1:1 allocation score on hex-0: 0 +clone_color: ocfs2-1:2 allocation score on hex-7: 0 +clone_color: ocfs2-1:2 allocation score on hex-8: 0 +clone_color: ocfs2-1:2 allocation score on hex-9: 0 +clone_color: ocfs2-1:2 allocation score on hex-0: 0 +clone_color: ocfs2-1:3 allocation score on hex-7: 0 +clone_color: ocfs2-1:3 allocation score on hex-8: 0 +clone_color: ocfs2-1:3 allocation score on hex-9: 0 +clone_color: ocfs2-1:3 allocation score on hex-0: 0 +native_color: ocfs2-1:0 allocation score on hex-7: 0 +native_color: ocfs2-1:0 allocation score on hex-8: 0 +native_color: ocfs2-1:0 allocation score on hex-9: 0 +native_color: ocfs2-1:0 allocation score on hex-0: 0 +native_color: ocfs2-1:1 allocation score on hex-7: 0 +native_color: ocfs2-1:1 allocation score on hex-8: -1000000 +native_color: ocfs2-1:1 allocation score on hex-9: 0 +native_color: ocfs2-1:1 allocation score on hex-0: 0 +native_color: ocfs2-1:2 allocation score on hex-7: 0 +native_color: ocfs2-1:2 allocation score on hex-8: -1000000 +native_color: ocfs2-1:2 allocation score on hex-9: -1000000 +native_color: ocfs2-1:2 allocation score on hex-0: 0 +native_color: ocfs2-1:3 allocation score on hex-7: 0 +native_color: ocfs2-1:3 allocation score on hex-8: -1000000 +native_color: ocfs2-1:3 allocation score on hex-9: -1000000 +native_color: ocfs2-1:3 allocation score on hex-0: -1000000 +clone_color: fs2-clone allocation score on hex-7: 0 +clone_color: fs2-clone allocation score on hex-8: 0 +clone_color: fs2-clone allocation score on hex-9: 0 +clone_color: fs2-clone allocation score on hex-0: 0 +clone_color: ocfs2-2:0 allocation score on hex-7: 0 +clone_color: ocfs2-2:0 allocation score on hex-8: 0 +clone_color: ocfs2-2:0 allocation score on hex-9: 0 +clone_color: ocfs2-2:0 allocation score on hex-0: 0 +clone_color: ocfs2-2:1 allocation score on hex-7: 0 +clone_color: ocfs2-2:1 allocation score on hex-8: 0 +clone_color: ocfs2-2:1 allocation score on hex-9: 0 +clone_color: ocfs2-2:1 allocation score on hex-0: 0 +clone_color: ocfs2-2:2 allocation score on hex-7: 0 +clone_color: ocfs2-2:2 allocation score on hex-8: 0 +clone_color: ocfs2-2:2 allocation score on hex-9: 0 +clone_color: ocfs2-2:2 allocation score on hex-0: 0 +clone_color: ocfs2-2:3 allocation score on hex-7: 0 +clone_color: ocfs2-2:3 allocation score on hex-8: 0 +clone_color: ocfs2-2:3 allocation score on hex-9: 0 +clone_color: ocfs2-2:3 allocation score on hex-0: 0 +native_color: ocfs2-2:0 allocation score on hex-7: 0 +native_color: ocfs2-2:0 allocation score on hex-8: 0 +native_color: ocfs2-2:0 allocation score on hex-9: 0 +native_color: ocfs2-2:0 allocation score on hex-0: 0 +native_color: ocfs2-2:1 allocation score on hex-7: 0 +native_color: ocfs2-2:1 allocation score on hex-8: -1000000 +native_color: ocfs2-2:1 allocation score on hex-9: 0 +native_color: ocfs2-2:1 allocation score on hex-0: 0 +native_color: ocfs2-2:2 allocation score on hex-7: 0 +native_color: ocfs2-2:2 allocation score on hex-8: -1000000 +native_color: ocfs2-2:2 allocation score on hex-9: -1000000 +native_color: ocfs2-2:2 allocation score on hex-0: 0 +native_color: ocfs2-2:3 allocation score on hex-7: 0 +native_color: ocfs2-2:3 allocation score on hex-8: -1000000 +native_color: ocfs2-2:3 allocation score on hex-9: -1000000 +native_color: ocfs2-2:3 allocation score on hex-0: -1000000 +native_color: vg1:0 allocation score on hex-7: 0 +native_color: vg1:0 allocation score on hex-8: 0 +native_color: vg1:0 allocation score on hex-9: 0 +native_color: vg1:0 allocation score on hex-0: 0 +native_color: vg1:1 allocation score on hex-7: 0 +native_color: vg1:1 allocation score on hex-8: -1000000 +native_color: vg1:1 allocation score on hex-9: 0 +native_color: vg1:1 allocation score on hex-0: 0 +native_color: vg1:2 allocation score on hex-7: 0 +native_color: vg1:2 allocation score on hex-8: -1000000 +native_color: vg1:2 allocation score on hex-9: -1000000 +native_color: vg1:2 allocation score on hex-0: 0 +native_color: vg1:3 allocation score on hex-7: 0 +native_color: vg1:3 allocation score on hex-8: -1000000 +native_color: vg1:3 allocation score on hex-9: -1000000 +native_color: vg1:3 allocation score on hex-0: -1000000 +native_color: o2cb:0 allocation score on hex-7: 0 +native_color: o2cb:0 allocation score on hex-8: 0 +native_color: o2cb:0 allocation score on hex-9: 0 +native_color: o2cb:0 allocation score on hex-0: 0 +native_color: o2cb:1 allocation score on hex-7: 0 +native_color: o2cb:1 allocation score on hex-8: -1000000 +native_color: o2cb:1 allocation score on hex-9: 0 +native_color: o2cb:1 allocation score on hex-0: 0 +native_color: o2cb:2 allocation score on hex-7: 0 +native_color: o2cb:2 allocation score on hex-8: -1000000 +native_color: o2cb:2 allocation score on hex-9: -1000000 +native_color: o2cb:2 allocation score on hex-0: 0 +native_color: o2cb:3 allocation score on hex-7: 0 +native_color: o2cb:3 allocation score on hex-8: -1000000 +native_color: o2cb:3 allocation score on hex-9: -1000000 +native_color: o2cb:3 allocation score on hex-0: -1000000 +clone_color: dlm-clone allocation score on hex-7: 0 +clone_color: dlm-clone allocation score on hex-8: 0 +clone_color: dlm-clone allocation score on hex-9: 0 +clone_color: dlm-clone allocation score on hex-0: 0 +clone_color: dlm:0 allocation score on hex-7: 0 +clone_color: dlm:0 allocation score on hex-8: 0 +clone_color: dlm:0 allocation score on hex-9: 0 +clone_color: dlm:0 allocation score on hex-0: 0 +clone_color: dlm:1 allocation score on hex-7: 0 +clone_color: dlm:1 allocation score on hex-8: 0 +clone_color: dlm:1 allocation score on hex-9: 0 +clone_color: dlm:1 allocation score on hex-0: 0 +clone_color: dlm:2 allocation score on hex-7: 0 +clone_color: dlm:2 allocation score on hex-8: 0 +clone_color: dlm:2 allocation score on hex-9: 0 +clone_color: dlm:2 allocation score on hex-0: 0 +clone_color: dlm:3 allocation score on hex-7: 0 +clone_color: dlm:3 allocation score on hex-8: 0 +clone_color: dlm:3 allocation score on hex-9: 0 +clone_color: dlm:3 allocation score on hex-0: 0 +clone_color: clvm-clone allocation score on hex-7: 0 +clone_color: clvm-clone allocation score on hex-8: 0 +clone_color: clvm-clone allocation score on hex-9: 0 +clone_color: clvm-clone allocation score on hex-0: 0 +clone_color: clvm:0 allocation score on hex-7: 0 +clone_color: clvm:0 allocation score on hex-8: 0 +clone_color: clvm:0 allocation score on hex-9: 0 +clone_color: clvm:0 allocation score on hex-0: 0 +clone_color: clvm:1 allocation score on hex-7: 0 +clone_color: clvm:1 allocation score on hex-8: 0 +clone_color: clvm:1 allocation score on hex-9: 0 +clone_color: clvm:1 allocation score on hex-0: 0 +clone_color: clvm:2 allocation score on hex-7: 0 +clone_color: clvm:2 allocation score on hex-8: 0 +clone_color: clvm:2 allocation score on hex-9: 0 +clone_color: clvm:2 allocation score on hex-0: 0 +clone_color: clvm:3 allocation score on hex-7: 0 +clone_color: clvm:3 allocation score on hex-8: 0 +clone_color: clvm:3 allocation score on hex-9: 0 +clone_color: clvm:3 allocation score on hex-0: 0 +native_color: clvm:0 allocation score on hex-7: 0 +native_color: clvm:0 allocation score on hex-8: 0 +native_color: clvm:0 allocation score on hex-9: 0 +native_color: clvm:0 allocation score on hex-0: 0 +native_color: clvm:1 allocation score on hex-7: 0 +native_color: clvm:1 allocation score on hex-8: -1000000 +native_color: clvm:1 allocation score on hex-9: 0 +native_color: clvm:1 allocation score on hex-0: 0 +native_color: clvm:2 allocation score on hex-7: 0 +native_color: clvm:2 allocation score on hex-8: -1000000 +native_color: clvm:2 allocation score on hex-9: -1000000 +native_color: clvm:2 allocation score on hex-0: 0 +native_color: clvm:3 allocation score on hex-7: 0 +native_color: clvm:3 allocation score on hex-8: -1000000 +native_color: clvm:3 allocation score on hex-9: -1000000 +native_color: clvm:3 allocation score on hex-0: -1000000 +native_color: dlm:0 allocation score on hex-7: -1000000 +native_color: dlm:0 allocation score on hex-8: -1000000 +native_color: dlm:0 allocation score on hex-9: -1000000 +native_color: dlm:0 allocation score on hex-0: -1000000 +native_color: dlm:1 allocation score on hex-7: -1000000 +native_color: dlm:1 allocation score on hex-8: -1000000 +native_color: dlm:1 allocation score on hex-9: -1000000 +native_color: dlm:1 allocation score on hex-0: -1000000 +native_color: dlm:2 allocation score on hex-7: -1000000 +native_color: dlm:2 allocation score on hex-8: -1000000 +native_color: dlm:2 allocation score on hex-9: -1000000 +native_color: dlm:2 allocation score on hex-0: -1000000 +native_color: dlm:3 allocation score on hex-7: -1000000 +native_color: dlm:3 allocation score on hex-8: -1000000 +native_color: dlm:3 allocation score on hex-9: -1000000 +native_color: dlm:3 allocation score on hex-0: -1000000 diff --git a/pengine/test10/order-clone.xml b/pengine/test10/order-clone.xml new file mode 100644 index 0000000000..46e967f8e6 --- /dev/null +++ b/pengine/test10/order-clone.xml @@ -0,0 +1,259 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pengine/test10/rec-node-11.dot b/pengine/test10/rec-node-11.dot index 78e8c558d9..7f679f5d67 100644 --- a/pengine/test10/rec-node-11.dot +++ b/pengine/test10/rec-node-11.dot @@ -1,63 +1,64 @@ digraph "g" { "all_stopped" -> "rsc3_start_0 node2" [ style = bold] "all_stopped" [ style=bold color="green" fontcolor="orange" ] "group1_running_0" [ style=bold color="green" fontcolor="orange" ] "group1_start_0" -> "group1_running_0" [ style = bold] "group1_start_0" -> "rsc1_start_0 node2" [ style = bold] "group1_start_0" -> "rsc2_start_0 node2" [ style = bold] "group1_start_0" [ style=bold color="green" fontcolor="orange" ] "group1_stop_0" -> "group1_start_0" [ style = bold] "group1_stop_0" -> "group1_stopped_0" [ style = bold] "group1_stop_0" -> "rsc1_stop_0 node1" [ style = bold] "group1_stop_0" -> "rsc2_stop_0 node1" [ style = bold] "group1_stop_0" [ style=bold color="green" fontcolor="orange" ] "group1_stopped_0" -> "group1_start_0" [ style = bold] "group1_stopped_0" -> "rsc3_stop_0 node2" [ style = bold] "group1_stopped_0" [ style=bold color="green" fontcolor="orange" ] "probe_complete node2" -> "probe_complete" [ style = bold] "probe_complete node2" [ style=bold color="green" fontcolor="black" ] "probe_complete" -> "group1_start_0" [ style = bold] "probe_complete" -> "group1_stop_0" [ style = bold] "probe_complete" -> "rsc1_start_0 node2" [ style = bold] "probe_complete" -> "rsc1_stop_0 node1" [ style = bold] "probe_complete" -> "rsc2_start_0 node2" [ style = bold] "probe_complete" -> "rsc2_stop_0 node1" [ style = bold] "probe_complete" -> "stonith-1_start_0 node2" [ style = bold] "probe_complete" [ style=bold color="green" fontcolor="orange" ] "rsc1_monitor_0 node2" -> "probe_complete node2" [ style = bold] "rsc1_monitor_0 node2" [ style=bold color="green" fontcolor="black" ] "rsc1_start_0 node2" -> "group1_running_0" [ style = bold] "rsc1_start_0 node2" -> "rsc2_start_0 node2" [ style = bold] "rsc1_start_0 node2" [ style=bold color="green" fontcolor="black" ] "rsc1_stop_0 node1" -> "all_stopped" [ style = bold] "rsc1_stop_0 node1" -> "group1_stopped_0" [ style = bold] "rsc1_stop_0 node1" -> "rsc1_start_0 node2" [ style = bold] "rsc1_stop_0 node1" [ style=bold color="green" fontcolor="orange" ] "rsc2_monitor_0 node2" -> "probe_complete node2" [ style = bold] "rsc2_monitor_0 node2" [ style=bold color="green" fontcolor="black" ] "rsc2_start_0 node2" -> "group1_running_0" [ style = bold] "rsc2_start_0 node2" [ style=bold color="green" fontcolor="black" ] "rsc2_stop_0 node1" -> "all_stopped" [ style = bold] "rsc2_stop_0 node1" -> "group1_stopped_0" [ style = bold] "rsc2_stop_0 node1" -> "rsc1_stop_0 node1" [ style = bold] "rsc2_stop_0 node1" -> "rsc2_start_0 node2" [ style = bold] "rsc2_stop_0 node1" [ style=bold color="green" fontcolor="orange" ] "rsc3_start_0 node2" -> "group1_start_0" [ style = bold] "rsc3_start_0 node2" [ style=bold color="green" fontcolor="black" ] "rsc3_stop_0 node2" -> "all_stopped" [ style = bold] "rsc3_stop_0 node2" -> "rsc3_start_0 node2" [ style = bold] "rsc3_stop_0 node2" [ style=bold color="green" fontcolor="black" ] "stonith node1" -> "all_stopped" [ style = bold] +"stonith node1" -> "group1_stop_0" [ style = bold] "stonith node1" -> "rsc1_stop_0 node1" [ style = bold] "stonith node1" -> "rsc2_stop_0 node1" [ style = bold] "stonith node1" -> "stonith_complete" [ style = bold] "stonith node1" [ style=bold color="green" fontcolor="black" ] "stonith-1_monitor_0 node2" -> "probe_complete node2" [ style = bold] "stonith-1_monitor_0 node2" [ style=bold color="green" fontcolor="black" ] "stonith-1_start_0 node2" -> "stonith_up" [ style = bold] "stonith-1_start_0 node2" [ style=bold color="green" fontcolor="black" ] "stonith_complete" [ style=bold color="green" fontcolor="orange" ] "stonith_up" -> "stonith node1" [ style = bold] "stonith_up" -> "stonith_complete" [ style = bold] "stonith_up" [ style=bold color="green" fontcolor="orange" ] } diff --git a/pengine/test10/rec-node-11.exp b/pengine/test10/rec-node-11.exp index d6eb7c10f2..1c4e25a68e 100644 --- a/pengine/test10/rec-node-11.exp +++ b/pengine/test10/rec-node-11.exp @@ -1,311 +1,314 @@ + + + diff --git a/pengine/test10/rec-node-13.dot b/pengine/test10/rec-node-13.dot index e99124bdb5..92be0af422 100644 --- a/pengine/test10/rec-node-13.dot +++ b/pengine/test10/rec-node-13.dot @@ -1,15 +1,16 @@ digraph "g" { "all_stopped" [ style=bold color="green" fontcolor="orange" ] "master_rsc_1_stop_0" -> "master_rsc_1_stopped_0" [ style = bold] "master_rsc_1_stop_0" -> "ocf_msdummy:6_stop_0 c001n04" [ style = bold] "master_rsc_1_stop_0" [ style=bold color="green" fontcolor="orange" ] "master_rsc_1_stopped_0" [ style=bold color="green" fontcolor="orange" ] "ocf_msdummy:6_stop_0 c001n04" -> "all_stopped" [ style = bold] "ocf_msdummy:6_stop_0 c001n04" -> "master_rsc_1_stopped_0" [ style = bold] "ocf_msdummy:6_stop_0 c001n04" [ style=bold color="green" fontcolor="orange" ] "stonith c001n04" -> "all_stopped" [ style = bold] +"stonith c001n04" -> "master_rsc_1_stop_0" [ style = bold] "stonith c001n04" -> "ocf_msdummy:6_stop_0 c001n04" [ style = bold] "stonith c001n04" [ style=bold color="green" fontcolor="black" ] "stonith_up" -> "stonith c001n04" [ style = bold] "stonith_up" [ style=bold color="green" fontcolor="orange" ] } diff --git a/pengine/test10/rec-node-13.exp b/pengine/test10/rec-node-13.exp index ed91fdb34c..885255b79d 100644 --- a/pengine/test10/rec-node-13.exp +++ b/pengine/test10/rec-node-13.exp @@ -1,76 +1,80 @@ - + + + + + diff --git a/pengine/test10/rec-node-15.scores b/pengine/test10/rec-node-15.scores index 9c14937b32..1810748266 100644 --- a/pengine/test10/rec-node-15.scores +++ b/pengine/test10/rec-node-15.scores @@ -1,79 +1,79 @@ Allocation scores: native_color: stonith-1 allocation score on sapcl03: 0 native_color: stonith-1 allocation score on sapcl02: 0 native_color: stonith-1 allocation score on sapcl01: 0 group_color: app01 allocation score on sapcl03: 0 group_color: app01 allocation score on sapcl02: 0 -group_color: app01 allocation score on sapcl01: 0 +group_color: app01 allocation score on sapcl01: 100 group_color: IPaddr_192_168_1_101 allocation score on sapcl03: 0 group_color: IPaddr_192_168_1_101 allocation score on sapcl02: 0 group_color: IPaddr_192_168_1_101 allocation score on sapcl01: 100 group_color: LVM_2 allocation score on sapcl03: 0 group_color: LVM_2 allocation score on sapcl02: 0 group_color: LVM_2 allocation score on sapcl01: 0 group_color: Filesystem_3 allocation score on sapcl03: 0 group_color: Filesystem_3 allocation score on sapcl02: 0 group_color: Filesystem_3 allocation score on sapcl01: 0 native_color: IPaddr_192_168_1_101 allocation score on sapcl03: -1000000 native_color: IPaddr_192_168_1_101 allocation score on sapcl02: -1000000 native_color: IPaddr_192_168_1_101 allocation score on sapcl01: 100 native_color: LVM_2 allocation score on sapcl03: -1000000 native_color: LVM_2 allocation score on sapcl02: -1000000 native_color: LVM_2 allocation score on sapcl01: 0 native_color: Filesystem_3 allocation score on sapcl03: -1000000 native_color: Filesystem_3 allocation score on sapcl02: -1000000 native_color: Filesystem_3 allocation score on sapcl01: 0 group_color: app02 allocation score on sapcl03: 0 -group_color: app02 allocation score on sapcl02: 0 +group_color: app02 allocation score on sapcl02: 100 group_color: app02 allocation score on sapcl01: 0 group_color: IPaddr_192_168_1_102 allocation score on sapcl03: 0 group_color: IPaddr_192_168_1_102 allocation score on sapcl02: 100 group_color: IPaddr_192_168_1_102 allocation score on sapcl01: 0 group_color: LVM_12 allocation score on sapcl03: 0 group_color: LVM_12 allocation score on sapcl02: 0 group_color: LVM_12 allocation score on sapcl01: 0 group_color: Filesystem_13 allocation score on sapcl03: 0 group_color: Filesystem_13 allocation score on sapcl02: 0 group_color: Filesystem_13 allocation score on sapcl01: 0 native_color: IPaddr_192_168_1_102 allocation score on sapcl03: -1000000 native_color: IPaddr_192_168_1_102 allocation score on sapcl02: -1000000 native_color: IPaddr_192_168_1_102 allocation score on sapcl01: 0 native_color: LVM_12 allocation score on sapcl03: -1000000 native_color: LVM_12 allocation score on sapcl02: -1000000 native_color: LVM_12 allocation score on sapcl01: 0 native_color: Filesystem_13 allocation score on sapcl03: -1000000 native_color: Filesystem_13 allocation score on sapcl02: -1000000 native_color: Filesystem_13 allocation score on sapcl01: 0 -group_color: oracle allocation score on sapcl03: 0 +group_color: oracle allocation score on sapcl03: 100 group_color: oracle allocation score on sapcl02: 0 group_color: oracle allocation score on sapcl01: 0 group_color: IPaddr_192_168_1_104 allocation score on sapcl03: 100 group_color: IPaddr_192_168_1_104 allocation score on sapcl02: 0 group_color: IPaddr_192_168_1_104 allocation score on sapcl01: 0 group_color: LVM_22 allocation score on sapcl03: 0 group_color: LVM_22 allocation score on sapcl02: 0 group_color: LVM_22 allocation score on sapcl01: 0 group_color: Filesystem_23 allocation score on sapcl03: 0 group_color: Filesystem_23 allocation score on sapcl02: 0 group_color: Filesystem_23 allocation score on sapcl01: 0 group_color: oracle_24 allocation score on sapcl03: 0 group_color: oracle_24 allocation score on sapcl02: 0 group_color: oracle_24 allocation score on sapcl01: 0 group_color: oralsnr_25 allocation score on sapcl03: 0 group_color: oralsnr_25 allocation score on sapcl02: 0 group_color: oralsnr_25 allocation score on sapcl01: 0 native_color: IPaddr_192_168_1_104 allocation score on sapcl03: -1000000 native_color: IPaddr_192_168_1_104 allocation score on sapcl02: -1000000 native_color: IPaddr_192_168_1_104 allocation score on sapcl01: 0 native_color: LVM_22 allocation score on sapcl03: -1000000 native_color: LVM_22 allocation score on sapcl02: -1000000 native_color: LVM_22 allocation score on sapcl01: 0 native_color: Filesystem_23 allocation score on sapcl03: -1000000 native_color: Filesystem_23 allocation score on sapcl02: -1000000 native_color: Filesystem_23 allocation score on sapcl01: 0 native_color: oracle_24 allocation score on sapcl03: -1000000 native_color: oracle_24 allocation score on sapcl02: -1000000 native_color: oracle_24 allocation score on sapcl01: 0 native_color: oralsnr_25 allocation score on sapcl03: -1000000 native_color: oralsnr_25 allocation score on sapcl02: -1000000 native_color: oralsnr_25 allocation score on sapcl01: 0 diff --git a/pengine/test10/rec-node-2.dot b/pengine/test10/rec-node-2.dot index 5fea3704e3..82ecfffb34 100644 --- a/pengine/test10/rec-node-2.dot +++ b/pengine/test10/rec-node-2.dot @@ -1,100 +1,100 @@ digraph "g" { "all_stopped" -> "rsc1_start_0 node2" [ style = bold] -"all_stopped" -> "rsc2_start_0 node2" [ style = bold] "all_stopped" -> "rsc3_start_0 node2" [ style = bold] "all_stopped" -> "rsc4_start_0 node2" [ style = bold] -"all_stopped" -> "rsc5_start_0 node2" [ style = bold] "all_stopped" -> "rsc6_start_0 node2" [ style = bold] "all_stopped" [ style=bold color="green" fontcolor="orange" ] "group1_running_0" [ style=bold color="green" fontcolor="orange" ] "group1_start_0" -> "group1_running_0" [ style = bold] "group1_start_0" -> "rsc3_start_0 node2" [ style = bold] "group1_start_0" -> "rsc4_start_0 node2" [ style = bold] "group1_start_0" [ style=bold color="green" fontcolor="orange" ] "group1_stop_0" -> "group1_start_0" [ style = bold] "group1_stop_0" -> "group1_stopped_0" [ style = bold] "group1_stop_0" -> "rsc3_stop_0" [ style = bold] "group1_stop_0" -> "rsc4_stop_0" [ style = bold] "group1_stop_0" [ style=bold color="green" fontcolor="orange" ] "group1_stopped_0" -> "group1_start_0" [ style = bold] "group1_stopped_0" [ style=bold color="green" fontcolor="orange" ] "group2_running_0" [ style=bold color="green" fontcolor="orange" ] "group2_start_0" -> "group2_running_0" [ style = bold] "group2_start_0" -> "rsc5_start_0 node2" [ style = bold] "group2_start_0" -> "rsc6_start_0 node2" [ style = bold] "group2_start_0" [ style=bold color="green" fontcolor="orange" ] "group2_stop_0" -> "group2_start_0" [ style = bold] "group2_stop_0" -> "group2_stopped_0" [ style = bold] "group2_stop_0" -> "rsc5_stop_0" [ style = bold] "group2_stop_0" -> "rsc6_stop_0" [ style = bold] "group2_stop_0" [ style=bold color="green" fontcolor="orange" ] "group2_stopped_0" -> "group2_start_0" [ style = bold] "group2_stopped_0" [ style=bold color="green" fontcolor="orange" ] "probe_complete node2" -> "probe_complete" [ style = bold] "probe_complete node2" [ style=bold color="green" fontcolor="black" ] "probe_complete" -> "group1_start_0" [ style = bold] "probe_complete" -> "group1_stop_0" [ style = bold] "probe_complete" -> "group2_start_0" [ style = bold] "probe_complete" -> "group2_stop_0" [ style = bold] "probe_complete" -> "rsc1_start_0 node2" [ style = bold] "probe_complete" -> "rsc2_start_0 node2" [ style = bold] "probe_complete" -> "rsc3_start_0 node2" [ style = bold] "probe_complete" -> "rsc3_stop_0" [ style = bold] "probe_complete" -> "rsc4_start_0 node2" [ style = bold] "probe_complete" -> "rsc4_stop_0" [ style = bold] "probe_complete" -> "rsc5_start_0 node2" [ style = bold] "probe_complete" -> "rsc5_stop_0" [ style = bold] "probe_complete" -> "rsc6_start_0 node2" [ style = bold] "probe_complete" -> "rsc6_stop_0" [ style = bold] "probe_complete" -> "stonith-1_start_0 node2" [ style = bold] "probe_complete" [ style=bold color="green" fontcolor="orange" ] "rsc1_monitor_0 node2" -> "probe_complete node2" [ style = bold] "rsc1_monitor_0 node2" [ style=bold color="green" fontcolor="black" ] "rsc1_start_0 node2" [ style=bold color="green" fontcolor="black" ] "rsc2_monitor_0 node2" -> "probe_complete node2" [ style = bold] "rsc2_monitor_0 node2" [ style=bold color="green" fontcolor="black" ] "rsc2_start_0 node2" [ style=bold color="green" fontcolor="black" ] "rsc3_monitor_0 node2" -> "probe_complete node2" [ style = bold] "rsc3_monitor_0 node2" [ style=bold color="green" fontcolor="black" ] "rsc3_start_0 node2" -> "group1_running_0" [ style = bold] "rsc3_start_0 node2" -> "rsc4_start_0 node2" [ style = bold] "rsc3_start_0 node2" [ style=bold color="green" fontcolor="black" ] "rsc3_stop_0" -> "all_stopped" [ style = bold] "rsc3_stop_0" -> "group1_stopped_0" [ style = bold] "rsc3_stop_0" [ style=bold color="green" fontcolor="orange" ] "rsc4_monitor_0 node2" -> "probe_complete node2" [ style = bold] "rsc4_monitor_0 node2" [ style=bold color="green" fontcolor="black" ] "rsc4_start_0 node2" -> "group1_running_0" [ style = bold] "rsc4_start_0 node2" [ style=bold color="green" fontcolor="black" ] "rsc4_stop_0" -> "all_stopped" [ style = bold] "rsc4_stop_0" -> "group1_stopped_0" [ style = bold] "rsc4_stop_0" -> "rsc3_stop_0" [ style = bold] "rsc4_stop_0" [ style=bold color="green" fontcolor="orange" ] "rsc5_monitor_0 node2" -> "probe_complete node2" [ style = bold] "rsc5_monitor_0 node2" [ style=bold color="green" fontcolor="black" ] "rsc5_start_0 node2" -> "group2_running_0" [ style = bold] "rsc5_start_0 node2" -> "rsc6_start_0 node2" [ style = bold] "rsc5_start_0 node2" [ style=bold color="green" fontcolor="black" ] "rsc5_stop_0" -> "all_stopped" [ style = bold] "rsc5_stop_0" -> "group2_stopped_0" [ style = bold] "rsc5_stop_0" [ style=bold color="green" fontcolor="orange" ] "rsc6_monitor_0 node2" -> "probe_complete node2" [ style = bold] "rsc6_monitor_0 node2" [ style=bold color="green" fontcolor="black" ] "rsc6_start_0 node2" -> "group2_running_0" [ style = bold] "rsc6_start_0 node2" [ style=bold color="green" fontcolor="black" ] "rsc6_stop_0" -> "all_stopped" [ style = bold] "rsc6_stop_0" -> "group2_stopped_0" [ style = bold] "rsc6_stop_0" -> "rsc5_stop_0" [ style = bold] "rsc6_stop_0" [ style=bold color="green" fontcolor="orange" ] "stonith node1" -> "all_stopped" [ style = bold] "stonith node1" -> "stonith_complete" [ style = bold] "stonith node1" [ style=bold color="green" fontcolor="black" ] "stonith-1_monitor_0 node2" -> "probe_complete node2" [ style = bold] "stonith-1_monitor_0 node2" [ style=bold color="green" fontcolor="black" ] "stonith-1_start_0 node2" -> "stonith_up" [ style = bold] "stonith-1_start_0 node2" [ style=bold color="green" fontcolor="black" ] +"stonith_complete" -> "rsc2_start_0 node2" [ style = bold] +"stonith_complete" -> "rsc5_start_0 node2" [ style = bold] "stonith_complete" [ style=bold color="green" fontcolor="orange" ] "stonith_up" -> "stonith node1" [ style = bold] "stonith_up" -> "stonith_complete" [ style = bold] "stonith_up" [ style=bold color="green" fontcolor="orange" ] } diff --git a/pengine/test10/rec-node-2.exp b/pengine/test10/rec-node-2.exp index 0c24f685c8..49944ca597 100644 --- a/pengine/test10/rec-node-2.exp +++ b/pengine/test10/rec-node-2.exp @@ -1,496 +1,496 @@ - + - + - - - + + + diff --git a/pengine/test10/standby.scores b/pengine/test10/standby.scores index 556a93e1e4..5981107ca5 100644 --- a/pengine/test10/standby.scores +++ b/pengine/test10/standby.scores @@ -1,76 +1,76 @@ Allocation scores: group_color: app01 allocation score on sapcl03: 0 group_color: app01 allocation score on sapcl02: 0 -group_color: app01 allocation score on sapcl01: 0 +group_color: app01 allocation score on sapcl01: 100 group_color: IPaddr_192_168_1_101 allocation score on sapcl03: 0 group_color: IPaddr_192_168_1_101 allocation score on sapcl02: 0 group_color: IPaddr_192_168_1_101 allocation score on sapcl01: 100 group_color: LVM_2 allocation score on sapcl03: 0 group_color: LVM_2 allocation score on sapcl02: 0 group_color: LVM_2 allocation score on sapcl01: 0 group_color: Filesystem_3 allocation score on sapcl03: 0 group_color: Filesystem_3 allocation score on sapcl02: 0 group_color: Filesystem_3 allocation score on sapcl01: 0 native_color: IPaddr_192_168_1_101 allocation score on sapcl03: -1000000 native_color: IPaddr_192_168_1_101 allocation score on sapcl02: -1000000 native_color: IPaddr_192_168_1_101 allocation score on sapcl01: 100 native_color: LVM_2 allocation score on sapcl03: -1000000 native_color: LVM_2 allocation score on sapcl02: -1000000 native_color: LVM_2 allocation score on sapcl01: 0 native_color: Filesystem_3 allocation score on sapcl03: -1000000 native_color: Filesystem_3 allocation score on sapcl02: -1000000 native_color: Filesystem_3 allocation score on sapcl01: 0 group_color: app02 allocation score on sapcl03: 0 -group_color: app02 allocation score on sapcl02: 0 +group_color: app02 allocation score on sapcl02: 100 group_color: app02 allocation score on sapcl01: 0 group_color: IPaddr_192_168_1_102 allocation score on sapcl03: 0 group_color: IPaddr_192_168_1_102 allocation score on sapcl02: 100 group_color: IPaddr_192_168_1_102 allocation score on sapcl01: 0 group_color: LVM_12 allocation score on sapcl03: 0 group_color: LVM_12 allocation score on sapcl02: 0 group_color: LVM_12 allocation score on sapcl01: 0 group_color: Filesystem_13 allocation score on sapcl03: 0 group_color: Filesystem_13 allocation score on sapcl02: 0 group_color: Filesystem_13 allocation score on sapcl01: 0 native_color: IPaddr_192_168_1_102 allocation score on sapcl03: -1000000 native_color: IPaddr_192_168_1_102 allocation score on sapcl02: -1000000 native_color: IPaddr_192_168_1_102 allocation score on sapcl01: 0 native_color: LVM_12 allocation score on sapcl03: -1000000 native_color: LVM_12 allocation score on sapcl02: -1000000 native_color: LVM_12 allocation score on sapcl01: 0 native_color: Filesystem_13 allocation score on sapcl03: -1000000 native_color: Filesystem_13 allocation score on sapcl02: -1000000 native_color: Filesystem_13 allocation score on sapcl01: 0 -group_color: oracle allocation score on sapcl03: 0 +group_color: oracle allocation score on sapcl03: 100 group_color: oracle allocation score on sapcl02: 0 group_color: oracle allocation score on sapcl01: 0 group_color: IPaddr_192_168_1_104 allocation score on sapcl03: 100 group_color: IPaddr_192_168_1_104 allocation score on sapcl02: 0 group_color: IPaddr_192_168_1_104 allocation score on sapcl01: 0 group_color: LVM_22 allocation score on sapcl03: 0 group_color: LVM_22 allocation score on sapcl02: 0 group_color: LVM_22 allocation score on sapcl01: 0 group_color: Filesystem_23 allocation score on sapcl03: 0 group_color: Filesystem_23 allocation score on sapcl02: 0 group_color: Filesystem_23 allocation score on sapcl01: 0 group_color: oracle_24 allocation score on sapcl03: 0 group_color: oracle_24 allocation score on sapcl02: 0 group_color: oracle_24 allocation score on sapcl01: 0 group_color: oralsnr_25 allocation score on sapcl03: 0 group_color: oralsnr_25 allocation score on sapcl02: 0 group_color: oralsnr_25 allocation score on sapcl01: 0 native_color: IPaddr_192_168_1_104 allocation score on sapcl03: -1000000 native_color: IPaddr_192_168_1_104 allocation score on sapcl02: -1000000 native_color: IPaddr_192_168_1_104 allocation score on sapcl01: 0 native_color: LVM_22 allocation score on sapcl03: -1000000 native_color: LVM_22 allocation score on sapcl02: -1000000 native_color: LVM_22 allocation score on sapcl01: 0 native_color: Filesystem_23 allocation score on sapcl03: -1000000 native_color: Filesystem_23 allocation score on sapcl02: -1000000 native_color: Filesystem_23 allocation score on sapcl01: 0 native_color: oracle_24 allocation score on sapcl03: -1000000 native_color: oracle_24 allocation score on sapcl02: -1000000 native_color: oracle_24 allocation score on sapcl01: 0 native_color: oralsnr_25 allocation score on sapcl03: -1000000 native_color: oralsnr_25 allocation score on sapcl02: -1000000 native_color: oralsnr_25 allocation score on sapcl01: 0 diff --git a/pengine/test10/stonith-0.dot b/pengine/test10/stonith-0.dot index 258f742062..ec2c2e1297 100644 --- a/pengine/test10/stonith-0.dot +++ b/pengine/test10/stonith-0.dot @@ -1,88 +1,90 @@ digraph "g" { "all_stopped" [ style=bold color="green" fontcolor="orange" ] "child_DoFencing:4_monitor_20000 c001n08" [ style=bold color="green" fontcolor="black" ] "group-1_running_0" [ style=bold color="green" fontcolor="orange" ] "group-1_start_0" -> "group-1_running_0" [ style = bold] "group-1_start_0" -> "heartbeat_192.168.100.182_start_0 c001n02" [ style = bold] "group-1_start_0" -> "ocf_192.168.100.181_start_0 c001n02" [ style = bold] "group-1_start_0" -> "ocf_192.168.100.183_start_0 c001n02" [ style = bold] "group-1_start_0" [ style=bold color="green" fontcolor="orange" ] "group-1_stop_0" -> "group-1_start_0" [ style = bold] "group-1_stop_0" -> "group-1_stopped_0" [ style = bold] "group-1_stop_0" -> "heartbeat_192.168.100.182_stop_0 c001n03" [ style = bold] "group-1_stop_0" -> "ocf_192.168.100.181_stop_0 c001n03" [ style = bold] "group-1_stop_0" -> "ocf_192.168.100.181_stop_0 c001n05" [ style = bold] "group-1_stop_0" -> "ocf_192.168.100.183_stop_0 c001n03" [ style = bold] "group-1_stop_0" -> "ocf_192.168.100.183_stop_0 c001n05" [ style = bold] "group-1_stop_0" [ style=bold color="green" fontcolor="orange" ] "group-1_stopped_0" -> "group-1_start_0" [ style = bold] "group-1_stopped_0" [ style=bold color="green" fontcolor="orange" ] "heartbeat_192.168.100.182_monitor_5000 c001n02" [ style=bold color="green" fontcolor="black" ] "heartbeat_192.168.100.182_start_0 c001n02" -> "group-1_running_0" [ style = bold] "heartbeat_192.168.100.182_start_0 c001n02" -> "heartbeat_192.168.100.182_monitor_5000 c001n02" [ style = bold] "heartbeat_192.168.100.182_start_0 c001n02" -> "ocf_192.168.100.183_start_0 c001n02" [ style = bold] "heartbeat_192.168.100.182_start_0 c001n02" [ style=bold color="green" fontcolor="black" ] "heartbeat_192.168.100.182_stop_0 c001n03" -> "all_stopped" [ style = bold] "heartbeat_192.168.100.182_stop_0 c001n03" -> "group-1_stopped_0" [ style = bold] "heartbeat_192.168.100.182_stop_0 c001n03" -> "heartbeat_192.168.100.182_start_0 c001n02" [ style = bold] "heartbeat_192.168.100.182_stop_0 c001n03" -> "ocf_192.168.100.181_stop_0 c001n03" [ style = bold] "heartbeat_192.168.100.182_stop_0 c001n03" -> "ocf_192.168.100.181_stop_0 c001n05" [ style = bold] "heartbeat_192.168.100.182_stop_0 c001n03" [ style=bold color="green" fontcolor="orange" ] "ocf_192.168.100.181_monitor_5000 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_192.168.100.181_start_0 c001n02" -> "group-1_running_0" [ style = bold] "ocf_192.168.100.181_start_0 c001n02" -> "heartbeat_192.168.100.182_start_0 c001n02" [ style = bold] "ocf_192.168.100.181_start_0 c001n02" -> "ocf_192.168.100.181_monitor_5000 c001n02" [ style = bold] "ocf_192.168.100.181_start_0 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_192.168.100.181_stop_0 c001n03" -> "all_stopped" [ style = bold] "ocf_192.168.100.181_stop_0 c001n03" -> "group-1_stopped_0" [ style = bold] "ocf_192.168.100.181_stop_0 c001n03" -> "ocf_192.168.100.181_start_0 c001n02" [ style = bold] "ocf_192.168.100.181_stop_0 c001n03" [ style=bold color="green" fontcolor="orange" ] "ocf_192.168.100.181_stop_0 c001n05" -> "all_stopped" [ style = bold] "ocf_192.168.100.181_stop_0 c001n05" -> "group-1_stopped_0" [ style = bold] "ocf_192.168.100.181_stop_0 c001n05" -> "ocf_192.168.100.181_start_0 c001n02" [ style = bold] "ocf_192.168.100.181_stop_0 c001n05" [ style=bold color="green" fontcolor="orange" ] "ocf_192.168.100.183_monitor_5000 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_192.168.100.183_start_0 c001n02" -> "group-1_running_0" [ style = bold] "ocf_192.168.100.183_start_0 c001n02" -> "ocf_192.168.100.183_monitor_5000 c001n02" [ style = bold] "ocf_192.168.100.183_start_0 c001n02" [ style=bold color="green" fontcolor="black" ] "ocf_192.168.100.183_stop_0 c001n03" -> "all_stopped" [ style = bold] "ocf_192.168.100.183_stop_0 c001n03" -> "group-1_stopped_0" [ style = bold] "ocf_192.168.100.183_stop_0 c001n03" -> "heartbeat_192.168.100.182_stop_0 c001n03" [ style = bold] "ocf_192.168.100.183_stop_0 c001n03" -> "ocf_192.168.100.183_start_0 c001n02" [ style = bold] "ocf_192.168.100.183_stop_0 c001n03" [ style=bold color="green" fontcolor="orange" ] "ocf_192.168.100.183_stop_0 c001n05" -> "all_stopped" [ style = bold] "ocf_192.168.100.183_stop_0 c001n05" -> "group-1_stopped_0" [ style = bold] "ocf_192.168.100.183_stop_0 c001n05" -> "heartbeat_192.168.100.182_stop_0 c001n03" [ style = bold] "ocf_192.168.100.183_stop_0 c001n05" -> "ocf_192.168.100.183_start_0 c001n02" [ style = bold] "ocf_192.168.100.183_stop_0 c001n05" [ style=bold color="green" fontcolor="orange" ] "rsc_c001n05_monitor_5000 c001n07" [ style=bold color="green" fontcolor="black" ] "rsc_c001n05_start_0 c001n07" -> "rsc_c001n05_monitor_5000 c001n07" [ style = bold] "rsc_c001n05_start_0 c001n07" [ style=bold color="green" fontcolor="black" ] "rsc_c001n05_stop_0 c001n05" -> "all_stopped" [ style = bold] "rsc_c001n05_stop_0 c001n05" -> "rsc_c001n05_start_0 c001n07" [ style = bold] "rsc_c001n05_stop_0 c001n05" [ style=bold color="green" fontcolor="orange" ] "rsc_c001n07_monitor_5000 c001n07" [ style=bold color="green" fontcolor="black" ] "rsc_c001n07_start_0 c001n07" -> "rsc_c001n07_monitor_5000 c001n07" [ style = bold] "rsc_c001n07_start_0 c001n07" [ style=bold color="green" fontcolor="black" ] "rsc_c001n07_stop_0 c001n03" -> "all_stopped" [ style = bold] "rsc_c001n07_stop_0 c001n03" -> "rsc_c001n07_start_0 c001n07" [ style = bold] "rsc_c001n07_stop_0 c001n03" [ style=bold color="green" fontcolor="orange" ] "stonith c001n03" -> "all_stopped" [ style = bold] +"stonith c001n03" -> "group-1_stop_0" [ style = bold] "stonith c001n03" -> "heartbeat_192.168.100.182_stop_0 c001n03" [ style = bold] "stonith c001n03" -> "ocf_192.168.100.181_stop_0 c001n03" [ style = bold] "stonith c001n03" -> "ocf_192.168.100.183_stop_0 c001n03" [ style = bold] "stonith c001n03" -> "rsc_c001n07_stop_0 c001n03" [ style = bold] "stonith c001n03" [ style=bold color="green" fontcolor="black" ] "stonith c001n05" -> "all_stopped" [ style = bold] +"stonith c001n05" -> "group-1_stop_0" [ style = bold] "stonith c001n05" -> "ocf_192.168.100.181_stop_0 c001n05" [ style = bold] "stonith c001n05" -> "ocf_192.168.100.183_stop_0 c001n05" [ style = bold] "stonith c001n05" -> "rsc_c001n05_stop_0 c001n05" [ style = bold] "stonith c001n05" -> "stonith c001n03" [ style = bold] "stonith c001n05" -> "stonith_complete" [ style = bold] "stonith c001n05" [ style=bold color="green" fontcolor="black" ] "stonith_complete" [ style=bold color="green" fontcolor="orange" ] "stonith_up" -> "stonith c001n03" [ style = bold] "stonith_up" -> "stonith c001n05" [ style = bold] "stonith_up" -> "stonith_complete" [ style = bold] "stonith_up" [ style=bold color="green" fontcolor="orange" ] } diff --git a/pengine/test10/stonith-0.exp b/pengine/test10/stonith-0.exp index afb3fa75ef..c4c13dbec2 100644 --- a/pengine/test10/stonith-0.exp +++ b/pengine/test10/stonith-0.exp @@ -1,435 +1,442 @@ - + + + + + + + + diff --git a/pengine/test10/stonith-1.dot b/pengine/test10/stonith-1.dot index d575820f00..3496d3218a 100644 --- a/pengine/test10/stonith-1.dot +++ b/pengine/test10/stonith-1.dot @@ -1,104 +1,105 @@ digraph "g" { "DoFencing_running_0" [ style=bold color="green" fontcolor="orange" ] "DoFencing_start_0" -> "DoFencing_running_0" [ style = bold] "DoFencing_start_0" -> "child_DoFencing:2_start_0 sles-4" [ style = bold] "DoFencing_start_0" [ style=bold color="green" fontcolor="orange" ] "DoFencing_stop_0" -> "DoFencing_start_0" [ style = bold] "DoFencing_stop_0" -> "DoFencing_stopped_0" [ style = bold] "DoFencing_stop_0" -> "child_DoFencing:2_stop_0 sles-3" [ style = bold] "DoFencing_stop_0" [ style=bold color="green" fontcolor="orange" ] "DoFencing_stopped_0" -> "DoFencing_start_0" [ style = bold] "DoFencing_stopped_0" [ style=bold color="green" fontcolor="orange" ] "all_stopped" [ style=bold color="green" fontcolor="orange" ] "child_DoFencing:2_monitor_60000 sles-4" [ style=bold color="green" fontcolor="black" ] "child_DoFencing:2_start_0 sles-4" -> "DoFencing_running_0" [ style = bold] "child_DoFencing:2_start_0 sles-4" -> "child_DoFencing:2_monitor_60000 sles-4" [ style = bold] "child_DoFencing:2_start_0 sles-4" -> "stonith_up" [ style = bold] "child_DoFencing:2_start_0 sles-4" [ style=bold color="green" fontcolor="black" ] "child_DoFencing:2_stop_0 sles-3" -> "DoFencing_stopped_0" [ style = bold] "child_DoFencing:2_stop_0 sles-3" -> "child_DoFencing:2_start_0 sles-4" [ style = bold] "child_DoFencing:2_stop_0 sles-3" [ style=bold color="green" fontcolor="orange" ] "group-1_running_0" [ style=bold color="green" fontcolor="orange" ] "group-1_start_0" -> "group-1_running_0" [ style = bold] "group-1_start_0" -> "r192.168.100.183_start_0 sles-1" [ style = bold] "group-1_start_0" [ style=bold color="green" fontcolor="orange" ] "lsb_dummy_monitor_5000 sles-2" [ style=bold color="green" fontcolor="black" ] "master_rsc_1_running_0" [ style=bold color="green" fontcolor="orange" ] "master_rsc_1_start_0" -> "master_rsc_1_running_0" [ style = bold] "master_rsc_1_start_0" -> "ocf_msdummy:0_start_0 sles-4" [ style = bold] "master_rsc_1_start_0" -> "ocf_msdummy:1_start_0 sles-1" [ style = bold] "master_rsc_1_start_0" -> "ocf_msdummy:2_start_0 sles-2" [ style = bold] "master_rsc_1_start_0" -> "ocf_msdummy:3_start_0 sles-4" [ style = bold] "master_rsc_1_start_0" -> "ocf_msdummy:4_start_0 sles-1" [ style = bold] "master_rsc_1_start_0" -> "ocf_msdummy:5_start_0 sles-2" [ style = bold] "master_rsc_1_start_0" [ style=bold color="green" fontcolor="orange" ] "master_rsc_1_stop_0" -> "master_rsc_1_start_0" [ style = bold] "master_rsc_1_stop_0" -> "master_rsc_1_stopped_0" [ style = bold] "master_rsc_1_stop_0" -> "ocf_msdummy:2_stop_0 sles-3" [ style = bold] "master_rsc_1_stop_0" -> "ocf_msdummy:5_stop_0 sles-3" [ style = bold] "master_rsc_1_stop_0" [ style=bold color="green" fontcolor="orange" ] "master_rsc_1_stopped_0" -> "master_rsc_1_start_0" [ style = bold] "master_rsc_1_stopped_0" [ style=bold color="green" fontcolor="orange" ] "migrator_monitor_10000 sles-4" [ style=bold color="green" fontcolor="black" ] "migrator_start_0 sles-4" -> "migrator_monitor_10000 sles-4" [ style = bold] "migrator_start_0 sles-4" [ style=bold color="green" fontcolor="black" ] "migrator_stop_0 sles-3" -> "all_stopped" [ style = bold] "migrator_stop_0 sles-3" -> "migrator_start_0 sles-4" [ style = bold] "migrator_stop_0 sles-3" [ style=bold color="green" fontcolor="orange" ] "ocf_msdummy:0_monitor_5000 sles-4" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:0_start_0 sles-4" -> "master_rsc_1_running_0" [ style = bold] "ocf_msdummy:0_start_0 sles-4" -> "ocf_msdummy:0_monitor_5000 sles-4" [ style = bold] "ocf_msdummy:0_start_0 sles-4" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:1_monitor_5000 sles-1" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:1_start_0 sles-1" -> "master_rsc_1_running_0" [ style = bold] "ocf_msdummy:1_start_0 sles-1" -> "ocf_msdummy:1_monitor_5000 sles-1" [ style = bold] "ocf_msdummy:1_start_0 sles-1" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:2_monitor_5000 sles-2" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:2_start_0 sles-2" -> "master_rsc_1_running_0" [ style = bold] "ocf_msdummy:2_start_0 sles-2" -> "ocf_msdummy:2_monitor_5000 sles-2" [ style = bold] "ocf_msdummy:2_start_0 sles-2" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:2_stop_0 sles-3" -> "all_stopped" [ style = bold] "ocf_msdummy:2_stop_0 sles-3" -> "master_rsc_1_stopped_0" [ style = bold] "ocf_msdummy:2_stop_0 sles-3" -> "ocf_msdummy:2_start_0 sles-2" [ style = bold] "ocf_msdummy:2_stop_0 sles-3" [ style=bold color="green" fontcolor="orange" ] "ocf_msdummy:3_monitor_5000 sles-4" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:3_start_0 sles-4" -> "master_rsc_1_running_0" [ style = bold] "ocf_msdummy:3_start_0 sles-4" -> "ocf_msdummy:3_monitor_5000 sles-4" [ style = bold] "ocf_msdummy:3_start_0 sles-4" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:4_monitor_5000 sles-1" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:4_start_0 sles-1" -> "master_rsc_1_running_0" [ style = bold] "ocf_msdummy:4_start_0 sles-1" -> "ocf_msdummy:4_monitor_5000 sles-1" [ style = bold] "ocf_msdummy:4_start_0 sles-1" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:5_monitor_5000 sles-2" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:5_start_0 sles-2" -> "master_rsc_1_running_0" [ style = bold] "ocf_msdummy:5_start_0 sles-2" -> "ocf_msdummy:5_monitor_5000 sles-2" [ style = bold] "ocf_msdummy:5_start_0 sles-2" [ style=bold color="green" fontcolor="black" ] "ocf_msdummy:5_stop_0 sles-3" -> "all_stopped" [ style = bold] "ocf_msdummy:5_stop_0 sles-3" -> "master_rsc_1_stopped_0" [ style = bold] "ocf_msdummy:5_stop_0 sles-3" -> "ocf_msdummy:5_start_0 sles-2" [ style = bold] "ocf_msdummy:5_stop_0 sles-3" [ style=bold color="green" fontcolor="orange" ] "r192.168.100.182_monitor_5000 sles-1" [ style=bold color="green" fontcolor="black" ] "r192.168.100.183_monitor_5000 sles-1" [ style=bold color="green" fontcolor="black" ] "r192.168.100.183_start_0 sles-1" -> "group-1_running_0" [ style = bold] "r192.168.100.183_start_0 sles-1" -> "r192.168.100.183_monitor_5000 sles-1" [ style = bold] "r192.168.100.183_start_0 sles-1" [ style=bold color="green" fontcolor="black" ] "rsc_sles-2_monitor_5000 sles-2" [ style=bold color="green" fontcolor="black" ] "rsc_sles-3_monitor_5000 sles-4" [ style=bold color="green" fontcolor="black" ] "rsc_sles-3_start_0 sles-4" -> "rsc_sles-3_monitor_5000 sles-4" [ style = bold] "rsc_sles-3_start_0 sles-4" [ style=bold color="green" fontcolor="black" ] "rsc_sles-3_stop_0 sles-3" -> "all_stopped" [ style = bold] "rsc_sles-3_stop_0 sles-3" -> "rsc_sles-3_start_0 sles-4" [ style = bold] "rsc_sles-3_stop_0 sles-3" [ style=bold color="green" fontcolor="orange" ] "rsc_sles-4_monitor_5000 sles-4" [ style=bold color="green" fontcolor="black" ] "stonith sles-3" -> "all_stopped" [ style = bold] +"stonith sles-3" -> "master_rsc_1_stop_0" [ style = bold] "stonith sles-3" -> "migrator_stop_0 sles-3" [ style = bold] "stonith sles-3" -> "ocf_msdummy:2_stop_0 sles-3" [ style = bold] "stonith sles-3" -> "ocf_msdummy:5_stop_0 sles-3" [ style = bold] "stonith sles-3" -> "rsc_sles-3_stop_0 sles-3" [ style = bold] "stonith sles-3" -> "stonith_complete" [ style = bold] "stonith sles-3" [ style=bold color="green" fontcolor="black" ] "stonith_complete" [ style=bold color="green" fontcolor="orange" ] "stonith_up" -> "stonith sles-3" [ style = bold] "stonith_up" -> "stonith_complete" [ style = bold] "stonith_up" [ style=bold color="green" fontcolor="orange" ] } diff --git a/pengine/test10/stonith-1.exp b/pengine/test10/stonith-1.exp index 543add16fc..17217e892a 100644 --- a/pengine/test10/stonith-1.exp +++ b/pengine/test10/stonith-1.exp @@ -1,586 +1,590 @@ - + + + + + diff --git a/tools/crm.in b/tools/crm.in index a6339516b1..bb5d4feb99 100644 --- a/tools/crm.in +++ b/tools/crm.in @@ -1,8195 +1,8097 @@ #!/usr/bin/python # # Copyright (C) 2008 Dejan Muhamedagic # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This software is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # import shlex import os from tempfile import mkstemp import subprocess import sys import time import readline import copy import xml.dom.minidom import signal import re def is_program(prog): return subprocess.call("which %s >/dev/null 2>&1"%prog, shell=True) == 0 def prereqs(): proglist = "which cibadmin crm_resource crm_attribute crm_mon crm_standby crm_failcount" for prog in proglist.split(): if not is_program(prog): print >> sys.stderr, "%s not available, check your installation"%prog sys.exit(1) prereqs() lineno = -1 regression_tests = False class ErrorBuffer(object): ''' Show error messages either immediately or buffered. ''' def __init__(self): self.msg_list = [] self.mode = "immediate" def buffer(self): self.mode = "keep" def release(self): if self.msg_list: print >> sys.stderr, '\n'.join(self.msg_list) if not batch: raw_input("Press enter to continue... ") self.msg_list = [] self.mode = "immediate" def writemsg(self,msg): if self.mode == "immediate": if regression_tests: print msg else: print >> sys.stderr, msg else: self.msg_list.append(msg) def error(self,s): self.writemsg("ERROR: %s" % add_lineno(s)) def warning(self,s): self.writemsg("WARNING: %s" % add_lineno(s)) def info(self,s): self.writemsg("INFO: %s" % add_lineno(s)) def debug(self,s): if user_prefs.get_debug(): self.writemsg("DEBUG: %s" % add_lineno(s)) err_buf = ErrorBuffer() def add_lineno(s): if lineno > 0: return "%d: %s" % (lineno,s) else: return s def common_err(s): err_buf.error(s) def common_warn(s): err_buf.warning(s) def common_info(s): err_buf.info(s) def common_debug(s): err_buf.debug(s) def no_prog_err(name): err_buf.error("%s not available, check your installation"%name) def missing_prog_warn(name): err_buf.warning("could not find any %s on the system"%name) def no_attribute_err(attr,obj_type): err_buf.error("required attribute %s not found in %s"%(attr,obj_type)) def bad_def_err(what,msg): err_buf.error("bad %s definition: %s"%(what,msg)) def unsupported_err(name): err_buf.error("%s is not supported"%name) def no_such_obj_err(name): err_buf.error("%s object is not supported"%name) def obj_cli_err(name): err_buf.error("object %s cannot be represented in the CLI notation"%name) def missing_obj_err(node): err_buf.error("object %s:%s missing (shouldn't have happened)"% \ (node.tagName,node.getAttribute("id"))) def constraint_norefobj_err(constraint_id,obj_id): err_buf.error("constraint %s references a resource %s which doesn't exist"% \ (constraint_id,obj_id)) def obj_exists_err(name): err_buf.error("object %s already exists"%name) def no_object_err(name): err_buf.error("object %s does not exist"%name) def invalid_id_err(obj_id): err_buf.error("%s: invalid object id"%obj_id) def id_used_err(node_id): err_buf.error("%s: id is already in use"%node_id) def skill_err(s): err_buf.error("%s: this command is not allowed at this skill level"%' '.join(s)) def syntax_err(s,token = '',context = ''): pfx = "syntax" if context: pfx = "%s in %s" %(pfx,context) if type(s) == type(''): err_buf.error("%s near <%s>"%(pfx,s)) elif token: err_buf.error("%s near <%s>: %s"%(pfx,token,' '.join(s))) else: err_buf.error("%s: %s"%(pfx,' '.join(s))) def bad_usage(cmd,args): err_buf.error("bad usage: %s %s"%(cmd,args)) def empty_cib_err(): err_buf.error("No CIB!") def cib_parse_err(msg): err_buf.error("%s"%msg) def cib_no_elem_err(el_name): err_buf.error("CIB contains no '%s' element!"%el_name) def cib_ver_unsupported_err(validator,rel): err_buf.error("CIB not supported: validator '%s', release '%s'"% (validator,rel)) err_buf.error("You may try the upgrade command") def update_err(obj_id,cibadm_opt,xml): if cibadm_opt == '-U': task = "update" elif cibadm_opt == '-D': task = "delete" else: task = "replace" err_buf.error("could not %s %s"%(task,obj_id)) err_buf.info("offending xml: %s" % xml) def not_impl_info(s): err_buf.info("%s is not implemented yet" % s) def ask(msg): print_msg = True while True: ans = raw_input(msg + ' ') if not ans or ans[0].lower() not in ('n','y'): if print_msg: print "Please answer with y[es] or n[o]" print_msg = False else: return ans[0].lower() == 'y' def keyword_cmp(string1, string2): return string1.lower() == string2.lower() from UserDict import DictMixin class odict(DictMixin): def __init__(self, data=None, **kwdata): self._keys = [] self._data = {} def __setitem__(self, key, value): if key not in self._data: self._keys.append(key) self._data[key] = value def __getitem__(self, key): if key not in self._data: return self._data[key.lower()] return self._data[key] def __delitem__(self, key): del self._data[key] self._keys.remove(key) def keys(self): return list(self._keys) def copy(self): copyDict = odict() copyDict._data = self._data.copy() copyDict._keys = self._keys[:] return copyDict class olist(list): def __init__(self, keys): #print "Init %s" % (repr(keys)) super(olist, self).__init__() for key in keys: self.append(key) self.append(key.upper()) # from: http://code.activestate.com/recipes/475116/ class TerminalController(object): """ A class that can be used to portably generate formatted output to a terminal. `TerminalController` defines a set of instance variables whose values are initialized to the control sequence necessary to perform a given action. These can be simply included in normal output to the terminal: >>> term = TerminalController() >>> print 'This is '+term.GREEN+'green'+term.NORMAL Alternatively, the `render()` method can used, which replaces '${action}' with the string required to perform 'action': >>> term = TerminalController() >>> print term.render('This is ${GREEN}green${NORMAL}') If the terminal doesn't support a given action, then the value of the corresponding instance variable will be set to ''. As a result, the above code will still work on terminals that do not support color, except that their output will not be colored. Also, this means that you can test whether the terminal supports a given action by simply testing the truth value of the corresponding instance variable: >>> term = TerminalController() >>> if term.CLEAR_SCREEN: ... print 'This terminal supports clearning the screen.' Finally, if the width and height of the terminal are known, then they will be stored in the `COLS` and `LINES` attributes. """ # Cursor movement: BOL = '' #: Move the cursor to the beginning of the line UP = '' #: Move the cursor up one line DOWN = '' #: Move the cursor down one line LEFT = '' #: Move the cursor left one char RIGHT = '' #: Move the cursor right one char # Deletion: CLEAR_SCREEN = '' #: Clear the screen and move to home position CLEAR_EOL = '' #: Clear to the end of the line. CLEAR_BOL = '' #: Clear to the beginning of the line. CLEAR_EOS = '' #: Clear to the end of the screen # Output modes: BOLD = '' #: Turn on bold mode BLINK = '' #: Turn on blink mode DIM = '' #: Turn on half-bright mode REVERSE = '' #: Turn on reverse-video mode NORMAL = '' #: Turn off all modes # Cursor display: HIDE_CURSOR = '' #: Make the cursor invisible SHOW_CURSOR = '' #: Make the cursor visible # Terminal size: COLS = None #: Width of the terminal (None for unknown) LINES = None #: Height of the terminal (None for unknown) # Foreground colors: BLACK = BLUE = GREEN = CYAN = RED = MAGENTA = YELLOW = WHITE = '' # Background colors: BG_BLACK = BG_BLUE = BG_GREEN = BG_CYAN = '' BG_RED = BG_MAGENTA = BG_YELLOW = BG_WHITE = '' _STRING_CAPABILITIES = """ BOL=cr UP=cuu1 DOWN=cud1 LEFT=cub1 RIGHT=cuf1 CLEAR_SCREEN=clear CLEAR_EOL=el CLEAR_BOL=el1 CLEAR_EOS=ed BOLD=bold BLINK=blink DIM=dim REVERSE=rev UNDERLINE=smul NORMAL=sgr0 HIDE_CURSOR=cinvis SHOW_CURSOR=cnorm""".split() _COLORS = """BLACK BLUE GREEN CYAN RED MAGENTA YELLOW WHITE""".split() _ANSICOLORS = "BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE".split() def __init__(self, term_stream=sys.stdout): """ Create a `TerminalController` and initialize its attributes with appropriate values for the current terminal. `term_stream` is the stream that will be used for terminal output; if this stream is not a tty, then the terminal is assumed to be a dumb terminal (i.e., have no capabilities). """ # Curses isn't available on all platforms try: import curses except: common_info("no curses support: you won't see colors") return # If the stream isn't a tty, then assume it has no capabilities. if not term_stream.isatty(): return # Check the terminal type. If we fail, then assume that the # terminal has no capabilities. try: curses.setupterm() except: return # Look up numeric capabilities. self.COLS = curses.tigetnum('cols') self.LINES = curses.tigetnum('lines') # Look up string capabilities. for capability in self._STRING_CAPABILITIES: (attrib, cap_name) = capability.split('=') setattr(self, attrib, self._tigetstr(cap_name) or '') # Colors set_fg = self._tigetstr('setf') if set_fg: for i,color in zip(range(len(self._COLORS)), self._COLORS): setattr(self, color, curses.tparm(set_fg, i) or '') set_fg_ansi = self._tigetstr('setaf') if set_fg_ansi: for i,color in zip(range(len(self._ANSICOLORS)), self._ANSICOLORS): setattr(self, color, curses.tparm(set_fg_ansi, i) or '') set_bg = self._tigetstr('setb') if set_bg: for i,color in zip(range(len(self._COLORS)), self._COLORS): setattr(self, 'BG_'+color, curses.tparm(set_bg, i) or '') set_bg_ansi = self._tigetstr('setab') if set_bg_ansi: for i,color in zip(range(len(self._ANSICOLORS)), self._ANSICOLORS): setattr(self, 'BG_'+color, curses.tparm(set_bg_ansi, i) or '') def _tigetstr(self, cap_name): # String capabilities can include "delays" of the form "$<2>". # For any modern terminal, we should be able to just ignore # these, so strip them out. import curses cap = curses.tigetstr(cap_name) or '' return re.sub(r'\$<\d+>[/*]?', '', cap) def render(self, template): """ Replace each $-substitutions in the given template string with the corresponding terminal control string (if it's defined) or '' (if it's not). """ return re.sub(r'\$\$|\${\w+}', self._render_sub, template) def _render_sub(self, match): s = match.group() if s == '$$': return s else: return getattr(self, s[2:-1]) def is_color(self, s): try: attr = getattr(self, s.upper()) return attr != None except: return False class CliDisplay(object): """ Display output for various syntax elements. """ def __init__(self): self.no_pretty = False def set_no_pretty(self): self.no_pretty = True def reset_no_pretty(self): self.no_pretty = False def colorstring(self, clrnum, s): if self.no_pretty: return s else: return termctrl.render("${%s}%s${NORMAL}" % \ (user_prefs.colorscheme[clrnum].upper(), s)) def keyword(self, kw): s = kw if "uppercase" in user_prefs.output: s = s.upper() if "color" in user_prefs.output: s = self.colorstring(0, s) return s def otherword(self, n, s): if "color" in user_prefs.output: return self.colorstring(n, s) else: return s def id(self, s): return self.otherword(1, s) def attr_name(self, s): return self.otherword(2, s) def attr_value(self, s): return self.otherword(3, s) def rscref(self, s): return self.otherword(4, s) def score(self, s): return self.otherword(5, s) global_aliases = { "quit": ("bye","exit"), "end": ("cd","up"), } def setup_aliases(obj): for cmd in obj.cmd_aliases.keys(): for alias in obj.cmd_aliases[cmd]: obj.help_table[alias] = obj.help_table[cmd] obj.cmd_table[alias] = obj.cmd_table[cmd] # # Resource Agents interface (meta-data, parameters, etc) # def lrmadmin(opts, xml = False): ''' Get information directly from lrmd using lrmadmin. ''' lrmadmin_prog = "@sbindir@/lrmadmin" l = [] #print "invoke: lrmadmin",opts if is_program(lrmadmin_prog) and is_process("lrmd"): l = stdin2list("%s %s" % (lrmadmin_prog,opts)) if not xml: l = l[1:] # skip the first line return l def prog_meta(s): ''' Do external program metadata. ''' prog = "@CRM_DAEMON_DIR@/%s" % s l = [] if is_program(prog): l = stdin2list("%s metadata" % prog) return l def get_nodes_text(n,tag): try: node = n.getElementsByTagName(tag)[0] for c in node.childNodes: if c.nodeType == c.TEXT_NODE: return c.data.strip() except: return '' def ra_classes(): ''' List of RA classes. ''' if wcache.is_cached("ra_classes"): return wcache.retrieve("ra_classes") l = lrmadmin("-C") l.sort() return wcache.store("ra_classes",l) def ra_providers(ra_type,ra_class = "ocf"): 'List of providers for a class:type.' id = "ra_providers-%s-%s" % (ra_class,ra_type) if wcache.is_cached(id): return wcache.retrieve(id) l = lrmadmin("-P %s %s" % (ra_class,ra_type),True) l.sort() return wcache.store(id,l) def ra_providers_all(ra_class = "ocf"): ''' List of providers for a class:type. ''' id = "ra_providers_all-%s" % ra_class if wcache.is_cached(id): return wcache.retrieve(id) ocf_root = os.getenv("@OCF_ROOT_DIR@") if not ocf_root: ocf_root = "/usr/lib/ocf" dir = ocf_root + "/resource.d" l = [] for s in os.listdir(dir): if os.path.isdir("%s/%s" % (dir,s)): l.append(s) l.sort() return wcache.store(id,l) def ra_types(ra_class = "ocf", ra_provider = ""): ''' List of RA type for a class. ''' if not ra_class: ra_class = "ocf" id = "ra_types-%s-%s" % (ra_class,ra_provider) if wcache.is_cached(id): return wcache.retrieve(id) if ra_provider: list = [] for ra in lrmadmin("-T %s" % ra_class): if ra_provider in ra_providers(ra,ra_class): list.append(ra) else: list = lrmadmin("-T %s" % ra_class) list.sort() return wcache.store(id,list) def mk_monitor_name(role,depth): depth = depth == "0" and "" or ("_%s" % depth) return role and role != "Started" and \ "monitor_%s%s" % (role,depth) or \ "monitor%s" % depth def monitor_name_node(node): depth = node.getAttribute("depth") or '0' role = node.getAttribute("role") return mk_monitor_name(role,depth) def monitor_name_pl(pl): depth = find_value(pl, "depth") or '0' role = find_value(pl, "role") return mk_monitor_name(role,depth) def crm_msec(t): ''' See lib/common/utils.c:crm_get_msec(). ''' convtab = { 'ms': (1,1), 'msec': (1,1), 'us': (1,1000), 'usec': (1,1000), '': (1000,1), 's': (1000,1), 'sec': (1000,1), 'm': (60*1000,1), 'min': (60*1000,1), 'h': (60*60*1000,1), 'hr': (60*60*1000,1), } if not t: return -1 r = re.match("\s*(\d+)\s*([a-zA-Z]+)?", t) if not r: return -1 if not r.group(2): q = '' else: q = r.group(2).lower() try: mult,div = convtab[q] except: return -1 return (int(r.group(1))*mult)/div def crm_time_cmp(a, b): return crm_msec(a) - crm_msec(b) class RAInfo(object): ''' A resource agent and whatever's useful about it. ''' ra_tab = " " # four horses required_ops = ("start", "stop") skip_ops = ("meta-data", "validate-all") skip_op_attr = ("name", "depth", "role") def __init__(self,ra_class,ra_type,ra_provider = "heartbeat"): self.ra_class = ra_class self.ra_type = ra_type self.ra_provider = ra_provider if not self.ra_provider: self.ra_provider = "heartbeat" self.mk_ra_node() # indirectly caches meta-data and doc def ra_string(self): return self.ra_class == "ocf" and \ "%s:%s:%s" % (self.ra_class, self.ra_provider, self.ra_type) or \ "%s:%s" % (self.ra_class, self.ra_type) def error(self, s): common_err("%s: %s" % (self.ra_string(), s)) def warn(self, s): common_warn("%s: %s" % (self.ra_string(), s)) def add_extra_stonith_params(self): if not self.ra_node or not stonithd_metadata.ra_node: return try: params_node = self.doc.getElementsByTagName("parameters")[0] except: params_node = self.doc.createElement("parameters") self.ra_node.appendChild(params_node) for n in stonithd_metadata.ra_node.getElementsByTagName("parameter"): params_node.appendChild(self.doc.importNode(n,1)) def mk_ra_node(self): ''' Return the resource_agent node. ''' meta = self.meta() try: self.doc = xml.dom.minidom.parseString('\n'.join(meta)) except: #common_err("could not parse meta-data for (%s,%s,%s)" \ # % (self.ra_class,self.ra_type,self.ra_provider)) self.ra_node = None return try: self.ra_node = self.doc.getElementsByTagName("resource-agent")[0] except: self.error("meta-data contains no resource-agent element") self.ra_node = None if self.ra_class == "stonith": self.add_extra_stonith_params() def param_type_default(self,n): try: content = n.getElementsByTagName("content")[0] type = content.getAttribute("type") default = content.getAttribute("default") return type,default except: return None,None def params(self): ''' Construct a dict of dicts: parameters are keys and dictionary of attributes/values are values. Cached too. ''' id = "ra_params-%s" % self.ra_string() if wcache.is_cached(id): return wcache.retrieve(id) if not self.ra_node: return None d = {} for pset in self.ra_node.getElementsByTagName("parameters"): for c in pset.getElementsByTagName("parameter"): name = c.getAttribute("name") if not name: continue required = c.getAttribute("required") unique = c.getAttribute("unique") type,default = self.param_type_default(c) d[name] = { "required": required, "unique": unique, "type": type, "default": default, } return wcache.store(id,d) def actions(self): ''' Construct a dict of dicts: actions are keys and dictionary of attributes/values are values. Cached too. ''' id = "ra_actions-%s" % self.ra_string() if wcache.is_cached(id): return wcache.retrieve(id) if not self.ra_node: return None d = {} for pset in self.ra_node.getElementsByTagName("actions"): for c in pset.getElementsByTagName("action"): name = c.getAttribute("name") if not name or name in self.skip_ops: continue if name == "monitor": name = monitor_name_node(c) d[name] = {} for a in c.attributes.keys(): if a in self.skip_op_attr: continue v = c.getAttribute(a) if v: d[name][a] = v # add monitor ops without role, if they don't already # exist d2 = {} for op in d.keys(): if re.match("monitor_[^0-9]", op): norole_op = re.sub(r'monitor_[^0-9_]+_(.*)', r'monitor_\1', op) if not norole_op in d: d2[norole_op] = d[op] d.update(d2) return wcache.store(id,d) def reqd_params_list(self): ''' List of required parameters. ''' d = self.params() if not d: return [] return [x for x in d if d[x]["required"] == '1'] def param_default(self,pname): ''' Parameter's default. ''' d = self.params() if not d: return None return d[pname]["default"] def sanity_check_params(self, id, pl): ''' pl is a list of (attribute,value) pairs. - are all required parameters defined - do all parameters exist ''' rc = 0 d = {} for p,v in pl: d[p] = v for p in self.reqd_params_list(): if p not in d: common_err("%s: required parameter %s not defined" % (id,p)) rc |= user_prefs.get_check_rc() for p in d: if p not in self.params(): common_err("%s: parameter %s does not exist" % (id,p)) rc |= user_prefs.get_check_rc() return rc def sanity_check_ops(self, id, ops): ''' ops is a dict, operation names are keys and values are lists of (attribute,value) pairs. - do all operations exist - are timeouts sensible ''' rc = 0 n_ops = {} for op in ops: n_op = op == "monitor" and monitor_name_pl(ops[op]) or op n_ops[n_op] = {} for p,v in ops[op]: if p in self.skip_op_attr: continue n_ops[n_op][p] = v default_timeout = get_default("default-action-timeout") for req_op in self.required_ops: if req_op not in n_ops: n_ops[req_op] = {} for op in n_ops: if op not in self.actions(): - common_err("%s: action %s does not exist" % (id,op)) - rc |= user_prefs.get_check_rc() + common_warn("%s: action %s not advertised in meta-data, it may not be supported by the RA" % (id,op)) + rc |= 1 continue try: adv_timeout = self.actions()[op]["timeout"] except: continue for a in n_ops[op]: v = n_ops[op][a] if a == "timeout": if crm_msec(v) < 0: continue if crm_time_cmp(adv_timeout,v) > 0: common_warn("%s: timeout %s for %s is smaller than the advised %s" % \ (id,v,op,adv_timeout)) rc |= 1 return rc def meta(self): ''' RA meta-data as raw xml. ''' id = "ra_meta-%s" % self.ra_string() if wcache.is_cached(id): return wcache.retrieve(id) if self.ra_class in ("pengine","stonithd"): l = prog_meta(self.ra_class) else: l = lrmadmin("-M %s %s %s" % (self.ra_class,self.ra_type,self.ra_provider),True) return wcache.store(id, l) def meta_pretty(self): ''' Print the RA meta-data in a human readable form. ''' if not self.ra_node: return '' l = [] title = self.meta_title() l.append(title) longdesc = get_nodes_text(self.ra_node,"longdesc") if longdesc: l.append(longdesc) if self.ra_class != "heartbeat": params = self.meta_parameters() if params: l.append(params.rstrip()) actions = self.meta_actions() if actions: l.append(actions) return '\n\n'.join(l) def get_shortdesc(self,n): name = n.getAttribute("name") shortdesc = get_nodes_text(n,"shortdesc") longdesc = get_nodes_text(n,"longdesc") if shortdesc and shortdesc not in (name,longdesc,self.ra_type): return shortdesc return '' def meta_title(self): s = self.ra_string() shortdesc = self.get_shortdesc(self.ra_node) if shortdesc: s = "%s (%s)" % (shortdesc,s) return s def meta_param_head(self,n): name = n.getAttribute("name") if not name: return None s = name if n.getAttribute("required") == "1": s = s + "*" type,default = self.param_type_default(n) if type and default: s = "%s (%s, [%s])" % (s,type,default) elif type: s = "%s (%s)" % (s,type) shortdesc = self.get_shortdesc(n) s = "%s: %s" % (s,shortdesc) return s def format_parameter(self,n): l = [] head = self.meta_param_head(n) if not head: self.error("no name attribute for parameter") return "" l.append(head) longdesc = get_nodes_text(n,"longdesc") if longdesc: longdesc = self.ra_tab + longdesc.replace("\n","\n"+self.ra_tab) + '\n' l.append(longdesc) return '\n'.join(l) def meta_parameter(self,param): if not self.ra_node: return '' l = [] for pset in self.ra_node.getElementsByTagName("parameters"): for c in pset.getElementsByTagName("parameter"): if c.getAttribute("name") == param: return self.format_parameter(c) def meta_parameters(self): if not self.ra_node: return '' l = [] for pset in self.ra_node.getElementsByTagName("parameters"): for c in pset.getElementsByTagName("parameter"): s = self.format_parameter(c) if s: l.append(s) if l: return "Parameters (* denotes required, [] the default):\n\n" + '\n'.join(l) def meta_action_head(self,n): name = n.getAttribute("name") if not name: return '' if name in self.skip_ops: return '' if name == "monitor": name = monitor_name_node(n) s = "%-13s" % name for a in n.attributes.keys(): if a in self.skip_op_attr: continue v = n.getAttribute(a) if v: s = "%s %s=%s" % (s,a,v) return s def meta_actions(self): l = [] for aset in self.ra_node.getElementsByTagName("actions"): for c in aset.getElementsByTagName("action"): s = self.meta_action_head(c) if s: l.append(self.ra_tab + s) if l: return "Operations' defaults (advisory minimum):\n\n" + '\n'.join(l) def cmd_end(cmd,dir = ".."): "Go up one level." levels.droplevel() def cmd_exit(cmd): "Exit the crm program" cmd_end(cmd) if interactive: print "bye" try: readline.write_history_file(hist_file) except: pass for f in tmpfiles: os.unlink(f) sys.exit() # # help or make users feel less lonely # def add_shorthelp(topic,shorthelp,topic_help): ''' Join topics ("%s,%s") if they share the same short description. ''' for i in range(len(topic_help)): if topic_help[i][1] == shorthelp: topic_help[i][0] = "%s,%s" % (topic_help[i][0], topic) return topic_help.append([topic, shorthelp]) def dump_short_help(help_tab): topic_help = [] for topic in help_tab: if topic == '.': continue # with odict, for whatever reason, python parses differently: # help_tab["..."] = ("...","...") and # help_tab["..."] = ("...",""" # ...""") # a parser bug? if type(help_tab[topic][0]) == type(()): shorthelp = help_tab[topic][0][0] else: shorthelp = help_tab[topic][0] add_shorthelp(topic,shorthelp,topic_help) for t,d in topic_help: print "\t%-16s %s" % (t,d) def overview(help_tab): print "" print help_tab['.'][1] print "" print "Available commands:" print "" dump_short_help(help_tab) print "" def topic_help(help_tab,topic): if topic not in help_tab: print "There is no help for topic %s" % topic return if type(help_tab[topic][0]) == type(()): shorthelp = help_tab[topic][0][0] longhelp = help_tab[topic][0][1] else: shorthelp = help_tab[topic][0] longhelp = help_tab[topic][1] print longhelp or shorthelp def cmd_help(help_tab,topic = ''): "help!" # help_tab is an odict (ordered dictionary): # help_tab[topic] = (short_help,long_help) # topic '.' is a special entry for the top level if not topic: overview(help_tab) else: topic_help(help_tab,topic) def add_sudo(cmd): if user_prefs.crm_user: return "sudo -E -u %s %s"%(user_prefs.crm_user,cmd) return cmd def pipe_string(cmd,s): rc = -1 # command failed cmd = add_sudo(cmd) p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE) try: p.communicate(s) p.wait() rc = p.returncode except IOError, msg: common_err(msg) return rc def cibdump2doc(section = None): doc = None if section: cmd = "%s -o %s" % (cib_dump,section) else: cmd = cib_dump cmd = add_sudo(cmd) p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) try: doc = xmlparse(p.stdout) p.wait() except IOError, msg: common_err(msg) + return None return doc def file2doc(s): try: f = open(s,'r') except IOError, msg: common_err(msg) return None doc = xmlparse(f) f.close() return doc def shadow2doc(name): return file2doc(shadowfile(name)) def str2tmp(s): ''' Write the given string to a temporary file. Return the name of the file. ''' fd,tmp = mkstemp() try: f = os.fdopen(fd,"w") except IOError, msg: common_err(msg) return f.write(s) f.close() return tmp def is_filename_sane(name): if re.search("['`/#*?$\[\]]",name): common_err("%s: bad name"%name) return False return True def is_name_sane(name): if re.search("[']",name): common_err("%s: bad name"%name) return False return True def is_value_sane(name): if re.search("[']",name): common_err("%s: bad name"%name) return False return True def ext_cmd(cmd): if regression_tests: print ".EXT", cmd return subprocess.call(add_sudo(cmd), shell=True) def get_stdin(cmd, stderr_on = True): ''' Run a cmd, return stdin output. stderr_on controls whether to show output which comes on stderr. ''' if stderr_on: stderr = None else: stderr = subprocess.PIPE proc = subprocess.Popen(cmd, shell = True, \ stdout = subprocess.PIPE, stderr = stderr) outp = proc.communicate()[0] proc.wait() outp = outp.strip() return outp def stdin2list(cmd, stderr_on = True): ''' Run a cmd, fetch output, return it as a list of lines. stderr_on controls whether to show output which comes on stderr. ''' s = get_stdin(add_sudo(cmd), stderr_on) return s.split('\n') def find_program(envvar,*args): if envvar and os.getenv(envvar): return os.getenv(envvar) for prog in args: if is_program(prog): return prog def is_id_valid(id): """ Verify that the id follows the definition: http://www.w3.org/TR/1999/REC-xml-names-19990114/#ns-qualnames """ if not id: return False id_re = "^[A-Za-z_][\w._-]*$" return re.match(id_re,id) def check_filename(fname): """ Verify that the string is a filename. """ fname_re = "^[^/]+$" return re.match(fname_re,id) class UserPrefs(object): ''' Keep user preferences here. ''' dflt_colorscheme = "yellow,normal,cyan,red,green,magenta".split(',') skill_levels = {"operator":0, "administrator":1, "expert":2} output_types = ("plain", "color", "uppercase") check_frequencies = ("always", "on-verify", "never") check_modes = ("strict", "relaxed") def __init__(self): self.skill_level = 2 #TODO: set back to 0? self.editor = find_program("EDITOR","vim","vi","emacs","nano") self.pager = find_program("PAGER","less","more","pg") self.dotty = find_program("","dotty") if not self.editor: missing_prog_warn("editor") if not self.pager: missing_prog_warn("pager") self.crm_user = "" self.xmlindent = " " # two spaces # keywords,ids,attribute names,values self.colorscheme = self.dflt_colorscheme # plain or color self.output = ['color',] # the semantic checks preferences self.check_frequency = "always" self.check_mode = "strict" self.debug = False def check_skill_level(self,n): return self.skill_level >= n def set_skill_level(self,skill_level): if skill_level in self.skill_levels: self.skill_level = self.skill_levels[skill_level] else: common_err("no %s skill level"%skill_level) return False def get_skill_level(self): for s in self.skill_levels: if self.skill_level == self.skill_levels[s]: return s def set_editor(self,prog): if is_program(prog): self.editor = prog else: common_err("program %s does not exist"% prog) return False def set_pager(self,prog): if is_program(prog): self.pager = prog else: common_err("program %s does not exist"% prog) return False def set_crm_user(self,user = ''): self.crm_user = user def set_output(self,otypes): l = otypes.split(',') for otype in l: if not otype in self.output_types: common_err("no %s output type" % otype) return False self.output = l def set_colors(self,scheme): colors = scheme.split(',') if len(colors) != 6: common_err("bad color scheme: %s"%scheme) colors = UserPrefs.dflt_colorscheme rc = True for c in colors: if not termctrl.is_color(c): common_err("%s is not a recognized color" % c) rc = False if rc: self.colorscheme = colors else: self.output.remove("color") return rc def is_check_always(self): ''' Even though the frequency may be set to always, it doesn't make sense to do that with non-interactive sessions. ''' return interactive and self.check_frequency == "always" def get_check_rc(self): ''' If the check mode is set to strict, then on errors we return 2 which is the code for error. Otherwise, we pretend that errors are warnings. ''' return self.check_mode == "strict" and 2 or 1 def set_check_freq(self,frequency): if frequency not in self.check_frequencies: common_err("no %s check frequency"%frequency) return False self.check_frequency = frequency def set_check_mode(self,mode): if mode not in self.check_modes: common_err("no %s check mode"%mode) return False self.check_mode = mode def set_debug(self): self.debug = True def get_debug(self): return self.debug def write_rc(self,f): print >>f, '%s "%s"' % ("editor",self.editor) print >>f, '%s "%s"' % ("pager",self.pager) print >>f, '%s "%s"' % ("user",self.crm_user) print >>f, '%s "%s"' % ("skill-level",self.get_skill_level()) print >>f, '%s "%s"' % ("output", ','.join(self.output)) print >>f, '%s "%s"' % ("colorscheme", ','.join(self.colorscheme)) print >>f, '%s "%s"' % ("check-frequency",self.check_frequency) print >>f, '%s "%s"' % ("check-mode",self.check_mode) def save_options(self): try: f = open(rc_file,"w") except os.error,msg: common_err("open: %s"%msg) return print >>f, 'options' self.write_rc(f) print >>f, 'end' f.close() class CliOptions(object): ''' Manage user preferences ''' help_table = odict() help_table["."] = ("user preferences","Various user preferences may be set here.") help_table["skill-level"] = ("set skill level", "") help_table["editor"] = ("set prefered editor program", "") help_table["pager"] = ("set prefered pager program", "") help_table["user"] = ("set the cluster user", """ If you need extra privileges to talk to the cluster (i.e. the cib process), then set this to user. Typically, that is either "root" or "hacluster". Don't forget to setup the sudoers file as well. Example: user hacluster """) help_table["output"] = ("set output type", """ How to display configurations. Possible values are: "plain", "color", and "uppercase". The latter two may be combined: "color,uppercase". That is if you're really in the emphasis mood. """) help_table["colorscheme"] = ("set colors for output", """ With output set to color, a comma separated list of colors from this option are used to emphasize: - keywords - object ids - attribute names - attribute values - scores - resource references The colors are whatever is available in your terminal. Use "normal" if you want to keep the default foreground color. Example: ............... colorscheme yellow,normal,blue,red,green,magenta ............... """) help_table["check-frequency"] = ("when to perform semantic check", """ Semantic check of the CIB or elements modified or created may be done on every configuration change ("always"), when verifying ("on-verify") or "never". It is by default set to "always". Experts may want to change the setting to "on-verify". The checks require that resource agents are present. If they are not installed at the configuration time set this preference to "never". """) help_table["check-mode"] = ("how to treat semantic errors", """ Semantic check of the CIB or elements modified or created may be done in the "strict" mode or in the "relaxed" mode. In the former certain problems are treated as configuration errors. In the "relaxed" mode all are treated as warnings. The default is "strict". """) help_table["quit"] = ("exit the program", "") help_table["help"] = ("show help", "") help_table["end"] = ("go back one level", "") cmd_aliases = global_aliases def __init__(self): self.cmd_table = odict() self.cmd_table["skill-level"] = (self.set_skill_level,(1,1),0,(skills_list,)) self.cmd_table["editor"] = (self.set_editor,(1,1),0) self.cmd_table["pager"] = (self.set_pager,(1,1),0) self.cmd_table["user"] = (self.set_crm_user,(0,1),0) self.cmd_table["output"] = (self.set_output,(1,1),0) self.cmd_table["colorscheme"] = (self.set_colors,(1,1),0) self.cmd_table["check-frequency"] = (self.set_check_frequency,(1,1),0) self.cmd_table["check-mode"] = (self.set_check_mode,(1,1),0) self.cmd_table["save"] = (self.save_options,(0,0),0) self.cmd_table["show"] = (self.show_options,(0,0),0) self.cmd_table["help"] = (self.help,(0,1),0) self.cmd_table["quit"] = (cmd_exit,(0,0),0) self.cmd_table["end"] = (cmd_end,(0,1),0) setup_aliases(self) def set_skill_level(self,cmd,skill_level): """usage: skill-level level: operator | administrator | expert""" return user_prefs.set_skill_level(skill_level) def set_editor(self,cmd,prog): "usage: editor " return user_prefs.set_editor(prog) def set_pager(self,cmd,prog): "usage: pager " return user_prefs.set_pager(prog) def set_crm_user(self,cmd,user = ''): "usage: user []" return user_prefs.set_crm_user(user) def set_output(self,cmd,otypes): "usage: output " return user_prefs.set_output(otypes) def set_colors(self,cmd,scheme): "usage: colorscheme " return user_prefs.set_colors(scheme) def set_check_frequency(self,cmd,freq): "usage: check-frequence " return user_prefs.set_check_freq(freq) def set_check_mode(self,cmd,mode): "usage: check-mode " return user_prefs.set_check_mode(mode) def show_options(self,cmd): "usage: show" return user_prefs.write_rc(sys.stdout) def save_options(self,cmd): "usage: save" return user_prefs.save_options() def help(self,cmd,topic = ''): "usage: help []" cmd_help(self.help_table,topic) cib_dump = "cibadmin -Ql" cib_piped = "cibadmin -p" cib_upgrade = "cibadmin --upgrade --force" cib_verify = "crm_verify -V -p" class WCache(object): "Cache stuff. A naive implementation." def __init__(self): self.lists = {} self.stamp = time.time() self.max_cache_age = 600 # seconds def is_cached(self,name): if time.time() - self.stamp > self.max_cache_age: self.stamp = time.time() self.clear() return name in self.lists def store(self,name,lst): self.lists[name] = lst return lst def retrieve(self,name): if self.is_cached(name): return self.lists[name] else: return None def clear(self): self.lists = {} def listshadows(): return stdin2list("ls @CRM_CONFIG_DIR@ | fgrep shadow. | sed 's/^shadow\.//'") def shadowfile(name): return "@CRM_CONFIG_DIR@/shadow.%s" % name class CibShadow(object): ''' CIB shadow management class ''' help_table = odict() help_table["."] = ("",""" CIB shadow management. See the crm_shadow program. """) help_table["new"] = ("create a new shadow CIB", "") help_table["delete"] = ("delete a shadow CIB", "") help_table["reset"] = ("copy live cib to a shadow CIB", "") help_table["commit"] = ("copy a shadow CIB to the cluster", "") help_table["use"] = ("change working CIB", ''' Choose a shadow CIB for further changes. If the name provided is empty, then the live (cluster) CIB is used. ''') help_table["diff"] = ("diff between the shadow CIB and the live CIB", "") help_table["list"] = ("list all shadow CIBs", "") help_table["quit"] = ("exit the program", "") help_table["help"] = ("show help", "") help_table["end"] = ("go back one level", "") envvar = "CIB_shadow" extcmd = ">/dev/null &1" % self.extcmd) except os.error: no_prog_err(self.extcmd) return False return True def new(self,cmd,name,*args): "usage: new [withstatus] [force]" if not is_filename_sane(name): return False new_cmd = "%s -c '%s'" % (self.extcmd,name) for par in args: if not par in ("force","--force","withstatus"): syntax_err((cmd,name,par), context = 'new') return False if "force" in args or "--force" in args: new_cmd = "%s --force" % new_cmd if ext_cmd(new_cmd) == 0: common_info("%s shadow CIB created"%name) self.use("use",name) if "withstatus" in args: cib_status.load("shadow:%s" % name) def delete(self,cmd,name): "usage: delete " if not is_filename_sane(name): return False if cib_in_use == name: common_err("%s shadow CIB is in use"%name) return False if ext_cmd("%s -D '%s' --force" % (self.extcmd,name)) == 0: common_info("%s shadow CIB deleted"%name) else: common_err("failed to delete %s shadow CIB"%name) return False def reset(self,cmd,name): "usage: reset " if not is_filename_sane(name): return False if ext_cmd("%s -r '%s'" % (self.extcmd,name)) == 0: common_info("copied live CIB to %s"%name) else: common_err("failed to copy live CIB to %s"%name) return False def commit(self,cmd,name): "usage: commit " if not is_filename_sane(name): return False if ext_cmd("%s -C '%s' --force" % (self.extcmd,name)) == 0: common_info("commited '%s' shadow CIB to the cluster"%name) wcache.clear() else: common_err("failed to commit the %s shadow CIB"%name) return False def diff(self,cmd): "usage: diff" s = get_stdin(add_sudo("%s -d" % self.extcmd_stdout)) page_string(s) def list(self,cmd): "usage: list" if regression_tests: for t in listshadows(): print t else: multicolumn(listshadows()) def _use(self,name,withstatus): # Choose a shadow cib for further changes. If the name # provided is empty, then choose the live (cluster) cib. # Don't allow ' in shadow names global cib_in_use if not name or name == "live": os.unsetenv(self.envvar) cib_in_use = "" if withstatus: cib_status.load("live") else: os.putenv(self.envvar,name) cib_in_use = name if withstatus: cib_status.load("shadow:%s" % name) def use(self,cmd,name = '', withstatus = ''): "usage: use [] [withstatus]" # check the name argument if name and not is_filename_sane(name): return False if name and name != "live": if not os.access(shadowfile(name),os.F_OK): common_err("%s: no such shadow CIB"%name) return False if withstatus and withstatus != "withstatus": syntax_err((cmd,withstatus), context = 'use') return False # If invoked from configure # take special precautions try: prev_level = levels.previous().myname() except: prev_level = '' if prev_level != "cibconfig": self._use(name,withstatus) return True if not cib_factory.has_cib_changed(): self._use(name,withstatus) # new CIB: refresh the CIB factory cib_factory.refresh() return True saved_cib = cib_in_use self._use(name,'') # don't load the status yet if not cib_factory.is_current_cib_equal(silent = True): # user made changes and now wants to switch to a # different and unequal CIB; we refuse to cooperate common_err("you made changes and the requested CIB is different from the current one") common_info("either commit or refresh, then try again") self._use(saved_cib,'') # revert to the previous CIB return False else: # the requested CIB is equal self._use(name,withstatus) # now load the status too return True def help(self,cmd,topic = ''): cmd_help(self.help_table,topic) def get_var(l,key): for s in l: a = s.split() if len(a) == 2 and a[0] == key: return a[1] return '' def chk_var(l,key): for s in l: a = s.split() if len(a) == 2 and a[0] == key and a[1]: return True return False def chk_key(l,key): for s in l: a = s.split() if len(a) >= 1 and a[0] == key: return True return False def validate(l): if not chk_var(l,'%name'): common_err("invalid template: missing '%name'") return False if not chk_key(l,'%generate'): common_err("invalid template: missing '%generate'") return False if not (chk_key(l,'%required') or chk_key(l[0:g],'%optional')): common_err("invalid template: missing '%required' or '%optional'") return False return True def fix_tmpl_refs(l,id,pfx): for i in range(len(l)): l[i] = l[i].replace(id,pfx) def fix_tmpl_refs_re(l,regex,repl): for i in range(len(l)): l[i] = re.sub(regex,repl,l[i]) class LoadTemplate(object): ''' Load a template and its dependencies, generate a configuration file which should be relatively easy and straightforward to parse. ''' edit_instructions = '''# Edit instructions: # # Add content only at the end of lines starting with '%%'. # Only add content, don't remove or replace anything. # The parameters following '%required' are not optional, # unlike those following '%optional'. # You may also add comments for future reference.''' no_more_edit = '''# Don't edit anything below this line.''' def __init__(self,name): self.name = name self.all_pre_gen = [] self.all_post_gen = [] self.all_pfx = [] def new_pfx(self,name): i = 1 pfx = name while pfx in self.all_pfx: pfx = "%s_%d" % (name,i) i += 1 self.all_pfx.append(pfx) return pfx def generate(self): return '\n'.join([ \ "# Configuration: %s" % self.name, \ '', \ self.edit_instructions, \ '', \ '\n'.join(self.all_pre_gen), \ self.no_more_edit, \ '', \ '%generate', \ '\n'.join(self.all_post_gen)]) def write_config(self,name): try: f = open("%s/%s" % (Template.conf_dir, name),"w") except os.error,msg: common_err("open: %s"%msg) return False print >>f, self.generate() f.close() return True def load_template(self,tmpl): try: f = open("%s/%s" % (Template.tmpl_dir, tmpl)) except os.error,msg: common_err("open: %s"%msg) return '' l = (''.join(f)).split('\n') if not validate(l): return '' common_info("pulling in template %s" % tmpl) g = l.index('%generate') pre_gen = l[0:g] post_gen = l[g+1:] name = get_var(pre_gen,'%name') for s in l[0:g]: if s.startswith('%depends_on'): a = s.split() if len(a) != 2: common_warn("%s: wrong usage" % s) continue tmpl_id = a[1] tmpl_pfx = self.load_template(a[1]) if tmpl_pfx: fix_tmpl_refs(post_gen,'%'+tmpl_id,'%'+tmpl_pfx) pfx = self.new_pfx(name) fix_tmpl_refs(post_gen, '%_:', '%'+pfx+':') # replace remaining %_, it may be useful at times fix_tmpl_refs(post_gen, '%_', pfx) v_idx = pre_gen.index('%required') or pre_gen.index('%optional') pre_gen.insert(v_idx,'%pfx ' + pfx) self.all_pre_gen += pre_gen self.all_post_gen += post_gen return pfx def post_process(self): pfx_re = '(%s)' % '|'.join(self.all_pfx) fix_tmpl_refs_re(self.all_post_gen, \ '%'+pfx_re+'([^:]|$)', r'\1\2') # process %if ... [%else] ... %fi rmidx_l = [] if_seq = False for i in range(len(self.all_post_gen)): s = self.all_post_gen[i] if if_seq: a = s.split() if len(a) >= 1 and a[0] == '%fi': if_seq = False rmidx_l.append(i) elif len(a) >= 1 and a[0] == '%else': outcome = not outcome rmidx_l.append(i) else: if not outcome: rmidx_l.append(i) continue if not s: continue a = s.split() if len(a) == 2 and a[0] == '%if': outcome = not a[1].startswith('%') # not replaced -> false if_seq = True rmidx_l.append(i) rmidx_l.reverse() for i in rmidx_l: del self.all_post_gen[i] def listtemplates(): l = [] for f in os.listdir(Template.tmpl_dir): if os.path.isfile("%s/%s" % (Template.tmpl_dir,f)): l.append(f) return l def listconfigs(): l = [] for f in os.listdir(Template.conf_dir): if os.path.isfile("%s/%s" % (Template.conf_dir,f)): l.append(f) return l def check_transition(inp,state,possible_l): if not state in possible_l: common_err("input (%s) in wrong state %s" % (inp,state)) return False return True class Template(object): ''' Configuration templates. ''' help_table = odict() help_table["."] = ("",""" Configuration templates. """) help_table["new"] = ("create a new configuration from templates", """ Create a new configuration from one or more templates. Note that configurations and templates are kept in different places, so it is possible to have a configuration name equal a template name. Usage: ............... new