From dab0f86a204830b676f140c947b20e8b10b40f31 Mon Sep 17 00:00:00 2001 From: Ken Gaillot Date: Mar 09 2021 06:18:55 +0000 Subject: Log: scheduler: use new function to set a resource's next role This does downgrade one log from debug to trace, but that seems reasonable. Otherwise it adds a trace message whenever the next role is changed. --- diff --git a/lib/pacemaker/pcmk_sched_group.c b/lib/pacemaker/pcmk_sched_group.c index 439ed91..c9026e4 100644 --- a/lib/pacemaker/pcmk_sched_group.c +++ b/lib/pacemaker/pcmk_sched_group.c @@ -68,7 +68,8 @@ pcmk__group_allocate(pe_resource_t *rsc, pe_node_t *prefer, } } - rsc->next_role = group_data->first_child->next_role; + pe__set_next_role(rsc, group_data->first_child->next_role, + "first group member"); pe__clear_resource_flags(rsc, pe_rsc_allocating|pe_rsc_provisional); if (group_data->colocated) { diff --git a/lib/pacemaker/pcmk_sched_native.c b/lib/pacemaker/pcmk_sched_native.c index 6abada2..c050ead 100644 --- a/lib/pacemaker/pcmk_sched_native.c +++ b/lib/pacemaker/pcmk_sched_native.c @@ -581,7 +581,7 @@ pcmk__native_allocate(pe_resource_t *rsc, pe_node_t *prefer, && data_set->no_quorum_policy == no_quorum_freeze) { crm_notice("Resource %s cannot be elevated from %s to %s: no-quorum-policy=freeze", rsc->id, role2text(rsc->role), role2text(rsc->next_role)); - rsc->next_role = rsc->role; + pe__set_next_role(rsc, rsc->role, "no-quorum-policy=freeze"); } pe__show_node_weights(!show_scores, rsc, __func__, rsc->allowed_nodes); @@ -594,7 +594,7 @@ pcmk__native_allocate(pe_resource_t *rsc, pe_node_t *prefer, const char *reason = NULL; pe_node_t *assign_to = NULL; - rsc->next_role = rsc->role; + pe__set_next_role(rsc, rsc->role, "unmanaged"); assign_to = pe__current_node(rsc); if (assign_to == NULL) { reason = "inactive"; @@ -1226,7 +1226,9 @@ native_create_actions(pe_resource_t * rsc, pe_working_set_t * data_set) chosen = rsc->allocated_to; next_role = rsc->next_role; if (next_role == RSC_ROLE_UNKNOWN) { - rsc->next_role = (chosen == NULL)? RSC_ROLE_STOPPED : RSC_ROLE_STARTED; + pe__set_next_role(rsc, + (chosen == NULL)? RSC_ROLE_STOPPED : RSC_ROLE_STARTED, + "allocation"); } pe_rsc_trace(rsc, "Creating all actions for %s transition from %s to %s (%s) on %s", rsc->id, role2text(rsc->role), role2text(rsc->next_role), diff --git a/lib/pacemaker/pcmk_sched_promotable.c b/lib/pacemaker/pcmk_sched_promotable.c index 40d07e9..f3bde0c 100644 --- a/lib/pacemaker/pcmk_sched_promotable.c +++ b/lib/pacemaker/pcmk_sched_promotable.c @@ -622,13 +622,8 @@ set_role_slave(pe_resource_t * rsc, gboolean current) GListPtr allocated = NULL; rsc->fns->location(rsc, &allocated, FALSE); - - if (allocated) { - rsc->next_role = RSC_ROLE_SLAVE; - - } else { - rsc->next_role = RSC_ROLE_STOPPED; - } + pe__set_next_role(rsc, (allocated? RSC_ROLE_SLAVE : RSC_ROLE_STOPPED), + "unpromoted instance"); g_list_free(allocated); } @@ -645,7 +640,7 @@ set_role_master(pe_resource_t * rsc) GListPtr gIter = rsc->children; if (rsc->next_role == RSC_ROLE_UNKNOWN) { - rsc->next_role = RSC_ROLE_MASTER; + pe__set_next_role(rsc, RSC_ROLE_MASTER, "promoted instance"); } for (; gIter != NULL; gIter = gIter->next) { diff --git a/lib/pacemaker/pcmk_sched_utils.c b/lib/pacemaker/pcmk_sched_utils.c index eaaf526..177f43e 100644 --- a/lib/pacemaker/pcmk_sched_utils.c +++ b/lib/pacemaker/pcmk_sched_utils.c @@ -1,5 +1,5 @@ /* - * Copyright 2004-2020 the Pacemaker project contributors + * Copyright 2004-2021 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -287,7 +287,7 @@ native_assign_node(pe_resource_t * rsc, GListPtr nodes, pe_node_t * chosen, gboo crm_debug("All nodes for resource %s are unavailable" ", unclean or shutting down (%s: %d, %d)", rsc->id, chosen->details->uname, can_run_resources(chosen), chosen->weight); - rsc->next_role = RSC_ROLE_STOPPED; + pe__set_next_role(rsc, RSC_ROLE_STOPPED, "node availability"); chosen = NULL; } } @@ -304,7 +304,7 @@ native_assign_node(pe_resource_t * rsc, GListPtr nodes, pe_node_t * chosen, gboo char *rc_inactive = crm_itoa(PCMK_OCF_NOT_RUNNING); crm_debug("Could not allocate a node for %s", rsc->id); - rsc->next_role = RSC_ROLE_STOPPED; + pe__set_next_role(rsc, RSC_ROLE_STOPPED, "unable to allocate"); for (gIter = rsc->actions; gIter != NULL; gIter = gIter->next) { pe_action_t *op = (pe_action_t *) gIter->data; diff --git a/lib/pengine/unpack.c b/lib/pengine/unpack.c index 19cde7a..ce51429 100644 --- a/lib/pengine/unpack.c +++ b/lib/pengine/unpack.c @@ -980,7 +980,7 @@ unpack_handle_remote_attrs(pe_node_t *this_node, xmlNode *state, pe_working_set_ crm_info("Node %s is shutting down", this_node->details->uname); this_node->details->shutdown = TRUE; if (rsc) { - rsc->next_role = RSC_ROLE_STOPPED; + pe__set_next_role(rsc, RSC_ROLE_STOPPED, "remote shutdown"); } } @@ -2060,7 +2060,7 @@ process_rsc_state(pe_resource_t * rsc, pe_node_t * node, break; case action_fail_stop: - rsc->next_role = RSC_ROLE_STOPPED; + pe__set_next_role(rsc, RSC_ROLE_STOPPED, "on-fail=stop"); break; case action_fail_recover: @@ -2114,7 +2114,7 @@ process_rsc_state(pe_resource_t * rsc, pe_node_t * node, /* if reconnect delay is in use, prevent the connection from exiting the * "STOPPED" role until the failure is cleared by the delay timeout. */ if (rsc->remote_reconnect_ms) { - rsc->next_role = RSC_ROLE_STOPPED; + pe__set_next_role(rsc, RSC_ROLE_STOPPED, "remote reset"); } break; } @@ -2405,10 +2405,7 @@ unpack_lrm_resource(pe_node_t *node, xmlNode *lrm_resource, if (get_target_role(rsc, &req_role)) { if (rsc->next_role == RSC_ROLE_UNKNOWN || req_role < rsc->next_role) { - pe_rsc_debug(rsc, "%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; + pe__set_next_role(rsc, req_role, XML_RSC_ATTR_TARGET_ROLE); } else if (req_role > rsc->next_role) { pe_rsc_info(rsc, "%s: Not overwriting calculated next role %s" @@ -3052,7 +3049,8 @@ unpack_rsc_op_failure(pe_resource_t * rsc, pe_node_t * node, int rc, xmlNode * x } else if (!strcmp(task, CRMD_ACTION_DEMOTE)) { if (action->on_fail == action_fail_block) { rsc->role = RSC_ROLE_MASTER; - rsc->next_role = RSC_ROLE_STOPPED; + pe__set_next_role(rsc, RSC_ROLE_STOPPED, + "demote with on-fail=block"); } else if(rc == PCMK_OCF_NOT_RUNNING) { rsc->role = RSC_ROLE_STOPPED; @@ -3083,7 +3081,7 @@ unpack_rsc_op_failure(pe_resource_t * rsc, pe_node_t * node, int rc, xmlNode * x 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; + pe__set_next_role(rsc, action->fail_role, "failure"); } if (action->fail_role == RSC_ROLE_STOPPED) { @@ -3200,7 +3198,7 @@ determine_op_status( /* clear any previous failure actions */ *on_fail = action_fail_ignore; - rsc->next_role = RSC_ROLE_UNKNOWN; + pe__set_next_role(rsc, RSC_ROLE_UNKNOWN, "not running"); } break; @@ -3595,7 +3593,7 @@ update_resource_state(pe_resource_t * rsc, pe_node_t * node, xmlNode * xml_op, c case action_fail_recover: case action_fail_restart_container: *on_fail = action_fail_ignore; - rsc->next_role = RSC_ROLE_UNKNOWN; + pe__set_next_role(rsc, RSC_ROLE_UNKNOWN, "clear past failures"); break; case action_fail_reset_remote: if (rsc->remote_reconnect_ms == 0) { @@ -3606,7 +3604,8 @@ update_resource_state(pe_resource_t * rsc, pe_node_t * node, xmlNode * xml_op, c * to reconnect.) */ *on_fail = action_fail_ignore; - rsc->next_role = RSC_ROLE_UNKNOWN; + pe__set_next_role(rsc, RSC_ROLE_UNKNOWN, + "clear past failures and reset remote"); } break; } diff --git a/lib/pengine/utils.c b/lib/pengine/utils.c index 831f890..dbfe048 100644 --- a/lib/pengine/utils.c +++ b/lib/pengine/utils.c @@ -1,5 +1,5 @@ /* - * Copyright 2004-2020 the Pacemaker project contributors + * Copyright 2004-2021 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -450,7 +450,8 @@ effective_quorum_policy(pe_resource_t *rsc, pe_working_set_t *data_set) case RSC_ROLE_MASTER: case RSC_ROLE_SLAVE: if (rsc->next_role > RSC_ROLE_SLAVE) { - rsc->next_role = RSC_ROLE_SLAVE; + pe__set_next_role(rsc, RSC_ROLE_SLAVE, + "no-quorum-policy=demote"); } policy = no_quorum_ignore; break;