summaryrefslogtreecommitdiffstats
path: root/lib/pengine/utils.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/pengine/utils.c331
1 files changed, 152 insertions, 179 deletions
diff --git a/lib/pengine/utils.c b/lib/pengine/utils.c
index ef0a092..4055d6d 100644
--- a/lib/pengine/utils.c
+++ b/lib/pengine/utils.c
@@ -27,40 +27,40 @@ gboolean ghash_free_str_str(gpointer key, gpointer value, gpointer user_data);
* \internal
* \brief Check whether we can fence a particular node
*
- * \param[in] data_set Working set for cluster
- * \param[in] node Name of node to check
+ * \param[in] scheduler Scheduler data
+ * \param[in] node Name of node to check
*
* \return true if node can be fenced, false otherwise
*/
bool
-pe_can_fence(const pe_working_set_t *data_set, const pe_node_t *node)
+pe_can_fence(const pcmk_scheduler_t *scheduler, const pcmk_node_t *node)
{
if (pe__is_guest_node(node)) {
/* Guest nodes are fenced by stopping their container resource. We can
* do that if the container's host is either online or fenceable.
*/
- pe_resource_t *rsc = node->details->remote_rsc->container;
+ pcmk_resource_t *rsc = node->details->remote_rsc->container;
for (GList *n = rsc->running_on; n != NULL; n = n->next) {
- pe_node_t *container_node = n->data;
+ pcmk_node_t *container_node = n->data;
if (!container_node->details->online
- && !pe_can_fence(data_set, container_node)) {
+ && !pe_can_fence(scheduler, container_node)) {
return false;
}
}
return true;
- } else if (!pcmk_is_set(data_set->flags, pe_flag_stonith_enabled)) {
+ } else if (!pcmk_is_set(scheduler->flags, pcmk_sched_fencing_enabled)) {
return false; /* Turned off */
- } else if (!pcmk_is_set(data_set->flags, pe_flag_have_stonith_resource)) {
+ } else if (!pcmk_is_set(scheduler->flags, pcmk_sched_have_fencing)) {
return false; /* No devices */
- } else if (pcmk_is_set(data_set->flags, pe_flag_have_quorum)) {
+ } else if (pcmk_is_set(scheduler->flags, pcmk_sched_quorate)) {
return true;
- } else if (data_set->no_quorum_policy == no_quorum_ignore) {
+ } else if (scheduler->no_quorum_policy == pcmk_no_quorum_ignore) {
return true;
} else if(node == NULL) {
@@ -85,65 +85,25 @@ pe_can_fence(const pe_working_set_t *data_set, const pe_node_t *node)
* \return Newly allocated shallow copy of this_node
* \note This function asserts on errors and is guaranteed to return non-NULL.
*/
-pe_node_t *
-pe__copy_node(const pe_node_t *this_node)
+pcmk_node_t *
+pe__copy_node(const pcmk_node_t *this_node)
{
- pe_node_t *new_node = NULL;
+ pcmk_node_t *new_node = NULL;
CRM_ASSERT(this_node != NULL);
- new_node = calloc(1, sizeof(pe_node_t));
+ new_node = calloc(1, sizeof(pcmk_node_t));
CRM_ASSERT(new_node != NULL);
new_node->rsc_discover_mode = this_node->rsc_discover_mode;
new_node->weight = this_node->weight;
new_node->fixed = this_node->fixed; // @COMPAT deprecated and unused
+ new_node->count = this_node->count;
new_node->details = this_node->details;
return new_node;
}
-/* any node in list1 or list2 and not in the other gets a score of -INFINITY */
-void
-node_list_exclude(GHashTable * hash, GList *list, gboolean merge_scores)
-{
- GHashTable *result = hash;
- pe_node_t *other_node = NULL;
- GList *gIter = list;
-
- GHashTableIter iter;
- pe_node_t *node = NULL;
-
- g_hash_table_iter_init(&iter, hash);
- while (g_hash_table_iter_next(&iter, NULL, (void **)&node)) {
-
- other_node = pe_find_node_id(list, node->details->id);
- if (other_node == NULL) {
- node->weight = -INFINITY;
- crm_trace("Banning dependent from %s (no primary instance)",
- pe__node_name(node));
- } else if (merge_scores) {
- node->weight = pcmk__add_scores(node->weight, other_node->weight);
- crm_trace("Added primary's score %s to dependent's score for %s "
- "(now %s)", pcmk_readable_score(other_node->weight),
- pe__node_name(node), pcmk_readable_score(node->weight));
- }
- }
-
- for (; gIter != NULL; gIter = gIter->next) {
- pe_node_t *node = (pe_node_t *) gIter->data;
-
- other_node = pe_hash_table_lookup(result, node->details->id);
-
- if (other_node == NULL) {
- pe_node_t *new_node = pe__copy_node(node);
-
- new_node->weight = -INFINITY;
- g_hash_table_insert(result, (gpointer) new_node->details->id, new_node);
- }
- }
-}
-
/*!
* \internal
* \brief Create a node hash table from a node list
@@ -159,8 +119,9 @@ pe__node_list2table(const GList *list)
result = pcmk__strkey_table(NULL, free);
for (const GList *gIter = list; gIter != NULL; gIter = gIter->next) {
- pe_node_t *new_node = pe__copy_node((const pe_node_t *) gIter->data);
+ pcmk_node_t *new_node = NULL;
+ new_node = pe__copy_node((const pcmk_node_t *) gIter->data);
g_hash_table_insert(result, (gpointer) new_node->details->id, new_node);
}
return result;
@@ -184,8 +145,8 @@ pe__node_list2table(const GList *list)
gint
pe__cmp_node_name(gconstpointer a, gconstpointer b)
{
- const pe_node_t *node1 = (const pe_node_t *) a;
- const pe_node_t *node2 = (const pe_node_t *) b;
+ const pcmk_node_t *node1 = (const pcmk_node_t *) a;
+ const pcmk_node_t *node2 = (const pcmk_node_t *) b;
if ((node1 == NULL) && (node2 == NULL)) {
return 0;
@@ -207,23 +168,23 @@ pe__cmp_node_name(gconstpointer a, gconstpointer b)
* \internal
* \brief Output node weights to stdout
*
- * \param[in] rsc Use allowed nodes for this resource
- * \param[in] comment Text description to prefix lines with
- * \param[in] nodes If rsc is not specified, use these nodes
- * \param[in,out] data_set Cluster working set
+ * \param[in] rsc Use allowed nodes for this resource
+ * \param[in] comment Text description to prefix lines with
+ * \param[in] nodes If rsc is not specified, use these nodes
+ * \param[in,out] scheduler Scheduler data
*/
static void
-pe__output_node_weights(const pe_resource_t *rsc, const char *comment,
- GHashTable *nodes, pe_working_set_t *data_set)
+pe__output_node_weights(const pcmk_resource_t *rsc, const char *comment,
+ GHashTable *nodes, pcmk_scheduler_t *scheduler)
{
- pcmk__output_t *out = data_set->priv;
+ pcmk__output_t *out = scheduler->priv;
// Sort the nodes so the output is consistent for regression tests
GList *list = g_list_sort(g_hash_table_get_values(nodes),
pe__cmp_node_name);
for (const GList *gIter = list; gIter != NULL; gIter = gIter->next) {
- const pe_node_t *node = (const pe_node_t *) gIter->data;
+ const pcmk_node_t *node = (const pcmk_node_t *) gIter->data;
out->message(out, "node-weight", rsc, comment, node->details->uname,
pcmk_readable_score(node->weight));
@@ -244,11 +205,11 @@ pe__output_node_weights(const pe_resource_t *rsc, const char *comment,
*/
static void
pe__log_node_weights(const char *file, const char *function, int line,
- const pe_resource_t *rsc, const char *comment,
+ const pcmk_resource_t *rsc, const char *comment,
GHashTable *nodes)
{
GHashTableIter iter;
- pe_node_t *node = NULL;
+ pcmk_node_t *node = NULL;
// Don't waste time if we're not tracing at this point
pcmk__if_tracing({}, return);
@@ -275,23 +236,23 @@ pe__log_node_weights(const char *file, const char *function, int line,
* \internal
* \brief Log or output node weights
*
- * \param[in] file Caller's filename
- * \param[in] function Caller's function name
- * \param[in] line Caller's line number
- * \param[in] to_log Log if true, otherwise output
- * \param[in] rsc If not NULL, use this resource's ID in logs,
- * and show scores recursively for any children
- * \param[in] comment Text description to prefix lines with
- * \param[in] nodes Nodes whose scores should be shown
- * \param[in,out] data_set Cluster working set
+ * \param[in] file Caller's filename
+ * \param[in] function Caller's function name
+ * \param[in] line Caller's line number
+ * \param[in] to_log Log if true, otherwise output
+ * \param[in] rsc If not NULL, use this resource's ID in logs,
+ * and show scores recursively for any children
+ * \param[in] comment Text description to prefix lines with
+ * \param[in] nodes Nodes whose scores should be shown
+ * \param[in,out] scheduler Scheduler data
*/
void
-pe__show_node_weights_as(const char *file, const char *function, int line,
- bool to_log, const pe_resource_t *rsc,
- const char *comment, GHashTable *nodes,
- pe_working_set_t *data_set)
+pe__show_node_scores_as(const char *file, const char *function, int line,
+ bool to_log, const pcmk_resource_t *rsc,
+ const char *comment, GHashTable *nodes,
+ pcmk_scheduler_t *scheduler)
{
- if (rsc != NULL && pcmk_is_set(rsc->flags, pe_rsc_orphan)) {
+ if ((rsc != NULL) && pcmk_is_set(rsc->flags, pcmk_rsc_removed)) {
// Don't show allocation scores for orphans
return;
}
@@ -303,16 +264,16 @@ pe__show_node_weights_as(const char *file, const char *function, int line,
if (to_log) {
pe__log_node_weights(file, function, line, rsc, comment, nodes);
} else {
- pe__output_node_weights(rsc, comment, nodes, data_set);
+ pe__output_node_weights(rsc, comment, nodes, scheduler);
}
// If this resource has children, repeat recursively for each
if (rsc && rsc->children) {
for (GList *gIter = rsc->children; gIter != NULL; gIter = gIter->next) {
- pe_resource_t *child = (pe_resource_t *) gIter->data;
+ pcmk_resource_t *child = (pcmk_resource_t *) gIter->data;
- pe__show_node_weights_as(file, function, line, to_log, child,
- comment, child->allowed_nodes, data_set);
+ pe__show_node_scores_as(file, function, line, to_log, child,
+ comment, child->allowed_nodes, scheduler);
}
}
}
@@ -334,8 +295,8 @@ pe__show_node_weights_as(const char *file, const char *function, int line,
gint
pe__cmp_rsc_priority(gconstpointer a, gconstpointer b)
{
- const pe_resource_t *resource1 = (const pe_resource_t *)a;
- const pe_resource_t *resource2 = (const pe_resource_t *)b;
+ const pcmk_resource_t *resource1 = (const pcmk_resource_t *)a;
+ const pcmk_resource_t *resource2 = (const pcmk_resource_t *)b;
if (a == NULL && b == NULL) {
return 0;
@@ -359,12 +320,13 @@ pe__cmp_rsc_priority(gconstpointer a, gconstpointer b)
}
static void
-resource_node_score(pe_resource_t *rsc, const pe_node_t *node, int score,
+resource_node_score(pcmk_resource_t *rsc, const pcmk_node_t *node, int score,
const char *tag)
{
- pe_node_t *match = NULL;
+ pcmk_node_t *match = NULL;
- if ((rsc->exclusive_discover || (node->rsc_discover_mode == pe_discover_never))
+ if ((rsc->exclusive_discover
+ || (node->rsc_discover_mode == pcmk_probe_never))
&& pcmk__str_eq(tag, "symmetric_default", pcmk__str_casei)) {
/* This string comparision may be fragile, but exclusive resources and
* exclusive nodes should not have the symmetric_default constraint
@@ -376,13 +338,13 @@ resource_node_score(pe_resource_t *rsc, const pe_node_t *node, int score,
GList *gIter = rsc->children;
for (; gIter != NULL; gIter = gIter->next) {
- pe_resource_t *child_rsc = (pe_resource_t *) gIter->data;
+ pcmk_resource_t *child_rsc = (pcmk_resource_t *) gIter->data;
resource_node_score(child_rsc, node, score, tag);
}
}
- match = pe_hash_table_lookup(rsc->allowed_nodes, node->details->id);
+ match = g_hash_table_lookup(rsc->allowed_nodes, node->details->id);
if (match == NULL) {
match = pe__copy_node(node);
g_hash_table_insert(rsc->allowed_nodes, (gpointer) match->details->id, match);
@@ -395,24 +357,24 @@ resource_node_score(pe_resource_t *rsc, const pe_node_t *node, int score,
}
void
-resource_location(pe_resource_t *rsc, const pe_node_t *node, int score,
- const char *tag, pe_working_set_t *data_set)
+resource_location(pcmk_resource_t *rsc, const pcmk_node_t *node, int score,
+ const char *tag, pcmk_scheduler_t *scheduler)
{
if (node != NULL) {
resource_node_score(rsc, node, score, tag);
- } else if (data_set != NULL) {
- GList *gIter = data_set->nodes;
+ } else if (scheduler != NULL) {
+ GList *gIter = scheduler->nodes;
for (; gIter != NULL; gIter = gIter->next) {
- pe_node_t *node_iter = (pe_node_t *) gIter->data;
+ pcmk_node_t *node_iter = (pcmk_node_t *) gIter->data;
resource_node_score(rsc, node_iter, score, tag);
}
} else {
GHashTableIter iter;
- pe_node_t *node_iter = NULL;
+ pcmk_node_t *node_iter = NULL;
g_hash_table_iter_init(&iter, rsc->allowed_nodes);
while (g_hash_table_iter_next(&iter, NULL, (void **)&node_iter)) {
@@ -431,14 +393,14 @@ resource_location(pe_resource_t *rsc, const pe_node_t *node, int score,
}
time_t
-get_effective_time(pe_working_set_t * data_set)
+get_effective_time(pcmk_scheduler_t *scheduler)
{
- if(data_set) {
- if (data_set->now == NULL) {
+ if(scheduler) {
+ if (scheduler->now == NULL) {
crm_trace("Recording a new 'now'");
- data_set->now = crm_time_new(NULL);
+ scheduler->now = crm_time_new(NULL);
}
- return crm_time_get_seconds_since_epoch(data_set->now);
+ return crm_time_get_seconds_since_epoch(scheduler->now);
}
crm_trace("Defaulting to 'now'");
@@ -446,9 +408,9 @@ get_effective_time(pe_working_set_t * data_set)
}
gboolean
-get_target_role(const pe_resource_t *rsc, enum rsc_role_e *role)
+get_target_role(const pcmk_resource_t *rsc, enum rsc_role_e *role)
{
- enum rsc_role_e local_role = RSC_ROLE_UNKNOWN;
+ enum rsc_role_e local_role = pcmk_role_unknown;
const char *value = g_hash_table_lookup(rsc->meta, XML_RSC_ATTR_TARGET_ROLE);
CRM_CHECK(role != NULL, return FALSE);
@@ -459,15 +421,15 @@ get_target_role(const pe_resource_t *rsc, enum rsc_role_e *role)
}
local_role = text2role(value);
- if (local_role == RSC_ROLE_UNKNOWN) {
+ if (local_role == pcmk_role_unknown) {
pcmk__config_err("Ignoring '" XML_RSC_ATTR_TARGET_ROLE "' for %s "
"because '%s' is not valid", rsc->id, value);
return FALSE;
- } else if (local_role > RSC_ROLE_STARTED) {
+ } else if (local_role > pcmk_role_started) {
if (pcmk_is_set(pe__const_top_resource(rsc, false)->flags,
- pe_rsc_promotable)) {
- if (local_role > RSC_ROLE_UNPROMOTED) {
+ pcmk_rsc_promotable)) {
+ if (local_role > pcmk_role_unpromoted) {
/* This is what we'd do anyway, just leave the default to avoid messing up the placement algorithm */
return FALSE;
}
@@ -485,13 +447,14 @@ get_target_role(const pe_resource_t *rsc, enum rsc_role_e *role)
}
gboolean
-order_actions(pe_action_t * lh_action, pe_action_t * rh_action, enum pe_ordering order)
+order_actions(pcmk_action_t *lh_action, pcmk_action_t *rh_action,
+ uint32_t flags)
{
GList *gIter = NULL;
- pe_action_wrapper_t *wrapper = NULL;
+ pcmk__related_action_t *wrapper = NULL;
GList *list = NULL;
- if (order == pe_order_none) {
+ if (flags == pcmk__ar_none) {
return FALSE;
}
@@ -508,23 +471,23 @@ order_actions(pe_action_t * lh_action, pe_action_t * rh_action, enum pe_ordering
/* Filter dups, otherwise update_action_states() has too much work to do */
gIter = lh_action->actions_after;
for (; gIter != NULL; gIter = gIter->next) {
- pe_action_wrapper_t *after = (pe_action_wrapper_t *) gIter->data;
+ pcmk__related_action_t *after = gIter->data;
- if (after->action == rh_action && (after->type & order)) {
+ if (after->action == rh_action && (after->type & flags)) {
return FALSE;
}
}
- wrapper = calloc(1, sizeof(pe_action_wrapper_t));
+ wrapper = calloc(1, sizeof(pcmk__related_action_t));
wrapper->action = rh_action;
- wrapper->type = order;
+ wrapper->type = flags;
list = lh_action->actions_after;
list = g_list_prepend(list, wrapper);
lh_action->actions_after = list;
- wrapper = calloc(1, sizeof(pe_action_wrapper_t));
+ wrapper = calloc(1, sizeof(pcmk__related_action_t));
wrapper->action = lh_action;
- wrapper->type = order;
+ wrapper->type = flags;
list = rh_action->actions_before;
list = g_list_prepend(list, wrapper);
rh_action->actions_before = list;
@@ -534,7 +497,7 @@ order_actions(pe_action_t * lh_action, pe_action_t * rh_action, enum pe_ordering
void
destroy_ticket(gpointer data)
{
- pe_ticket_t *ticket = data;
+ pcmk_ticket_t *ticket = data;
if (ticket->state) {
g_hash_table_destroy(ticket->state);
@@ -543,23 +506,23 @@ destroy_ticket(gpointer data)
free(ticket);
}
-pe_ticket_t *
-ticket_new(const char *ticket_id, pe_working_set_t * data_set)
+pcmk_ticket_t *
+ticket_new(const char *ticket_id, pcmk_scheduler_t *scheduler)
{
- pe_ticket_t *ticket = NULL;
+ pcmk_ticket_t *ticket = NULL;
if (pcmk__str_empty(ticket_id)) {
return NULL;
}
- if (data_set->tickets == NULL) {
- data_set->tickets = pcmk__strkey_table(free, destroy_ticket);
+ if (scheduler->tickets == NULL) {
+ scheduler->tickets = pcmk__strkey_table(free, destroy_ticket);
}
- ticket = g_hash_table_lookup(data_set->tickets, ticket_id);
+ ticket = g_hash_table_lookup(scheduler->tickets, ticket_id);
if (ticket == NULL) {
- ticket = calloc(1, sizeof(pe_ticket_t));
+ ticket = calloc(1, sizeof(pcmk_ticket_t));
if (ticket == NULL) {
crm_err("Cannot allocate ticket '%s'", ticket_id);
return NULL;
@@ -573,55 +536,57 @@ ticket_new(const char *ticket_id, pe_working_set_t * data_set)
ticket->standby = FALSE;
ticket->state = pcmk__strkey_table(free, free);
- g_hash_table_insert(data_set->tickets, strdup(ticket->id), ticket);
+ g_hash_table_insert(scheduler->tickets, strdup(ticket->id), ticket);
}
return ticket;
}
const char *
-rsc_printable_id(const pe_resource_t *rsc)
+rsc_printable_id(const pcmk_resource_t *rsc)
{
- return pcmk_is_set(rsc->flags, pe_rsc_unique)? rsc->id : ID(rsc->xml);
+ return pcmk_is_set(rsc->flags, pcmk_rsc_unique)? rsc->id : ID(rsc->xml);
}
void
-pe__clear_resource_flags_recursive(pe_resource_t *rsc, uint64_t flags)
+pe__clear_resource_flags_recursive(pcmk_resource_t *rsc, uint64_t flags)
{
pe__clear_resource_flags(rsc, flags);
for (GList *gIter = rsc->children; gIter != NULL; gIter = gIter->next) {
- pe__clear_resource_flags_recursive((pe_resource_t *) gIter->data, flags);
+ pe__clear_resource_flags_recursive((pcmk_resource_t *) gIter->data,
+ flags);
}
}
void
-pe__clear_resource_flags_on_all(pe_working_set_t *data_set, uint64_t flag)
+pe__clear_resource_flags_on_all(pcmk_scheduler_t *scheduler, uint64_t flag)
{
- for (GList *lpc = data_set->resources; lpc != NULL; lpc = lpc->next) {
- pe_resource_t *r = (pe_resource_t *) lpc->data;
+ for (GList *lpc = scheduler->resources; lpc != NULL; lpc = lpc->next) {
+ pcmk_resource_t *r = (pcmk_resource_t *) lpc->data;
pe__clear_resource_flags_recursive(r, flag);
}
}
void
-pe__set_resource_flags_recursive(pe_resource_t *rsc, uint64_t flags)
+pe__set_resource_flags_recursive(pcmk_resource_t *rsc, uint64_t flags)
{
pe__set_resource_flags(rsc, flags);
for (GList *gIter = rsc->children; gIter != NULL; gIter = gIter->next) {
- pe__set_resource_flags_recursive((pe_resource_t *) gIter->data, flags);
+ pe__set_resource_flags_recursive((pcmk_resource_t *) gIter->data,
+ flags);
}
}
void
-trigger_unfencing(pe_resource_t *rsc, pe_node_t *node, const char *reason,
- pe_action_t *dependency, pe_working_set_t *data_set)
+trigger_unfencing(pcmk_resource_t *rsc, pcmk_node_t *node, const char *reason,
+ pcmk_action_t *dependency, pcmk_scheduler_t *scheduler)
{
- if (!pcmk_is_set(data_set->flags, pe_flag_enable_unfencing)) {
+ if (!pcmk_is_set(scheduler->flags, pcmk_sched_enable_unfencing)) {
/* No resources require it */
return;
} else if ((rsc != NULL)
- && !pcmk_is_set(rsc->flags, pe_rsc_fence_device)) {
+ && !pcmk_is_set(rsc->flags, pcmk_rsc_fence_device)) {
/* Wasn't a stonith device */
return;
@@ -629,10 +594,11 @@ trigger_unfencing(pe_resource_t *rsc, pe_node_t *node, const char *reason,
&& node->details->online
&& node->details->unclean == FALSE
&& node->details->shutdown == FALSE) {
- pe_action_t *unfence = pe_fence_op(node, "on", FALSE, reason, FALSE, data_set);
+ pcmk_action_t *unfence = pe_fence_op(node, PCMK_ACTION_ON, FALSE,
+ reason, FALSE, scheduler);
if(dependency) {
- order_actions(unfence, dependency, pe_order_optional);
+ order_actions(unfence, dependency, pcmk__ar_ordered);
}
} else if(rsc) {
@@ -641,7 +607,7 @@ trigger_unfencing(pe_resource_t *rsc, pe_node_t *node, const char *reason,
g_hash_table_iter_init(&iter, rsc->allowed_nodes);
while (g_hash_table_iter_next(&iter, NULL, (void **)&node)) {
if(node->details->online && node->details->unclean == FALSE && node->details->shutdown == FALSE) {
- trigger_unfencing(rsc, node, reason, dependency, data_set);
+ trigger_unfencing(rsc, node, reason, dependency, scheduler);
}
}
}
@@ -650,7 +616,7 @@ trigger_unfencing(pe_resource_t *rsc, pe_node_t *node, const char *reason,
gboolean
add_tag_ref(GHashTable * tags, const char * tag_name, const char * obj_ref)
{
- pe_tag_t *tag = NULL;
+ pcmk_tag_t *tag = NULL;
GList *gIter = NULL;
gboolean is_existing = FALSE;
@@ -658,7 +624,7 @@ add_tag_ref(GHashTable * tags, const char * tag_name, const char * obj_ref)
tag = g_hash_table_lookup(tags, tag_name);
if (tag == NULL) {
- tag = calloc(1, sizeof(pe_tag_t));
+ tag = calloc(1, sizeof(pcmk_tag_t));
if (tag == NULL) {
return FALSE;
}
@@ -697,7 +663,7 @@ add_tag_ref(GHashTable * tags, const char * tag_name, const char * obj_ref)
* shutdown of remote nodes by virtue of their connection stopping.
*/
bool
-pe__shutdown_requested(const pe_node_t *node)
+pe__shutdown_requested(const pcmk_node_t *node)
{
const char *shutdown = pe_node_attribute_raw(node, XML_CIB_ATTR_SHUTDOWN);
@@ -706,18 +672,22 @@ pe__shutdown_requested(const pe_node_t *node)
/*!
* \internal
- * \brief Update a data set's "recheck by" time
+ * \brief Update "recheck by" time in scheduler data
*
- * \param[in] recheck Epoch time when recheck should happen
- * \param[in,out] data_set Current working set
+ * \param[in] recheck Epoch time when recheck should happen
+ * \param[in,out] scheduler Scheduler data
+ * \param[in] reason What time is being updated for (for logs)
*/
void
-pe__update_recheck_time(time_t recheck, pe_working_set_t *data_set)
+pe__update_recheck_time(time_t recheck, pcmk_scheduler_t *scheduler,
+ const char *reason)
{
- if ((recheck > get_effective_time(data_set))
- && ((data_set->recheck_by == 0)
- || (data_set->recheck_by > recheck))) {
- data_set->recheck_by = recheck;
+ if ((recheck > get_effective_time(scheduler))
+ && ((scheduler->recheck_by == 0)
+ || (scheduler->recheck_by > recheck))) {
+ scheduler->recheck_by = recheck;
+ crm_debug("Updated next scheduler recheck to %s for %s",
+ pcmk__trim(ctime(&recheck)), reason);
}
}
@@ -731,28 +701,28 @@ pe__update_recheck_time(time_t recheck, pe_working_set_t *data_set)
* \param[out] hash Where to store extracted name/value pairs
* \param[in] always_first If not NULL, process block with this ID first
* \param[in] overwrite Whether to replace existing values with same name
- * \param[in,out] data_set Cluster working set containing \p xml_obj
+ * \param[in,out] scheduler Scheduler data containing \p xml_obj
*/
void
pe__unpack_dataset_nvpairs(const xmlNode *xml_obj, const char *set_name,
const pe_rule_eval_data_t *rule_data,
GHashTable *hash, const char *always_first,
- gboolean overwrite, pe_working_set_t *data_set)
+ gboolean overwrite, pcmk_scheduler_t *scheduler)
{
crm_time_t *next_change = crm_time_new_undefined();
- pe_eval_nvpairs(data_set->input, xml_obj, set_name, rule_data, hash,
+ pe_eval_nvpairs(scheduler->input, xml_obj, set_name, rule_data, hash,
always_first, overwrite, next_change);
if (crm_time_is_defined(next_change)) {
time_t recheck = (time_t) crm_time_get_seconds_since_epoch(next_change);
- pe__update_recheck_time(recheck, data_set);
+ pe__update_recheck_time(recheck, scheduler, "rule evaluation");
}
crm_time_free(next_change);
}
bool
-pe__resource_is_disabled(const pe_resource_t *rsc)
+pe__resource_is_disabled(const pcmk_resource_t *rsc)
{
const char *target_role = NULL;
@@ -761,10 +731,10 @@ pe__resource_is_disabled(const pe_resource_t *rsc)
if (target_role) {
enum rsc_role_e target_role_e = text2role(target_role);
- if ((target_role_e == RSC_ROLE_STOPPED)
- || ((target_role_e == RSC_ROLE_UNPROMOTED)
+ if ((target_role_e == pcmk_role_stopped)
+ || ((target_role_e == pcmk_role_unpromoted)
&& pcmk_is_set(pe__const_top_resource(rsc, false)->flags,
- pe_rsc_promotable))) {
+ pcmk_rsc_promotable))) {
return true;
}
}
@@ -781,17 +751,17 @@ pe__resource_is_disabled(const pe_resource_t *rsc)
* \return true if \p rsc is running only on \p node, otherwise false
*/
bool
-pe__rsc_running_on_only(const pe_resource_t *rsc, const pe_node_t *node)
+pe__rsc_running_on_only(const pcmk_resource_t *rsc, const pcmk_node_t *node)
{
return (rsc != NULL) && pcmk__list_of_1(rsc->running_on)
- && pe__same_node((const pe_node_t *) rsc->running_on->data, node);
+ && pe__same_node((const pcmk_node_t *) rsc->running_on->data, node);
}
bool
-pe__rsc_running_on_any(pe_resource_t *rsc, GList *node_list)
+pe__rsc_running_on_any(pcmk_resource_t *rsc, GList *node_list)
{
for (GList *ele = rsc->running_on; ele; ele = ele->next) {
- pe_node_t *node = (pe_node_t *) ele->data;
+ pcmk_node_t *node = (pcmk_node_t *) ele->data;
if (pcmk__str_in_list(node->details->uname, node_list,
pcmk__str_star_matches|pcmk__str_casei)) {
return true;
@@ -802,7 +772,7 @@ pe__rsc_running_on_any(pe_resource_t *rsc, GList *node_list)
}
bool
-pcmk__rsc_filtered_by_node(pe_resource_t *rsc, GList *only_node)
+pcmk__rsc_filtered_by_node(pcmk_resource_t *rsc, GList *only_node)
{
return (rsc->fns->active(rsc, FALSE) && !pe__rsc_running_on_any(rsc, only_node));
}
@@ -813,7 +783,7 @@ pe__filter_rsc_list(GList *rscs, GList *filter)
GList *retval = NULL;
for (GList *gIter = rscs; gIter; gIter = gIter->next) {
- pe_resource_t *rsc = (pe_resource_t *) gIter->data;
+ pcmk_resource_t *rsc = (pcmk_resource_t *) gIter->data;
/* I think the second condition is safe here for all callers of this
* function. If not, it needs to move into pe__node_text.
@@ -828,7 +798,8 @@ pe__filter_rsc_list(GList *rscs, GList *filter)
}
GList *
-pe__build_node_name_list(pe_working_set_t *data_set, const char *s) {
+pe__build_node_name_list(pcmk_scheduler_t *scheduler, const char *s)
+{
GList *nodes = NULL;
if (pcmk__str_eq(s, "*", pcmk__str_null_matches)) {
@@ -838,7 +809,7 @@ pe__build_node_name_list(pe_working_set_t *data_set, const char *s) {
*/
nodes = g_list_prepend(nodes, strdup("*"));
} else {
- pe_node_t *node = pe_find_node(data_set->nodes, s);
+ pcmk_node_t *node = pe_find_node(scheduler->nodes, s);
if (node) {
/* The given string was a valid uname for a node. Return a
@@ -852,7 +823,7 @@ pe__build_node_name_list(pe_working_set_t *data_set, const char *s) {
* second case, we'll return a NULL pointer and nothing will
* get displayed.
*/
- nodes = pe__unames_with_tag(data_set, s);
+ nodes = pe__unames_with_tag(scheduler, s);
}
}
@@ -860,14 +831,16 @@ pe__build_node_name_list(pe_working_set_t *data_set, const char *s) {
}
GList *
-pe__build_rsc_list(pe_working_set_t *data_set, const char *s) {
+pe__build_rsc_list(pcmk_scheduler_t *scheduler, const char *s)
+{
GList *resources = NULL;
if (pcmk__str_eq(s, "*", pcmk__str_null_matches)) {
resources = g_list_prepend(resources, strdup("*"));
} else {
- pe_resource_t *rsc = pe_find_resource_with_flags(data_set->resources, s,
- pe_find_renamed|pe_find_any);
+ const uint32_t flags = pcmk_rsc_match_history|pcmk_rsc_match_basename;
+ pcmk_resource_t *rsc = pe_find_resource_with_flags(scheduler->resources,
+ s, flags);
if (rsc) {
/* A colon in the name we were given means we're being asked to filter
@@ -885,7 +858,7 @@ pe__build_rsc_list(pe_working_set_t *data_set, const char *s) {
* typo or something. See pe__build_node_name_list() for more
* detail.
*/
- resources = pe__rscs_with_tag(data_set, s);
+ resources = pe__rscs_with_tag(scheduler, s);
}
}
@@ -893,12 +866,12 @@ pe__build_rsc_list(pe_working_set_t *data_set, const char *s) {
}
xmlNode *
-pe__failed_probe_for_rsc(const pe_resource_t *rsc, const char *name)
+pe__failed_probe_for_rsc(const pcmk_resource_t *rsc, const char *name)
{
- const pe_resource_t *parent = pe__const_top_resource(rsc, false);
+ const pcmk_resource_t *parent = pe__const_top_resource(rsc, false);
const char *rsc_id = rsc->id;
- if (parent->variant == pe_clone) {
+ if (parent->variant == pcmk_rsc_variant_clone) {
rsc_id = pe__clone_child_id(parent);
}