31 #define RSC_ROLE_MAX (pcmk_role_promoted + 1) 174 if (prefer == NULL) {
175 prefer = most_free_node;
184 nodes = sorted_allowed_nodes(rsc);
189 if ((prefer != NULL) && (nodes != NULL)) {
193 if (chosen == NULL) {
195 pcmk__node_name(prefer), rsc->
id);
205 pcmk__node_name(chosen), rsc->
id);
210 pcmk__node_name(chosen), rsc->
id);
215 "Chose preferred node %s for %s " 216 "(ignoring %d candidates)",
217 pcmk__node_name(chosen), rsc->
id,
218 g_list_length(nodes));
222 if ((chosen == NULL) && (best != NULL)) {
229 if (!pcmk__is_unique_clone(rsc->
parent)
243 if (running == NULL) {
248 "Current node for %s (%s) can't run resources",
249 rsc->
id, pcmk__node_name(running));
252 int nodes_with_best_score = 1;
254 for (GList *iter = nodes->next; iter; iter = iter->next) {
261 if (pcmk__same_node(allowed, running)) {
265 nodes_with_best_score++;
268 if (nodes_with_best_score > 1) {
269 uint8_t log_level = LOG_INFO;
272 log_level = LOG_WARNING;
275 "Chose %s for %s from %d nodes with score %s",
276 pcmk__node_name(chosen), rsc->
id,
277 nodes_with_best_score,
284 pcmk__node_name(chosen), rsc->
id, g_list_length(nodes));
302 GHashTable *archive = NULL;
307 || ((colocation->
score < 0)
314 "%s: Assigning colocation %s primary %s first" 315 "(score=%d role=%s)",
316 rsc->
id, colocation->
id, other->
id,
324 if ((archive != NULL)
327 "%s: Reverting scores from colocation with %s " 328 "because no nodes allowed",
334 if (archive != NULL) {
335 g_hash_table_destroy(archive);
356 crm_trace(
"Pacemaker Remote node %s will be online",
365 crm_trace(
"Pacemaker Remote node %s will be shut down " 366 "(%sassigned connection's next role is %s)",
396 GList *this_with_colocations = NULL;
397 GList *with_this_colocations = NULL;
413 const char *node_name =
"no node";
436 for (iter = this_with_colocations; iter != NULL; iter = iter->next) {
437 colocation = iter->data;
441 apply_this_with(colocation, rsc);
444 for (iter = with_this_colocations; iter != NULL; iter = iter->next) {
445 colocation = iter->data;
457 for (iter = this_with_colocations; iter != NULL; iter = iter->next) {
458 colocation = iter->data;
462 apply_this_with(colocation, rsc);
465 for (iter = with_this_colocations; iter != NULL; iter = iter->next) {
466 colocation = iter->data;
474 g_list_free(this_with_colocations);
475 g_list_free(with_this_colocations);
479 "Banning %s from all nodes because it will be stopped",
487 crm_notice(
"Resource %s cannot be elevated from %s to %s due to " 507 const char *reason = NULL;
511 assign_to = pcmk__current_node(rsc);
512 if (assign_to == NULL) {
535 }
else if (!assign_best_node(rsc, prefer, stop_if_fail)) {
539 }
else if ((rsc->
running_on != NULL) && stop_if_fail) {
547 remote_connection_assigned(rsc);
566 bool need_stop,
bool need_promote)
577 pcmk__rsc_trace(rsc,
"Creating %s action to take %s down from %s to %s",
578 (need_stop?
"required" :
"optional"), rsc->
id,
580 fn = rsc_action_matrix[role][next_role];
584 fn(rsc, current, !need_stop);
591 bool required = need_stop;
593 next_role = rsc_state_matrix[role][rsc->
role];
598 (required?
"required" :
"optional"), rsc->
id,
600 fn = rsc_action_matrix[role][next_role];
646 "Creating action for %s to represent already pending start",
668 "Creating action to take %s from %s to %s " 673 fn = rsc_action_matrix[role][next_role];
691 bool need_stop =
false;
692 bool need_promote =
false;
693 bool is_moving =
false;
694 bool allow_migrate =
false;
695 bool multiply_active =
false;
698 unsigned int num_all_active = 0;
699 unsigned int num_clean_active = 0;
700 const char *next_role_source = NULL;
704 next_role_source = set_default_next_role(rsc);
706 "Creating all actions for %s transition from %s to %s " 712 current = rsc->
fns->
active_node(rsc, &num_all_active, &num_clean_active);
722 rsc->
id, pcmk__node_name(current),
734 && allow_migrate && (num_all_active == 2)
741 "Partial migration of %s from %s to %s will continue",
749 if (num_all_active > 2) {
751 crm_notice(
"Forcing recovery of %s because it is migrating " 752 "from %s to %s and possibly active elsewhere",
757 crm_notice(
"Forcing recovery of %s because it can no longer " 758 "migrate from %s to %s",
764 allow_migrate =
false;
767 multiply_active = (num_all_active > 1);
776 multiply_active = (num_clean_active > 1);
779 if (multiply_active) {
784 pcmk__s(
class,
"Untyped"), rsc->id, num_all_active,
786 crm_notice(
"For more information, see \"What are multiply active " 788 "https://projects.clusterlabs.org/w/clusterlabs/faq/");
790 switch (rsc->recovery_type) {
807 create_pending_start(rsc);
843 schedule_restart_actions(rsc, current, need_stop, need_promote);
846 schedule_role_transition_actions(rsc);
868 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
869 if (node->details->remote_rsc != NULL) {
891 GList *allowed_nodes = NULL;
901 return allowed_nodes;
913 GList *allowed_nodes = NULL;
914 bool check_unfencing =
false;
915 bool check_utilization =
false;
921 "Skipping implicit constraints for unmanaged resource " 933 check_utilization = (g_hash_table_size(rsc->
utilization) > 0)
972 if (check_unfencing || check_utilization || (rsc->
container != NULL)) {
973 allowed_nodes = allowed_nodes_as_list(rsc);
976 if (check_unfencing) {
980 if (check_utilization) {
1021 if (remote_rsc != NULL) {
1025 for (GList *item = allowed_nodes; item; item = item->next) {
1040 crm_trace(
"Order and colocate %s relative to its container %s",
1077 rsc_avoids_remote_nodes(rsc);
1079 g_list_free(allowed_nodes);
1105 CRM_ASSERT((dependent != NULL) && (primary != NULL)
1106 && (colocation != NULL));
1108 if (for_dependent) {
1117 ((colocation->
score > 0)?
"Colocating" :
"Anti-colocating"),
1118 dependent->
id, primary->
id, colocation->
id,
1122 switch (filter_results) {
1143 CRM_ASSERT(pcmk__is_primitive(rsc) && (list != NULL));
1145 if (rsc == orig_rsc) {
1150 if (rsc->
parent != NULL) {
1155 for (GList *iter = rsc->
rsc_cons_lhs; iter != NULL; iter = iter->next) {
1172 CRM_ASSERT(pcmk__is_primitive(rsc) && (list != NULL));
1174 if (rsc == orig_rsc) {
1179 if (rsc->
parent != NULL) {
1184 for (GList *iter = rsc->
rsc_cons; iter != NULL; iter = iter->next) {
1207 return (uint32_t)
action->flags;
1227 return pcmk_all_flags_set(rsc->
flags,
1244 for (GList *iter = rsc->
running_on; iter != NULL; iter = iter->next) {
1248 if (is_expected_node(rsc, current)) {
1254 "Skipping stop of multiply active resource %s " 1255 "on expected node %s",
1256 rsc->
id, pcmk__node_name(current));
1265 "Skipping stop of %s on %s " 1266 "because partial migration there will continue",
1267 rsc->
id, pcmk__node_name(current));
1271 "Forcing stop of %s on %s " 1272 "because migration target changed",
1273 rsc->
id, pcmk__node_name(current));
1279 rsc->
id, pcmk__node_name(current));
1308 rsc->
id, pcmk__node_name(current));
1330 (optional?
"optional" :
"required"), rsc->
id,
1331 pcmk__node_name(node), node->
weight);
1340 if (is_expected_node(rsc, node)) {
1345 "Start of multiply active resouce %s " 1346 "on expected node %s will be a pseudo-action",
1347 rsc->
id, pcmk__node_name(node));
1364 GList *action_list = NULL;
1365 bool runnable =
true;
1371 for (iter = action_list; iter != NULL; iter = iter->next) {
1378 g_list_free(action_list);
1384 (optional?
"optional" :
"required"), rsc->
id,
1385 pcmk__node_name(node));
1387 if (is_expected_node(rsc, node)) {
1392 "Promotion of multiply active resouce %s " 1393 "on expected node %s will be a pseudo-action",
1394 rsc->
id, pcmk__node_name(node));
1399 rsc->
id, pcmk__node_name(node));
1402 for (iter = action_list; iter != NULL; iter = iter->next) {
1407 g_list_free(action_list);
1427 for (GList *iter = rsc->
running_on; iter != NULL; iter = iter->next) {
1430 if (is_expected_node(rsc, current)) {
1432 "Skipping demote of multiply active resource %s " 1433 "on expected node %s",
1434 rsc->
id, pcmk__node_name(current));
1437 (optional?
"optional" :
"required"), rsc->
id,
1438 pcmk__node_name(current));
1469 CRM_CHECK((rsc != NULL) && (node != NULL),
return);
1472 pcmk__rsc_trace(rsc,
"Skipping clean-up of %s on %s: resource failed",
1473 rsc->
id, pcmk__node_name(node));
1478 pcmk__rsc_trace(rsc,
"Skipping clean-up of %s on %s: node unavailable",
1479 rsc->
id, pcmk__node_name(node));
1483 crm_notice(
"Scheduling clean-up of %s on %s",
1484 rsc->
id, pcmk__node_name(node));
1508 CRM_ASSERT(pcmk__is_primitive(rsc) && (xml != NULL));
1515 if (value != NULL) {
1523 if (value != NULL) {
1534 if (
parent->container != NULL) {
1544 value = g_hash_table_lookup(rsc->
meta,
"external-ip");
1545 if (value != NULL) {
1554 GList *all_rscs, GHashTable *utilization)
1557 && (orig_rsc != NULL) && (utilization != NULL));
1564 "%s: Adding primitive %s as colocated utilization",
1565 orig_rsc->
id, rsc->
id);
1584 if (shutdown != NULL) {
1585 long long result_ll;
1588 result = (time_t) result_ll;
1602 ban_if_not_locked(gpointer
data, gpointer user_data)
1617 const char *
class = NULL;
1625 || rsc->is_remote_node) {
1629 if (rsc->lock_node != NULL) {
1632 if (rsc->running_on != NULL) {
1638 "Cancelling shutdown lock " 1639 "because %s is already active", rsc->id);
1641 rsc->lock_node = NULL;
1646 }
else if (pcmk__list_of_1(rsc->running_on)) {
1652 "Not locking %s to unclean %s for shutdown",
1653 rsc->id, pcmk__node_name(node));
1655 rsc->lock_node = node;
1656 rsc->lock_time = shutdown_time(node);
1661 if (rsc->lock_node == NULL) {
1666 if (rsc->cluster->shutdown_lock > 0) {
1667 time_t lock_expiration = rsc->lock_time + rsc->cluster->shutdown_lock;
1669 pcmk__rsc_info(rsc,
"Locking %s to %s due to shutdown (expires @%lld)",
1670 rsc->id, pcmk__node_name(rsc->lock_node),
1671 (
long long) lock_expiration);
1673 "shutdown lock expiration");
1676 rsc->id, pcmk__node_name(rsc->lock_node));
1680 g_list_foreach(rsc->cluster->nodes, ban_if_not_locked, rsc);
pcmk_assignment_methods_t * cmds
const pcmk_resource_t * pe__const_top_resource(const pcmk_resource_t *rsc, bool include_bundle)
#define CRM_CHECK(expr, failure_action)
pcmk_resource_t * pe__resource_contains_guest_node(const pcmk_scheduler_t *scheduler, const pcmk_resource_t *rsc)
pcmk_node_t * pcmk_find_node(const pcmk_scheduler_t *scheduler, const char *node_name)
Find a node by name in scheduler data.
Relation applies only if actions are on same node.
enum pe_quorum_policy no_quorum_policy
#define crm_notice(fmt, args...)
'then' is runnable (and migratable) only if 'first' is runnable
pcmk_scheduler_t * cluster
const char * pcmk_role_text(enum rsc_role_e role)
Get readable description of a resource role.
#define PCMK__NODE_ATTR_SHUTDOWN
pcmk_node_t * partial_migration_target
#define promote_action(rsc, node, optional)
G_GNUC_INTERNAL void pcmk__new_ordering(pcmk_resource_t *first_rsc, char *first_task, pcmk_action_t *first_action, pcmk_resource_t *then_rsc, char *then_task, pcmk_action_t *then_action, uint32_t flags, pcmk_scheduler_t *sched)
G_GNUC_INTERNAL void pcmk__order_vs_unfence(const pcmk_resource_t *rsc, pcmk_node_t *node, pcmk_action_t *action, enum pcmk__action_relation_flags order)
#define stop_action(rsc, node, optional)
G_GNUC_INTERNAL void pcmk__create_utilization_constraints(pcmk_resource_t *rsc, const GList *allowed_nodes)
const char * pcmk_readable_score(int score)
Return a displayable static string for a score value.
G_GNUC_INTERNAL void pcmk__release_node_capacity(GHashTable *current_utilization, const pcmk_resource_t *rsc)
G_GNUC_INTERNAL bool pcmk__any_node_available(GHashTable *nodes)
gint pe__cmp_node_name(gconstpointer a, gconstpointer b)
#define pcmk__rsc_trace(rsc, fmt, args...)
bool pcmk__rsc_can_migrate(const pcmk_resource_t *rsc, const pcmk_node_t *current)
gboolean order_actions(pcmk_action_t *lh_action, pcmk_action_t *rh_action, uint32_t flags)
#define delete_action(rsc, node, optional)
#define pcmk__rsc_info(rsc, fmt, args...)
#define PCMK_OPT_SHUTDOWN_LOCK
enum rsc_role_e next_role
#define PCMK_ACTION_MONITOR
void pcmk__schedule_cleanup(pcmk_resource_t *rsc, const pcmk_node_t *node, bool optional)
void pcmk__primitive_add_utilization(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList *all_rscs, GHashTable *utilization)
pcmk_action_t * pe_fence_op(pcmk_node_t *node, const char *op, bool optional, const char *reason, bool priority_delay, pcmk_scheduler_t *scheduler)
#define PCMK_VALUE_DEFAULT
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
void pe_action_set_reason(pcmk_action_t *action, const char *reason, bool overwrite)
G_GNUC_INTERNAL const pcmk_node_t * pcmk__ban_insufficient_capacity(pcmk_resource_t *rsc)
void pcmk__primitive_internal_constraints(pcmk_resource_t *rsc)
pcmk_node_t *(* assign)(pcmk_resource_t *rsc, const pcmk_node_t *prefer, bool stop_if_fail)
GList * pe__resource_actions(const pcmk_resource_t *rsc, const pcmk_node_t *node, const char *task, bool require_node)
Find all actions of given type for a resource.
pcmk_scheduler_t * data_set
pcmk_resource_t * container
G_GNUC_INTERNAL bool pcmk__node_available(const pcmk_node_t *node, bool consider_score, bool consider_guest)
G_GNUC_INTERNAL bool pcmk__assign_resource(pcmk_resource_t *rsc, pcmk_node_t *node, bool force, bool stop_if_fail)
G_GNUC_INTERNAL void pcmk__apply_coloc_to_scores(pcmk_resource_t *dependent, const pcmk_resource_t *primary, const pcmk__colocation_t *colocation)
#define pcmk__rsc_debug(rsc, fmt, args...)
void(* with_this_colocations)(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList **list)
#define demote_action(rsc, node, optional)
const char * pcmk__multiply_active_text(enum rsc_recovery_type recovery)
Get readable description of a multiply-active recovery type.
#define PCMK_ACTION_DEMOTE
int pcmk__scan_ll(const char *text, long long *result, long long default_value)
GList * dangling_migrations
void pe__set_next_role(pcmk_resource_t *rsc, enum rsc_role_e role, const char *why)
G_GNUC_INTERNAL void pcmk__add_with_this_list(GList **list, GList *addition, const pcmk_resource_t *rsc)
G_GNUC_INTERNAL int pcmk__apply_coloc_to_priority(pcmk_resource_t *dependent, const pcmk_resource_t *primary, const pcmk__colocation_t *colocation)
pcmk_node_t * pcmk__primitive_assign(pcmk_resource_t *rsc, const pcmk_node_t *prefer, bool stop_if_fail)
Actions are ordered (optionally, if no other flags are set)
#define pcmk__clear_action_flags(action, flags_to_clear)
G_GNUC_INTERNAL void pcmk__create_recurring_actions(pcmk_resource_t *rsc)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define PCMK_OPT_STOP_ALL_RESOURCES
void resource_location(pcmk_resource_t *rsc, const pcmk_node_t *node, int score, const char *tag, pcmk_scheduler_t *scheduler)
#define pcmk__sched_err(fmt...)
G_GNUC_INTERNAL void pcmk__add_this_with(GList **list, const pcmk__colocation_t *colocation, const pcmk_resource_t *rsc)
void(* this_with_colocations)(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList **list)
#define crm_trace(fmt, args...)
#define do_crm_log(level, fmt, args...)
Log a message.
#define PCMK_RESOURCE_CLASS_STONITH
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
#define PCMK_META_REMOTE_NODE
struct pe_node_shared_s * details
#define PCMK_ACTION_START
Wrappers for and extensions to libxml2.
G_GNUC_INTERNAL void pcmk__add_with_this(GList **list, const pcmk__colocation_t *colocation, const pcmk_resource_t *rsc)
void pcmk__create_migration_actions(pcmk_resource_t *rsc, const pcmk_node_t *current)
#define PCMK_META_TARGET_ROLE
void pcmk__primitive_create_actions(pcmk_resource_t *rsc)
#define pcmk__set_rsc_flags(resource, flags_to_set)
#define PCMK_ACTION_DELETE
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
void pcmk__primitive_shutdown_lock(pcmk_resource_t *rsc)
const char * placement_strategy
G_GNUC_INTERNAL void pcmk__order_restart_vs_unfence(gpointer data, gpointer user_data)
void pe__update_recheck_time(time_t recheck, pcmk_scheduler_t *scheduler, const char *reason)
#define pcmk__order_resource_actions(first_rsc, first_task, then_rsc, then_task, flags)
pcmk_resource_t * primary
void pcmk__with_primitive_colocations(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList **list)
#define PCMK_ACTION_LRM_DELETE
G_GNUC_INTERNAL enum pcmk__coloc_affects pcmk__colocation_affects(const pcmk_resource_t *dependent, const pcmk_resource_t *primary, const pcmk__colocation_t *colocation, bool preview)
G_GNUC_INTERNAL GList * pcmk__with_this_colocations(const pcmk_resource_t *rsc)
pcmk__action_result_t result
G_GNUC_INTERNAL void pcmk__add_dependent_scores(gpointer data, gpointer user_data)
#define start_action(rsc, node, optional)
G_GNUC_INTERNAL GHashTable * pcmk__copy_node_table(GHashTable *nodes)
G_GNUC_INTERNAL void pcmk__add_this_with_list(GList **list, GList *addition, const pcmk_resource_t *rsc)
G_GNUC_INTERNAL bool pcmk__node_unfenced(const pcmk_node_t *node)
void(* rsc_transition_fn)(pcmk_resource_t *rsc, pcmk_node_t *node, bool optional)
G_GNUC_INTERNAL GList * pcmk__this_with_colocations(const pcmk_resource_t *rsc)
const char * pcmk__node_attr(const pcmk_node_t *node, const char *name, const char *target, enum pcmk__rsc_node node_type)
pcmk_node_t *(* active_node)(const pcmk_resource_t *rsc, unsigned int *count_all, unsigned int *count_clean)
pcmk_node_t * allocated_to
If 'then' action becomes required, 'first' becomes optional.
#define PCMK_ACTION_PROMOTE
#define PCMK_OPT_NO_QUORUM_POLICY
#define pe__show_node_scores(level, rsc, text, nodes, scheduler)
enum pe_action_flags flags
void pe__clear_resource_history(pcmk_resource_t *rsc, const pcmk_node_t *node)
#define pcmk__set_action_flags(action, flags_to_set)
uint32_t pcmk__primitive_action_flags(pcmk_action_t *action, const pcmk_node_t *node)
void pcmk__primitive_add_graph_meta(const pcmk_resource_t *rsc, xmlNode *xml)
G_GNUC_INTERNAL GList * pcmk__sort_nodes(GList *nodes, pcmk_node_t *active_node)
#define PCMK__META_CONTAINER
G_GNUC_INTERNAL void pcmk__new_colocation(const char *id, const char *node_attr, int score, pcmk_resource_t *dependent, pcmk_resource_t *primary, const char *dependent_role, const char *primary_role, uint32_t flags)
void pcmk__primitive_with_colocations(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList **list)
Resource role is unknown.
#define PCMK_VALUE_FREEZE
time_t get_effective_time(pcmk_scheduler_t *scheduler)
int pcmk__primitive_apply_coloc_score(pcmk_resource_t *dependent, const pcmk_resource_t *primary, const pcmk__colocation_t *colocation, bool for_dependent)
#define pcmk__clear_rsc_flags(resource, flags_to_clear)
int(* apply_coloc_score)(pcmk_resource_t *dependent, const pcmk_resource_t *primary, const pcmk__colocation_t *colocation, bool for_dependent)
void pcmk__abort_dangling_migration(void *data, void *user_data)
pcmk_resource_t * remote_rsc
pcmk_node_t * partial_migration_source
#define PCMK_SCORE_INFINITY
Integer score to use to represent "infinity".
GHashTable * allowed_nodes
Where resource is running.
char * crm_meta_name(const char *field)
Get the environment variable equivalent of a meta-attribute name.