summaryrefslogtreecommitdiffstats
path: root/lib/pengine/clone.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:45:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:45:40 +0000
commit07d7f4cfa4b10de87a31b68191036ff446add675 (patch)
tree7162524d8aaf1aef62d2f4fa51f595ed113981ff /lib/pengine/clone.c
parentAdding upstream version 2.1.6. (diff)
downloadpacemaker-07d7f4cfa4b10de87a31b68191036ff446add675.tar.xz
pacemaker-07d7f4cfa4b10de87a31b68191036ff446add675.zip
Adding upstream version 2.1.7.upstream/2.1.7
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/pengine/clone.c')
-rw-r--r--lib/pengine/clone.c428
1 files changed, 237 insertions, 191 deletions
diff --git a/lib/pengine/clone.c b/lib/pengine/clone.c
index e411f98..a92a4b7 100644
--- a/lib/pengine/clone.c
+++ b/lib/pengine/clone.c
@@ -18,13 +18,14 @@
#include <crm/msg_xml.h>
#include <crm/common/output.h>
#include <crm/common/xml_internal.h>
+#include <crm/common/scheduler_internal.h>
#ifdef PCMK__COMPAT_2_0
-#define PROMOTED_INSTANCES RSC_ROLE_PROMOTED_LEGACY_S "s"
-#define UNPROMOTED_INSTANCES RSC_ROLE_UNPROMOTED_LEGACY_S "s"
+#define PROMOTED_INSTANCES PCMK__ROLE_PROMOTED_LEGACY "s"
+#define UNPROMOTED_INSTANCES PCMK__ROLE_UNPROMOTED_LEGACY "s"
#else
-#define PROMOTED_INSTANCES RSC_ROLE_PROMOTED_S
-#define UNPROMOTED_INSTANCES RSC_ROLE_UNPROMOTED_S
+#define PROMOTED_INSTANCES PCMK__ROLE_PROMOTED
+#define UNPROMOTED_INSTANCES PCMK__ROLE_UNPROMOTED
#endif
typedef struct clone_variant_data_s {
@@ -36,7 +37,7 @@ typedef struct clone_variant_data_s {
int total_clones;
- uint32_t flags; // Group of enum pe__clone_flags
+ uint32_t flags; // Group of enum pcmk__clone_flags
notify_data_t *stop_notify;
notify_data_t *start_notify;
@@ -46,8 +47,8 @@ typedef struct clone_variant_data_s {
xmlNode *xml_obj_child;
} clone_variant_data_t;
-#define get_clone_variant_data(data, rsc) \
- CRM_ASSERT((rsc != NULL) && (rsc->variant == pe_clone)); \
+#define get_clone_variant_data(data, rsc) \
+ CRM_ASSERT((rsc != NULL) && (rsc->variant == pcmk_rsc_variant_clone)); \
data = (clone_variant_data_t *) rsc->variant_opaque;
/*!
@@ -59,7 +60,7 @@ typedef struct clone_variant_data_s {
* \return Maximum instances for \p clone
*/
int
-pe__clone_max(const pe_resource_t *clone)
+pe__clone_max(const pcmk_resource_t *clone)
{
const clone_variant_data_t *clone_data = NULL;
@@ -76,7 +77,7 @@ pe__clone_max(const pe_resource_t *clone)
* \return Maximum allowed instances per node for \p clone
*/
int
-pe__clone_node_max(const pe_resource_t *clone)
+pe__clone_node_max(const pcmk_resource_t *clone)
{
const clone_variant_data_t *clone_data = NULL;
@@ -93,7 +94,7 @@ pe__clone_node_max(const pe_resource_t *clone)
* \return Maximum promoted instances for \p clone
*/
int
-pe__clone_promoted_max(const pe_resource_t *clone)
+pe__clone_promoted_max(const pcmk_resource_t *clone)
{
clone_variant_data_t *clone_data = NULL;
@@ -110,7 +111,7 @@ pe__clone_promoted_max(const pe_resource_t *clone)
* \return Maximum promoted instances for \p clone
*/
int
-pe__clone_promoted_node_max(const pe_resource_t *clone)
+pe__clone_promoted_node_max(const pcmk_resource_t *clone)
{
clone_variant_data_t *clone_data = NULL;
@@ -167,16 +168,16 @@ node_list_to_str(const GList *list)
}
static void
-clone_header(pcmk__output_t *out, int *rc, const pe_resource_t *rsc,
+clone_header(pcmk__output_t *out, int *rc, const pcmk_resource_t *rsc,
clone_variant_data_t *clone_data, const char *desc)
{
GString *attrs = NULL;
- if (pcmk_is_set(rsc->flags, pe_rsc_promotable)) {
+ if (pcmk_is_set(rsc->flags, pcmk_rsc_promotable)) {
pcmk__add_separated_word(&attrs, 64, "promotable", ", ");
}
- if (pcmk_is_set(rsc->flags, pe_rsc_unique)) {
+ if (pcmk_is_set(rsc->flags, pcmk_rsc_unique)) {
pcmk__add_separated_word(&attrs, 64, "unique", ", ");
}
@@ -184,10 +185,10 @@ clone_header(pcmk__output_t *out, int *rc, const pe_resource_t *rsc,
pcmk__add_separated_word(&attrs, 64, "disabled", ", ");
}
- if (pcmk_is_set(rsc->flags, pe_rsc_maintenance)) {
+ if (pcmk_is_set(rsc->flags, pcmk_rsc_maintenance)) {
pcmk__add_separated_word(&attrs, 64, "maintenance", ", ");
- } else if (!pcmk_is_set(rsc->flags, pe_rsc_managed)) {
+ } else if (!pcmk_is_set(rsc->flags, pcmk_rsc_managed)) {
pcmk__add_separated_word(&attrs, 64, "unmanaged", ", ");
}
@@ -206,8 +207,8 @@ clone_header(pcmk__output_t *out, int *rc, const pe_resource_t *rsc,
}
void
-pe__force_anon(const char *standard, pe_resource_t *rsc, const char *rid,
- pe_working_set_t *data_set)
+pe__force_anon(const char *standard, pcmk_resource_t *rsc, const char *rid,
+ pcmk_scheduler_t *scheduler)
{
if (pe_rsc_is_clone(rsc)) {
clone_variant_data_t *clone_data = rsc->variant_opaque;
@@ -218,15 +219,15 @@ pe__force_anon(const char *standard, pe_resource_t *rsc, const char *rid,
clone_data->clone_node_max = 1;
clone_data->clone_max = QB_MIN(clone_data->clone_max,
- g_list_length(data_set->nodes));
+ g_list_length(scheduler->nodes));
}
}
-pe_resource_t *
-find_clone_instance(const pe_resource_t *rsc, const char *sub_id)
+pcmk_resource_t *
+find_clone_instance(const pcmk_resource_t *rsc, const char *sub_id)
{
char *child_id = NULL;
- pe_resource_t *child = NULL;
+ pcmk_resource_t *child = NULL;
const char *child_base = NULL;
clone_variant_data_t *clone_data = NULL;
@@ -240,13 +241,13 @@ find_clone_instance(const pe_resource_t *rsc, const char *sub_id)
return child;
}
-pe_resource_t *
-pe__create_clone_child(pe_resource_t *rsc, pe_working_set_t *data_set)
+pcmk_resource_t *
+pe__create_clone_child(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler)
{
gboolean as_orphan = FALSE;
char *inc_num = NULL;
char *inc_max = NULL;
- pe_resource_t *child_rsc = NULL;
+ pcmk_resource_t *child_rsc = NULL;
xmlNode *child_copy = NULL;
clone_variant_data_t *clone_data = NULL;
@@ -268,7 +269,7 @@ pe__create_clone_child(pe_resource_t *rsc, pe_working_set_t *data_set)
crm_xml_add(child_copy, XML_RSC_ATTR_INCARNATION, inc_num);
if (pe__unpack_resource(child_copy, &child_rsc, rsc,
- data_set) != pcmk_rc_ok) {
+ scheduler) != pcmk_rc_ok) {
goto bail;
}
/* child_rsc->globally_unique = rsc->globally_unique; */
@@ -278,10 +279,10 @@ pe__create_clone_child(pe_resource_t *rsc, pe_working_set_t *data_set)
pe_rsc_trace(child_rsc, "Setting clone attributes for: %s", child_rsc->id);
rsc->children = g_list_append(rsc->children, child_rsc);
if (as_orphan) {
- pe__set_resource_flags_recursive(child_rsc, pe_rsc_orphan);
+ pe__set_resource_flags_recursive(child_rsc, pcmk_rsc_removed);
}
- add_hash_param(child_rsc->meta, XML_RSC_ATTR_INCARNATION_MAX, inc_max);
+ add_hash_param(child_rsc->meta, PCMK_META_CLONE_MAX, inc_max);
pe_rsc_trace(rsc, "Added %s instance %s", rsc->id, child_rsc->id);
bail:
@@ -291,90 +292,89 @@ pe__create_clone_child(pe_resource_t *rsc, pe_working_set_t *data_set)
return child_rsc;
}
+/*!
+ * \internal
+ * \brief Unpack a nonnegative integer value from a resource meta-attribute
+ *
+ * \param[in] rsc Resource with meta-attribute
+ * \param[in] meta_name Name of meta-attribute to unpack
+ * \param[in] deprecated_name If not NULL, try unpacking this
+ * if \p meta_name is unset
+ * \param[in] default_value Value to use if unset
+ *
+ * \return Integer parsed from resource's specified meta-attribute if a valid
+ * nonnegative integer, \p default_value if unset, or 0 if invalid
+ */
+static int
+unpack_meta_int(const pcmk_resource_t *rsc, const char *meta_name,
+ const char *deprecated_name, int default_value)
+{
+ int integer = default_value;
+ const char *value = g_hash_table_lookup(rsc->meta, meta_name);
+
+ if ((value == NULL) && (deprecated_name != NULL)) {
+ value = g_hash_table_lookup(rsc->meta, deprecated_name);
+ }
+ if (value != NULL) {
+ pcmk__scan_min_int(value, &integer, 0);
+ }
+ return integer;
+}
+
gboolean
-clone_unpack(pe_resource_t * rsc, pe_working_set_t * data_set)
+clone_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler)
{
int lpc = 0;
xmlNode *a_child = NULL;
xmlNode *xml_obj = rsc->xml;
clone_variant_data_t *clone_data = NULL;
- const char *max_clones = g_hash_table_lookup(rsc->meta, XML_RSC_ATTR_INCARNATION_MAX);
- const char *max_clones_node = g_hash_table_lookup(rsc->meta, XML_RSC_ATTR_INCARNATION_NODEMAX);
-
pe_rsc_trace(rsc, "Processing resource %s...", rsc->id);
clone_data = calloc(1, sizeof(clone_variant_data_t));
rsc->variant_opaque = clone_data;
- if (pcmk_is_set(rsc->flags, pe_rsc_promotable)) {
- const char *promoted_max = NULL;
- const char *promoted_node_max = NULL;
-
- promoted_max = g_hash_table_lookup(rsc->meta,
- XML_RSC_ATTR_PROMOTED_MAX);
- if (promoted_max == NULL) {
- // @COMPAT deprecated since 2.0.0
- promoted_max = g_hash_table_lookup(rsc->meta,
- PCMK_XA_PROMOTED_MAX_LEGACY);
- }
-
- promoted_node_max = g_hash_table_lookup(rsc->meta,
- XML_RSC_ATTR_PROMOTED_NODEMAX);
- if (promoted_node_max == NULL) {
- // @COMPAT deprecated since 2.0.0
- promoted_node_max =
- g_hash_table_lookup(rsc->meta,
- PCMK_XA_PROMOTED_NODE_MAX_LEGACY);
- }
-
+ if (pcmk_is_set(rsc->flags, pcmk_rsc_promotable)) {
// Use 1 as default but 0 for minimum and invalid
- if (promoted_max == NULL) {
- clone_data->promoted_max = 1;
- } else {
- pcmk__scan_min_int(promoted_max, &(clone_data->promoted_max), 0);
- }
+ // @COMPAT PCMK_XA_PROMOTED_MAX_LEGACY deprecated since 2.0.0
+ clone_data->promoted_max = unpack_meta_int(rsc, PCMK_META_PROMOTED_MAX,
+ PCMK_XA_PROMOTED_MAX_LEGACY,
+ 1);
// Use 1 as default but 0 for minimum and invalid
- if (promoted_node_max == NULL) {
- clone_data->promoted_node_max = 1;
- } else {
- pcmk__scan_min_int(promoted_node_max,
- &(clone_data->promoted_node_max), 0);
- }
+ // @COMPAT PCMK_XA_PROMOTED_NODE_MAX_LEGACY deprecated since 2.0.0
+ clone_data->promoted_node_max =
+ unpack_meta_int(rsc, PCMK_META_PROMOTED_NODE_MAX,
+ PCMK_XA_PROMOTED_NODE_MAX_LEGACY, 1);
}
// Implied by calloc()
/* clone_data->xml_obj_child = NULL; */
// Use 1 as default but 0 for minimum and invalid
- if (max_clones_node == NULL) {
- clone_data->clone_node_max = 1;
- } else {
- pcmk__scan_min_int(max_clones_node, &(clone_data->clone_node_max), 0);
- }
+ clone_data->clone_node_max = unpack_meta_int(rsc, PCMK_META_CLONE_NODE_MAX,
+ NULL, 1);
/* Use number of nodes (but always at least 1, which is handy for crm_verify
* for a CIB without nodes) as default, but 0 for minimum and invalid
*/
- if (max_clones == NULL) {
- clone_data->clone_max = QB_MAX(1, g_list_length(data_set->nodes));
- } else {
- pcmk__scan_min_int(max_clones, &(clone_data->clone_max), 0);
- }
+ clone_data->clone_max = unpack_meta_int(rsc, PCMK_META_CLONE_MAX, NULL,
+ QB_MAX(1, g_list_length(scheduler->nodes)));
if (crm_is_true(g_hash_table_lookup(rsc->meta, XML_RSC_ATTR_ORDERED))) {
clone_data->flags = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE,
"Clone", rsc->id,
clone_data->flags,
- pe__clone_ordered,
- "pe__clone_ordered");
+ pcmk__clone_ordered,
+ "pcmk__clone_ordered");
}
- if ((rsc->flags & pe_rsc_unique) == 0 && clone_data->clone_node_max > 1) {
- pcmk__config_err("Ignoring " XML_RSC_ATTR_PROMOTED_MAX " for %s "
+ if (!pcmk_is_set(rsc->flags, pcmk_rsc_unique)
+ && (clone_data->clone_node_max > 1)) {
+
+ pcmk__config_err("Ignoring " PCMK_META_CLONE_NODE_MAX " of %d for %s "
"because anonymous clones support only one instance "
- "per node", rsc->id);
+ "per node", clone_data->clone_node_max, rsc->id);
clone_data->clone_node_max = 1;
}
@@ -382,9 +382,9 @@ clone_unpack(pe_resource_t * rsc, pe_working_set_t * data_set)
pe_rsc_trace(rsc, "\tClone max: %d", clone_data->clone_max);
pe_rsc_trace(rsc, "\tClone node max: %d", clone_data->clone_node_max);
pe_rsc_trace(rsc, "\tClone is unique: %s",
- pe__rsc_bool_str(rsc, pe_rsc_unique));
+ pe__rsc_bool_str(rsc, pcmk_rsc_unique));
pe_rsc_trace(rsc, "\tClone is promotable: %s",
- pe__rsc_bool_str(rsc, pe_rsc_promotable));
+ pe__rsc_bool_str(rsc, pcmk_rsc_promotable));
// Clones may contain a single group or primitive
for (a_child = pcmk__xe_first_child(xml_obj); a_child != NULL;
@@ -415,20 +415,20 @@ clone_unpack(pe_resource_t * rsc, pe_working_set_t * data_set)
* inherit when being unpacked, as well as in resource agents' environment.
*/
add_hash_param(rsc->meta, XML_RSC_ATTR_UNIQUE,
- pe__rsc_bool_str(rsc, pe_rsc_unique));
+ pe__rsc_bool_str(rsc, pcmk_rsc_unique));
if (clone_data->clone_max <= 0) {
/* Create one child instance so that unpack_find_resource() will hook up
* any orphans up to the parent correctly.
*/
- if (pe__create_clone_child(rsc, data_set) == NULL) {
+ if (pe__create_clone_child(rsc, scheduler) == NULL) {
return FALSE;
}
} else {
// Create a child instance for each available instance number
for (lpc = 0; lpc < clone_data->clone_max; lpc++) {
- if (pe__create_clone_child(rsc, data_set) == NULL) {
+ if (pe__create_clone_child(rsc, scheduler) == NULL) {
return FALSE;
}
}
@@ -439,12 +439,12 @@ clone_unpack(pe_resource_t * rsc, pe_working_set_t * data_set)
}
gboolean
-clone_active(pe_resource_t * rsc, gboolean all)
+clone_active(pcmk_resource_t * rsc, gboolean all)
{
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;
gboolean child_active = child_rsc->fns->active(child_rsc, all);
if (all == FALSE && child_active) {
@@ -492,27 +492,29 @@ short_print(const char *list, const char *prefix, const char *type,
}
static const char *
-configured_role_str(pe_resource_t * rsc)
+configured_role_str(pcmk_resource_t * rsc)
{
const char *target_role = g_hash_table_lookup(rsc->meta,
XML_RSC_ATTR_TARGET_ROLE);
if ((target_role == NULL) && rsc->children && rsc->children->data) {
- target_role = g_hash_table_lookup(((pe_resource_t*)rsc->children->data)->meta,
+ pcmk_resource_t *instance = rsc->children->data; // Any instance will do
+
+ target_role = g_hash_table_lookup(instance->meta,
XML_RSC_ATTR_TARGET_ROLE);
}
return target_role;
}
static enum rsc_role_e
-configured_role(pe_resource_t * rsc)
+configured_role(pcmk_resource_t *rsc)
{
const char *target_role = configured_role_str(rsc);
if (target_role) {
return text2role(target_role);
}
- return RSC_ROLE_UNKNOWN;
+ return pcmk_role_unknown;
}
/*!
@@ -520,7 +522,7 @@ configured_role(pe_resource_t * rsc)
* \deprecated This function will be removed in a future release
*/
static void
-clone_print_xml(pe_resource_t *rsc, const char *pre_text, long options,
+clone_print_xml(pcmk_resource_t *rsc, const char *pre_text, long options,
void *print_data)
{
char *child_text = crm_strdup_printf("%s ", pre_text);
@@ -530,19 +532,20 @@ clone_print_xml(pe_resource_t *rsc, const char *pre_text, long options,
status_print("%s<clone ", pre_text);
status_print(XML_ATTR_ID "=\"%s\" ", rsc->id);
status_print("multi_state=\"%s\" ",
- pe__rsc_bool_str(rsc, pe_rsc_promotable));
- status_print("unique=\"%s\" ", pe__rsc_bool_str(rsc, pe_rsc_unique));
- status_print("managed=\"%s\" ", pe__rsc_bool_str(rsc, pe_rsc_managed));
- status_print("failed=\"%s\" ", pe__rsc_bool_str(rsc, pe_rsc_failed));
+ pe__rsc_bool_str(rsc, pcmk_rsc_promotable));
+ status_print("unique=\"%s\" ", pe__rsc_bool_str(rsc, pcmk_rsc_unique));
+ status_print("managed=\"%s\" ",
+ pe__rsc_bool_str(rsc, pcmk_rsc_managed));
+ status_print("failed=\"%s\" ", pe__rsc_bool_str(rsc, pcmk_rsc_failed));
status_print("failure_ignored=\"%s\" ",
- pe__rsc_bool_str(rsc, pe_rsc_failure_ignored));
+ pe__rsc_bool_str(rsc, pcmk_rsc_ignore_failure));
if (target_role) {
status_print("target_role=\"%s\" ", target_role);
}
status_print(">\n");
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;
child_rsc->fns->print(child_rsc, child_text, options, print_data);
}
@@ -552,7 +555,7 @@ clone_print_xml(pe_resource_t *rsc, const char *pre_text, long options,
}
bool
-is_set_recursive(const pe_resource_t *rsc, long long flag, bool any)
+is_set_recursive(const pcmk_resource_t *rsc, long long flag, bool any)
{
GList *gIter;
bool all = !any;
@@ -587,7 +590,7 @@ is_set_recursive(const pe_resource_t *rsc, long long flag, bool any)
* \deprecated This function will be removed in a future release
*/
void
-clone_print(pe_resource_t *rsc, const char *pre_text, long options,
+clone_print(pcmk_resource_t *rsc, const char *pre_text, long options,
void *print_data)
{
GString *list_text = NULL;
@@ -616,9 +619,9 @@ clone_print(pe_resource_t *rsc, const char *pre_text, long options,
status_print("%sClone Set: %s [%s]%s%s%s",
pre_text ? pre_text : "", rsc->id, ID(clone_data->xml_obj_child),
- pcmk_is_set(rsc->flags, pe_rsc_promotable)? " (promotable)" : "",
- pcmk_is_set(rsc->flags, pe_rsc_unique)? " (unique)" : "",
- pcmk_is_set(rsc->flags, pe_rsc_managed)? "" : " (unmanaged)");
+ pcmk_is_set(rsc->flags, pcmk_rsc_promotable)? " (promotable)" : "",
+ pcmk_is_set(rsc->flags, pcmk_rsc_unique)? " (unique)" : "",
+ pcmk_is_set(rsc->flags, pcmk_rsc_managed)? "" : " (unmanaged)");
if (options & pe_print_html) {
status_print("\n<ul>\n");
@@ -629,16 +632,17 @@ clone_print(pe_resource_t *rsc, const char *pre_text, long options,
for (; gIter != NULL; gIter = gIter->next) {
gboolean print_full = FALSE;
- pe_resource_t *child_rsc = (pe_resource_t *) gIter->data;
+ pcmk_resource_t *child_rsc = (pcmk_resource_t *) gIter->data;
gboolean partially_active = child_rsc->fns->active(child_rsc, FALSE);
if (options & pe_print_clone_details) {
print_full = TRUE;
}
- if (pcmk_is_set(rsc->flags, pe_rsc_unique)) {
+ if (pcmk_is_set(rsc->flags, pcmk_rsc_unique)) {
// Print individual instance when unique (except stopped orphans)
- if (partially_active || !pcmk_is_set(rsc->flags, pe_rsc_orphan)) {
+ if (partially_active
+ || !pcmk_is_set(rsc->flags, pcmk_rsc_removed)) {
print_full = TRUE;
}
@@ -652,15 +656,15 @@ clone_print(pe_resource_t *rsc, const char *pre_text, long options,
} else if (partially_active == FALSE) {
// List stopped instances when requested (except orphans)
- if (!pcmk_is_set(child_rsc->flags, pe_rsc_orphan)
+ if (!pcmk_is_set(child_rsc->flags, pcmk_rsc_removed)
&& !pcmk_is_set(options, pe_print_clone_active)) {
pcmk__add_word(&stopped_list, 1024, child_rsc->id);
}
- } else if (is_set_recursive(child_rsc, pe_rsc_orphan, TRUE)
- || is_set_recursive(child_rsc, pe_rsc_managed, FALSE) == FALSE
- || is_set_recursive(child_rsc, pe_rsc_failed, TRUE)) {
+ } else if (is_set_recursive(child_rsc, pcmk_rsc_removed, TRUE)
+ || !is_set_recursive(child_rsc, pcmk_rsc_managed, FALSE)
+ || is_set_recursive(child_rsc, pcmk_rsc_failed, TRUE)) {
// Print individual instance when active orphaned/unmanaged/failed
print_full = TRUE;
@@ -668,8 +672,9 @@ clone_print(pe_resource_t *rsc, const char *pre_text, long options,
} else if (child_rsc->fns->active(child_rsc, TRUE)) {
// Instance of fully active anonymous clone
- pe_node_t *location = child_rsc->fns->location(child_rsc, NULL, TRUE);
+ pcmk_node_t *location = NULL;
+ location = child_rsc->fns->location(child_rsc, NULL, TRUE);
if (location) {
// Instance is active on a single node
@@ -678,7 +683,7 @@ clone_print(pe_resource_t *rsc, const char *pre_text, long options,
if (location->details->online == FALSE && location->details->unclean) {
print_full = TRUE;
- } else if (a_role > RSC_ROLE_UNPROMOTED) {
+ } else if (a_role > pcmk_role_unpromoted) {
promoted_list = g_list_append(promoted_list, location);
} else {
@@ -709,7 +714,7 @@ clone_print(pe_resource_t *rsc, const char *pre_text, long options,
/* Promoted */
promoted_list = g_list_sort(promoted_list, pe__cmp_node_name);
for (gIter = promoted_list; gIter; gIter = gIter->next) {
- pe_node_t *host = gIter->data;
+ pcmk_node_t *host = gIter->data;
pcmk__add_word(&list_text, 1024, host->details->uname);
active_instances++;
@@ -725,17 +730,17 @@ clone_print(pe_resource_t *rsc, const char *pre_text, long options,
/* Started/Unpromoted */
started_list = g_list_sort(started_list, pe__cmp_node_name);
for (gIter = started_list; gIter; gIter = gIter->next) {
- pe_node_t *host = gIter->data;
+ pcmk_node_t *host = gIter->data;
pcmk__add_word(&list_text, 1024, host->details->uname);
active_instances++;
}
if (list_text != NULL) {
- if (pcmk_is_set(rsc->flags, pe_rsc_promotable)) {
+ if (pcmk_is_set(rsc->flags, pcmk_rsc_promotable)) {
enum rsc_role_e role = configured_role(rsc);
- if (role == RSC_ROLE_UNPROMOTED) {
+ if (role == pcmk_role_unpromoted) {
short_print((const char *) list_text->str, child_text,
UNPROMOTED_INSTANCES " (target-role)", NULL,
options, print_data);
@@ -756,11 +761,11 @@ clone_print(pe_resource_t *rsc, const char *pre_text, long options,
const char *state = "Stopped";
enum rsc_role_e role = configured_role(rsc);
- if (role == RSC_ROLE_STOPPED) {
+ if (role == pcmk_role_stopped) {
state = "Stopped (disabled)";
}
- if (!pcmk_is_set(rsc->flags, pe_rsc_unique)
+ if (!pcmk_is_set(rsc->flags, pcmk_rsc_unique)
&& (clone_data->clone_max > active_instances)) {
GList *nIter;
@@ -780,7 +785,7 @@ clone_print(pe_resource_t *rsc, const char *pre_text, long options,
list = g_list_sort(list, pe__cmp_node_name);
for (nIter = list; nIter != NULL; nIter = nIter->next) {
- pe_node_t *node = (pe_node_t *)nIter->data;
+ pcmk_node_t *node = (pcmk_node_t *) nIter->data;
if (pe_find_node(rsc->running_on, node->details->uname) == NULL) {
pcmk__add_word(&stopped_list, 1024, node->details->uname);
@@ -809,12 +814,13 @@ clone_print(pe_resource_t *rsc, const char *pre_text, long options,
free(child_text);
}
-PCMK__OUTPUT_ARGS("clone", "uint32_t", "pe_resource_t *", "GList *", "GList *")
+PCMK__OUTPUT_ARGS("clone", "uint32_t", "pcmk_resource_t *", "GList *",
+ "GList *")
int
pe__clone_xml(pcmk__output_t *out, va_list args)
{
uint32_t show_opts = va_arg(args, uint32_t);
- pe_resource_t *rsc = va_arg(args, pe_resource_t *);
+ pcmk_resource_t *rsc = va_arg(args, pcmk_resource_t *);
GList *only_node = va_arg(args, GList *);
GList *only_rsc = va_arg(args, GList *);
@@ -838,7 +844,7 @@ pe__clone_xml(pcmk__output_t *out, va_list args)
all = g_list_prepend(all, (gpointer) "*");
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;
if (pcmk__rsc_filtered_by_node(child_rsc, only_node)) {
continue;
@@ -852,16 +858,18 @@ pe__clone_xml(pcmk__output_t *out, va_list args)
printed_header = TRUE;
desc = pe__resource_description(rsc, show_opts);
-
rc = pe__name_and_nvpairs_xml(out, true, "clone", 10,
"id", rsc->id,
- "multi_state", pe__rsc_bool_str(rsc, pe_rsc_promotable),
- "unique", pe__rsc_bool_str(rsc, pe_rsc_unique),
- "maintenance", pe__rsc_bool_str(rsc, pe_rsc_maintenance),
- "managed", pe__rsc_bool_str(rsc, pe_rsc_managed),
+ "multi_state",
+ pe__rsc_bool_str(rsc, pcmk_rsc_promotable),
+ "unique", pe__rsc_bool_str(rsc, pcmk_rsc_unique),
+ "maintenance",
+ pe__rsc_bool_str(rsc, pcmk_rsc_maintenance),
+ "managed", pe__rsc_bool_str(rsc, pcmk_rsc_managed),
"disabled", pcmk__btoa(pe__resource_is_disabled(rsc)),
- "failed", pe__rsc_bool_str(rsc, pe_rsc_failed),
- "failure_ignored", pe__rsc_bool_str(rsc, pe_rsc_failure_ignored),
+ "failed", pe__rsc_bool_str(rsc, pcmk_rsc_failed),
+ "failure_ignored",
+ pe__rsc_bool_str(rsc, pcmk_rsc_ignore_failure),
"target_role", configured_role_str(rsc),
"description", desc);
CRM_ASSERT(rc == pcmk_rc_ok);
@@ -879,12 +887,13 @@ pe__clone_xml(pcmk__output_t *out, va_list args)
return rc;
}
-PCMK__OUTPUT_ARGS("clone", "uint32_t", "pe_resource_t *", "GList *", "GList *")
+PCMK__OUTPUT_ARGS("clone", "uint32_t", "pcmk_resource_t *", "GList *",
+ "GList *")
int
pe__clone_default(pcmk__output_t *out, va_list args)
{
uint32_t show_opts = va_arg(args, uint32_t);
- pe_resource_t *rsc = va_arg(args, pe_resource_t *);
+ pcmk_resource_t *rsc = va_arg(args, pcmk_resource_t *);
GList *only_node = va_arg(args, GList *);
GList *only_rsc = va_arg(args, GList *);
@@ -916,7 +925,7 @@ pe__clone_default(pcmk__output_t *out, va_list args)
for (; gIter != NULL; gIter = gIter->next) {
gboolean print_full = FALSE;
- pe_resource_t *child_rsc = (pe_resource_t *) gIter->data;
+ pcmk_resource_t *child_rsc = (pcmk_resource_t *) gIter->data;
gboolean partially_active = child_rsc->fns->active(child_rsc, FALSE);
if (pcmk__rsc_filtered_by_node(child_rsc, only_node)) {
@@ -931,9 +940,10 @@ pe__clone_default(pcmk__output_t *out, va_list args)
print_full = TRUE;
}
- if (pcmk_is_set(rsc->flags, pe_rsc_unique)) {
+ if (pcmk_is_set(rsc->flags, pcmk_rsc_unique)) {
// Print individual instance when unique (except stopped orphans)
- if (partially_active || !pcmk_is_set(rsc->flags, pe_rsc_orphan)) {
+ if (partially_active
+ || !pcmk_is_set(rsc->flags, pcmk_rsc_removed)) {
print_full = TRUE;
}
@@ -947,7 +957,7 @@ pe__clone_default(pcmk__output_t *out, va_list args)
} else if (partially_active == FALSE) {
// List stopped instances when requested (except orphans)
- if (!pcmk_is_set(child_rsc->flags, pe_rsc_orphan)
+ if (!pcmk_is_set(child_rsc->flags, pcmk_rsc_removed)
&& !pcmk_is_set(show_opts, pcmk_show_clone_detail)
&& pcmk_is_set(show_opts, pcmk_show_inactive_rscs)) {
if (stopped == NULL) {
@@ -956,9 +966,9 @@ pe__clone_default(pcmk__output_t *out, va_list args)
g_hash_table_insert(stopped, strdup(child_rsc->id), strdup("Stopped"));
}
- } else if (is_set_recursive(child_rsc, pe_rsc_orphan, TRUE)
- || is_set_recursive(child_rsc, pe_rsc_managed, FALSE) == FALSE
- || is_set_recursive(child_rsc, pe_rsc_failed, TRUE)) {
+ } else if (is_set_recursive(child_rsc, pcmk_rsc_removed, TRUE)
+ || !is_set_recursive(child_rsc, pcmk_rsc_managed, FALSE)
+ || is_set_recursive(child_rsc, pcmk_rsc_failed, TRUE)) {
// Print individual instance when active orphaned/unmanaged/failed
print_full = TRUE;
@@ -966,8 +976,9 @@ pe__clone_default(pcmk__output_t *out, va_list args)
} else if (child_rsc->fns->active(child_rsc, TRUE)) {
// Instance of fully active anonymous clone
- pe_node_t *location = child_rsc->fns->location(child_rsc, NULL, TRUE);
+ pcmk_node_t *location = NULL;
+ location = child_rsc->fns->location(child_rsc, NULL, TRUE);
if (location) {
// Instance is active on a single node
@@ -976,7 +987,7 @@ pe__clone_default(pcmk__output_t *out, va_list args)
if (location->details->online == FALSE && location->details->unclean) {
print_full = TRUE;
- } else if (a_role > RSC_ROLE_UNPROMOTED) {
+ } else if (a_role > pcmk_role_unpromoted) {
promoted_list = g_list_append(promoted_list, location);
} else {
@@ -1014,7 +1025,7 @@ pe__clone_default(pcmk__output_t *out, va_list args)
/* Promoted */
promoted_list = g_list_sort(promoted_list, pe__cmp_node_name);
for (gIter = promoted_list; gIter; gIter = gIter->next) {
- pe_node_t *host = gIter->data;
+ pcmk_node_t *host = gIter->data;
if (!pcmk__str_in_list(host->details->uname, only_node,
pcmk__str_star_matches|pcmk__str_casei)) {
@@ -1037,7 +1048,7 @@ pe__clone_default(pcmk__output_t *out, va_list args)
/* Started/Unpromoted */
started_list = g_list_sort(started_list, pe__cmp_node_name);
for (gIter = started_list; gIter; gIter = gIter->next) {
- pe_node_t *host = gIter->data;
+ pcmk_node_t *host = gIter->data;
if (!pcmk__str_in_list(host->details->uname, only_node,
pcmk__str_star_matches|pcmk__str_casei)) {
@@ -1052,10 +1063,10 @@ pe__clone_default(pcmk__output_t *out, va_list args)
if ((list_text != NULL) && (list_text->len > 0)) {
clone_header(out, &rc, rsc, clone_data, desc);
- if (pcmk_is_set(rsc->flags, pe_rsc_promotable)) {
+ if (pcmk_is_set(rsc->flags, pcmk_rsc_promotable)) {
enum rsc_role_e role = configured_role(rsc);
- if (role == RSC_ROLE_UNPROMOTED) {
+ if (role == pcmk_role_unpromoted) {
out->list_item(out, NULL,
UNPROMOTED_INSTANCES " (target-role): [ %s ]",
(const char *) list_text->str);
@@ -1075,7 +1086,7 @@ pe__clone_default(pcmk__output_t *out, va_list args)
}
if (pcmk_is_set(show_opts, pcmk_show_inactive_rscs)) {
- if (!pcmk_is_set(rsc->flags, pe_rsc_unique)
+ if (!pcmk_is_set(rsc->flags, pcmk_rsc_unique)
&& (clone_data->clone_max > active_instances)) {
GList *nIter;
@@ -1096,7 +1107,7 @@ pe__clone_default(pcmk__output_t *out, va_list args)
list = g_list_sort(list, pe__cmp_node_name);
for (nIter = list; nIter != NULL; nIter = nIter->next) {
- pe_node_t *node = (pe_node_t *)nIter->data;
+ pcmk_node_t *node = (pcmk_node_t *) nIter->data;
if (pe_find_node(rsc->running_on, node->details->uname) == NULL &&
pcmk__str_in_list(node->details->uname, only_node,
@@ -1104,7 +1115,7 @@ pe__clone_default(pcmk__output_t *out, va_list args)
xmlNode *probe_op = pe__failed_probe_for_rsc(rsc, node->details->uname);
const char *state = "Stopped";
- if (configured_role(rsc) == RSC_ROLE_STOPPED) {
+ if (configured_role(rsc) == pcmk_role_stopped) {
state = "Stopped (disabled)";
}
@@ -1166,7 +1177,7 @@ pe__clone_default(pcmk__output_t *out, va_list args)
}
void
-clone_free(pe_resource_t * rsc)
+clone_free(pcmk_resource_t * rsc)
{
clone_variant_data_t *clone_data = NULL;
@@ -1175,7 +1186,7 @@ clone_free(pe_resource_t * rsc)
pe_rsc_trace(rsc, "Freeing %s", rsc->id);
for (GList *gIter = rsc->children; 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;
CRM_ASSERT(child_rsc);
pe_rsc_trace(child_rsc, "Freeing child %s", child_rsc->id);
@@ -1200,13 +1211,13 @@ clone_free(pe_resource_t * rsc)
}
enum rsc_role_e
-clone_resource_state(const pe_resource_t * rsc, gboolean current)
+clone_resource_state(const pcmk_resource_t * rsc, gboolean current)
{
- enum rsc_role_e clone_role = RSC_ROLE_UNKNOWN;
+ enum rsc_role_e clone_role = pcmk_role_unknown;
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;
enum rsc_role_e a_role = child_rsc->fns->state(child_rsc, current);
if (a_role > clone_role) {
@@ -1222,17 +1233,17 @@ clone_resource_state(const pe_resource_t * rsc, gboolean current)
* \internal
* \brief Check whether a clone has an instance for every node
*
- * \param[in] rsc Clone to check
- * \param[in] data_set Cluster state
+ * \param[in] rsc Clone to check
+ * \param[in] scheduler Scheduler data
*/
bool
-pe__is_universal_clone(const pe_resource_t *rsc,
- const pe_working_set_t *data_set)
+pe__is_universal_clone(const pcmk_resource_t *rsc,
+ const pcmk_scheduler_t *scheduler)
{
if (pe_rsc_is_clone(rsc)) {
clone_variant_data_t *clone_data = rsc->variant_opaque;
- if (clone_data->clone_max == g_list_length(data_set->nodes)) {
+ if (clone_data->clone_max == g_list_length(scheduler->nodes)) {
return TRUE;
}
}
@@ -1240,7 +1251,7 @@ pe__is_universal_clone(const pe_resource_t *rsc,
}
gboolean
-pe__clone_is_filtered(const pe_resource_t *rsc, GList *only_rsc,
+pe__clone_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc,
gboolean check_parent)
{
gboolean passes = FALSE;
@@ -1256,9 +1267,9 @@ pe__clone_is_filtered(const pe_resource_t *rsc, GList *only_rsc,
for (const GList *iter = rsc->children;
iter != NULL; iter = iter->next) {
- const pe_resource_t *child_rsc = NULL;
+ const pcmk_resource_t *child_rsc = NULL;
- child_rsc = (const pe_resource_t *) iter->data;
+ child_rsc = (const pcmk_resource_t *) iter->data;
if (!child_rsc->fns->is_filtered(child_rsc, only_rsc, FALSE)) {
passes = TRUE;
break;
@@ -1270,7 +1281,7 @@ pe__clone_is_filtered(const pe_resource_t *rsc, GList *only_rsc,
}
const char *
-pe__clone_child_id(const pe_resource_t *rsc)
+pe__clone_child_id(const pcmk_resource_t *rsc)
{
clone_variant_data_t *clone_data = NULL;
get_clone_variant_data(clone_data, rsc);
@@ -1286,12 +1297,12 @@ pe__clone_child_id(const pe_resource_t *rsc)
* \return true if clone is ordered, otherwise false
*/
bool
-pe__clone_is_ordered(const pe_resource_t *clone)
+pe__clone_is_ordered(const pcmk_resource_t *clone)
{
clone_variant_data_t *clone_data = NULL;
get_clone_variant_data(clone_data, clone);
- return pcmk_is_set(clone_data->flags, pe__clone_ordered);
+ return pcmk_is_set(clone_data->flags, pcmk__clone_ordered);
}
/*!
@@ -1305,7 +1316,7 @@ pe__clone_is_ordered(const pe_resource_t *clone)
* already set or pcmk_rc_already if it was)
*/
int
-pe__set_clone_flag(pe_resource_t *clone, enum pe__clone_flags flag)
+pe__set_clone_flag(pcmk_resource_t *clone, enum pcmk__clone_flags flag)
{
clone_variant_data_t *clone_data = NULL;
@@ -1321,6 +1332,26 @@ pe__set_clone_flag(pe_resource_t *clone, enum pe__clone_flags flag)
/*!
* \internal
+ * \brief Check whether a clone flag is set
+ *
+ * \param[in] group Clone resource to check
+ * \param[in] flags Flag or flags to check
+ *
+ * \return \c true if all \p flags are set for \p clone, otherwise \c false
+ */
+bool
+pe__clone_flag_is_set(const pcmk_resource_t *clone, uint32_t flags)
+{
+ clone_variant_data_t *clone_data = NULL;
+
+ get_clone_variant_data(clone_data, clone);
+ CRM_ASSERT(clone_data != NULL);
+
+ return pcmk_all_flags_set(clone_data->flags, flags);
+}
+
+/*!
+ * \internal
* \brief Create pseudo-actions needed for promotable clones
*
* \param[in,out] clone Promotable clone to create actions for
@@ -1328,63 +1359,59 @@ pe__set_clone_flag(pe_resource_t *clone, enum pe__clone_flags flag)
* \param[in] any_demoting Whether any instance will be demoted
*/
void
-pe__create_promotable_pseudo_ops(pe_resource_t *clone, bool any_promoting,
+pe__create_promotable_pseudo_ops(pcmk_resource_t *clone, bool any_promoting,
bool any_demoting)
{
- pe_action_t *action = NULL;
- pe_action_t *action_complete = NULL;
+ pcmk_action_t *action = NULL;
+ pcmk_action_t *action_complete = NULL;
clone_variant_data_t *clone_data = NULL;
get_clone_variant_data(clone_data, clone);
// Create a "promote" action for the clone itself
- action = pe__new_rsc_pseudo_action(clone, RSC_PROMOTE, !any_promoting,
- true);
+ action = pe__new_rsc_pseudo_action(clone, PCMK_ACTION_PROMOTE,
+ !any_promoting, true);
// Create a "promoted" action for when all promotions are done
- action_complete = pe__new_rsc_pseudo_action(clone, RSC_PROMOTED,
+ action_complete = pe__new_rsc_pseudo_action(clone, PCMK_ACTION_PROMOTED,
!any_promoting, true);
action_complete->priority = INFINITY;
// Create notification pseudo-actions for promotion
if (clone_data->promote_notify == NULL) {
clone_data->promote_notify = pe__action_notif_pseudo_ops(clone,
- RSC_PROMOTE,
+ PCMK_ACTION_PROMOTE,
action,
action_complete);
}
// Create a "demote" action for the clone itself
- action = pe__new_rsc_pseudo_action(clone, RSC_DEMOTE, !any_demoting, true);
+ action = pe__new_rsc_pseudo_action(clone, PCMK_ACTION_DEMOTE,
+ !any_demoting, true);
// Create a "demoted" action for when all demotions are done
- action_complete = pe__new_rsc_pseudo_action(clone, RSC_DEMOTED,
+ action_complete = pe__new_rsc_pseudo_action(clone, PCMK_ACTION_DEMOTED,
!any_demoting, true);
action_complete->priority = INFINITY;
// Create notification pseudo-actions for demotion
if (clone_data->demote_notify == NULL) {
clone_data->demote_notify = pe__action_notif_pseudo_ops(clone,
- RSC_DEMOTE,
+ PCMK_ACTION_DEMOTE,
action,
action_complete);
if (clone_data->promote_notify != NULL) {
order_actions(clone_data->stop_notify->post_done,
- clone_data->promote_notify->pre,
- pe_order_optional);
+ clone_data->promote_notify->pre, pcmk__ar_ordered);
order_actions(clone_data->start_notify->post_done,
- clone_data->promote_notify->pre,
- pe_order_optional);
+ clone_data->promote_notify->pre, pcmk__ar_ordered);
order_actions(clone_data->demote_notify->post_done,
- clone_data->promote_notify->pre,
- pe_order_optional);
+ clone_data->promote_notify->pre, pcmk__ar_ordered);
order_actions(clone_data->demote_notify->post_done,
- clone_data->start_notify->pre,
- pe_order_optional);
+ clone_data->start_notify->pre, pcmk__ar_ordered);
order_actions(clone_data->demote_notify->post_done,
- clone_data->stop_notify->pre,
- pe_order_optional);
+ clone_data->stop_notify->pre, pcmk__ar_ordered);
}
}
}
@@ -1396,7 +1423,7 @@ pe__create_promotable_pseudo_ops(pe_resource_t *clone, bool any_promoting,
* \param[in,out] clone Clone to create notifications for
*/
void
-pe__create_clone_notifications(pe_resource_t *clone)
+pe__create_clone_notifications(pcmk_resource_t *clone)
{
clone_variant_data_t *clone_data = NULL;
@@ -1415,7 +1442,7 @@ pe__create_clone_notifications(pe_resource_t *clone)
* \param[in,out] clone Clone to free notification data for
*/
void
-pe__free_clone_notification_data(pe_resource_t *clone)
+pe__free_clone_notification_data(pcmk_resource_t *clone)
{
clone_variant_data_t *clone_data = NULL;
@@ -1445,26 +1472,45 @@ pe__free_clone_notification_data(pe_resource_t *clone)
* \param[in,out] stopped Stopped action for \p clone
*/
void
-pe__create_clone_notif_pseudo_ops(pe_resource_t *clone,
- pe_action_t *start, pe_action_t *started,
- pe_action_t *stop, pe_action_t *stopped)
+pe__create_clone_notif_pseudo_ops(pcmk_resource_t *clone,
+ pcmk_action_t *start, pcmk_action_t *started,
+ pcmk_action_t *stop, pcmk_action_t *stopped)
{
clone_variant_data_t *clone_data = NULL;
get_clone_variant_data(clone_data, clone);
if (clone_data->start_notify == NULL) {
- clone_data->start_notify = pe__action_notif_pseudo_ops(clone, RSC_START,
+ clone_data->start_notify = pe__action_notif_pseudo_ops(clone,
+ PCMK_ACTION_START,
start, started);
}
if (clone_data->stop_notify == NULL) {
- clone_data->stop_notify = pe__action_notif_pseudo_ops(clone, RSC_STOP,
+ clone_data->stop_notify = pe__action_notif_pseudo_ops(clone,
+ PCMK_ACTION_STOP,
stop, stopped);
if ((clone_data->start_notify != NULL)
&& (clone_data->stop_notify != NULL)) {
order_actions(clone_data->stop_notify->post_done,
- clone_data->start_notify->pre, pe_order_optional);
+ clone_data->start_notify->pre, pcmk__ar_ordered);
}
}
}
+
+/*!
+ * \internal
+ * \brief Get maximum clone resource instances per node
+ *
+ * \param[in] rsc Clone resource to check
+ *
+ * \return Maximum number of \p rsc instances that can be active on one node
+ */
+unsigned int
+pe__clone_max_per_node(const pcmk_resource_t *rsc)
+{
+ const clone_variant_data_t *clone_data = NULL;
+
+ get_clone_variant_data(clone_data, rsc);
+ return clone_data->clone_node_max;
+}