Blob Blame History Raw
From f296fea9e3d20bc5fd3e58725e5d536dff947ea8 Mon Sep 17 00:00:00 2001
From: Andrew Beekhof <andrew@beekhof.net>
Date: Tue, 21 Mar 2017 14:44:56 +1100
Subject: [PATCH 1/2] PE: Restore ABI compatibility with pre-container code

---
 fencing/main.c                |  2 +-
 include/crm/pengine/complex.h |  6 +++---
 lib/pengine/clone.c           |  2 +-
 lib/pengine/complex.c         | 29 +++++++++++++++--------------
 lib/pengine/unpack.c          |  6 +++---
 pengine/allocate.c            | 32 ++++++++++++++++----------------
 pengine/clone.c               |  6 +++---
 pengine/constraints.c         | 14 +++++++-------
 pengine/graph.c               |  4 ++--
 pengine/native.c              |  4 ++--
 pengine/utilization.c         | 13 ++++---------
 tools/crm_resource_runtime.c  | 21 ++++++++++-----------
 12 files changed, 67 insertions(+), 72 deletions(-)

diff --git a/fencing/main.c b/fencing/main.c
index e6eb087..437c31f 100644
--- a/fencing/main.c
+++ b/fencing/main.c
@@ -620,7 +620,7 @@ static void cib_device_update(resource_t *rsc, pe_working_set_t *data_set)
         GListPtr gIter = NULL;
         for (gIter = rsc->children; gIter != NULL; gIter = gIter->next) {
             cib_device_update(gIter->data, data_set);
-            if(rsc->variant == pe_clone || rsc->variant == pe_master) {
+            if(pe_rsc_is_clone(rsc)) {
                 crm_trace("Only processing one copy of the clone %s", rsc->id);
                 break;
             }
diff --git a/include/crm/pengine/complex.h b/include/crm/pengine/complex.h
index 92829f9..664d576 100644
--- a/include/crm/pengine/complex.h
+++ b/include/crm/pengine/complex.h
@@ -31,9 +31,9 @@ enum pe_obj_types {
     pe_unknown = -1,
     pe_native = 0,
     pe_group = 1,
-    pe_container = 2,
-    pe_clone = 3,
-    pe_master = 4
+    pe_clone = 2,
+    pe_master = 3,
+    pe_container = 4,
 };
 
 enum pe_obj_types get_resource_type(const char *name);
diff --git a/lib/pengine/clone.c b/lib/pengine/clone.c
index 6604a29..6652e59 100644
--- a/lib/pengine/clone.c
+++ b/lib/pengine/clone.c
@@ -47,7 +47,7 @@ mark_as_orphan(resource_t * rsc)
 void
 force_non_unique_clone(resource_t * rsc, const char *rid, pe_working_set_t * data_set)
 {
-    if (rsc->variant == pe_clone || rsc->variant == pe_master) {
+    if (pe_rsc_is_clone(rsc)) {
         clone_variant_data_t *clone_data = NULL;
 
         get_clone_variant_data(clone_data, rsc);
diff --git a/lib/pengine/complex.c b/lib/pengine/complex.c
index adc8abc..c4823f4 100644
--- a/lib/pengine/complex.c
+++ b/lib/pengine/complex.c
@@ -46,16 +46,6 @@ resource_object_functions_t resource_class_functions[] = {
      group_free
     },
     {
-     container_unpack,
-     native_find_rsc,
-     native_parameter,
-     container_print,
-     container_active,
-     container_resource_state,
-     native_location,
-     container_free
-    },
-    {
      clone_unpack,
      native_find_rsc,
      native_parameter,
@@ -73,7 +63,18 @@ resource_object_functions_t resource_class_functions[] = {
      clone_active,
      clone_resource_state,
      native_location,
-     clone_free}
+     clone_free
+    },
+    {
+     container_unpack,
+     native_find_rsc,
+     native_parameter,
+     container_print,
+     container_active,
+     container_resource_state,
+     native_location,
+     container_free
+    }
 };
 
 enum pe_obj_types
@@ -404,7 +405,7 @@ handle_rsc_isolation(resource_t *rsc)
      * at the clone level. this is really the only sane thing to do in this situation.
      * This allows someone to clone an isolated resource without having to shuffle
      * around the isolation attributes to the clone parent */
-    if (top == rsc->parent && top->variant >= pe_clone) {
+    if (top == rsc->parent && pe_rsc_is_clone(top)) {
         iso = top;
     }
 
@@ -414,7 +415,7 @@ handle_rsc_isolation(resource_t *rsc)
 set_rsc_opts:
     clear_bit(rsc->flags, pe_rsc_allow_migrate);
     set_bit(rsc->flags, pe_rsc_unique);
-    if (top->variant >= pe_clone) {
+    if (pe_rsc_is_clone(top)) {
         add_hash_param(rsc->meta, XML_RSC_ATTR_UNIQUE, XML_BOOLEAN_TRUE);
     }
 }
@@ -591,7 +592,7 @@ common_unpack(xmlNode * xml_obj, resource_t ** rsc,
 
     top = uber_parent(*rsc);
     value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_UNIQUE);
-    if (crm_is_true(value) || top->variant < pe_clone) {
+    if (crm_is_true(value) || pe_rsc_is_clone(top) == FALSE) {
         set_bit((*rsc)->flags, pe_rsc_unique);
     }
 
diff --git a/lib/pengine/unpack.c b/lib/pengine/unpack.c
index 717c23b..2f03493 100644
--- a/lib/pengine/unpack.c
+++ b/lib/pengine/unpack.c
@@ -1692,7 +1692,7 @@ find_anonymous_clone(pe_working_set_t * data_set, node_t * node, resource_t * pa
     gboolean skip_inactive = FALSE;
 
     CRM_ASSERT(parent != NULL);
-    CRM_ASSERT(parent->variant == pe_clone || parent->variant == pe_master);
+    CRM_ASSERT(pe_rsc_is_clone(parent));
     CRM_ASSERT(is_not_set(parent->flags, pe_rsc_unique));
 
     /* Find an instance active (or partially active for grouped clones) on the specified node */
@@ -1815,7 +1815,7 @@ unpack_find_resource(pe_working_set_t * data_set, node_t * node, const char *rsc
     if(parent && parent->parent) {
         rsc = find_container_child(rsc_id, rsc, node);
 
-    } else if (parent && parent->variant >= pe_clone) {
+    } else if (pe_rsc_is_clone(parent)) {
         if (is_not_set(parent->flags, pe_rsc_unique)) {
             char *base = clone_strip(rsc_id);
 
@@ -2721,7 +2721,7 @@ unpack_rsc_op_failure(resource_t * rsc, node_t * node, int rc, xmlNode * xml_op,
         if (fail_rsc->parent) {
             resource_t *parent = uber_parent(fail_rsc);
 
-            if ((parent->variant == pe_clone || parent->variant == pe_master)
+            if (pe_rsc_is_clone(parent)
                 && is_not_set(parent->flags, pe_rsc_unique)) {
                 /* for clone and master resources, if a child fails on an operation
                  * with on-fail = stop, all the resources fail.  Do this by preventing
diff --git a/pengine/allocate.c b/pengine/allocate.c
index bfc2471..3314d77 100644
--- a/pengine/allocate.c
+++ b/pengine/allocate.c
@@ -69,20 +69,6 @@ resource_alloc_functions_t resource_class_alloc_functions[] = {
      group_append_meta,
      },
     {
-     container_merge_weights,
-     container_color,
-     container_create_actions,
-     container_create_probe,
-     container_internal_constraints,
-     container_rsc_colocation_lh,
-     container_rsc_colocation_rh,
-     container_rsc_location,
-     container_action_flags,
-     container_update_actions,
-     container_expand,
-     container_append_meta,
-     },
-    {
      clone_merge_weights,
      clone_color,
      clone_create_actions,
@@ -109,6 +95,20 @@ resource_alloc_functions_t resource_class_alloc_functions[] = {
      clone_update_actions,
      clone_expand,
      master_append_meta,
+     },
+    {
+     container_merge_weights,
+     container_color,
+     container_create_actions,
+     container_create_probe,
+     container_internal_constraints,
+     container_rsc_colocation_lh,
+     container_rsc_colocation_rh,
+     container_rsc_location,
+     container_action_flags,
+     container_update_actions,
+     container_expand,
+     container_append_meta,
      }
 };
 
@@ -389,7 +389,7 @@ check_actions_for(xmlNode * rsc_entry, resource_t * rsc, node_t * node, pe_worki
     if (is_set(rsc->flags, pe_rsc_orphan)) {
         resource_t *parent = uber_parent(rsc);
         if(parent == NULL
-           || parent->variant < pe_clone
+           || pe_rsc_is_clone(parent) == FALSE
            || is_set(parent->flags, pe_rsc_unique)) {
             pe_rsc_trace(rsc, "Skipping param check for %s and deleting: orphan", rsc->id);
             DeleteRsc(rsc, node, FALSE, data_set);
@@ -2022,7 +2022,7 @@ order_probes(pe_working_set_t * data_set)
                 crm_trace("Same parent %s for %s", first_rsc->id, start->uuid);
                 continue;
 
-            } else if(FALSE && uber_parent(first_rsc)->variant < pe_clone) {
+            } else if(FALSE && pe_rsc_is_clone(uber_parent(first_rsc)) == FALSE) {
                 crm_trace("Not a clone %s for %s", first_rsc->id, start->uuid);
                 continue;
             }
diff --git a/pengine/clone.c b/pengine/clone.c
index 9e2835d..2b332b1 100644
--- a/pengine/clone.c
+++ b/pengine/clone.c
@@ -1071,7 +1071,7 @@ clone_rsc_colocation_rh(resource_t * rsc_lh, resource_t * rsc_rh, rsc_colocation
     pe_rsc_trace(rsc_rh, "Processing constraint %s: %s -> %s %d",
                  constraint->id, rsc_lh->id, rsc_rh->id, constraint->score);
 
-    if (constraint->rsc_lh->variant >= pe_clone) {
+    if (pe_rsc_is_clone(constraint->rsc_lh)) {
 
         get_clone_variant_data(clone_data_lh, constraint->rsc_lh);
         if (clone_data_lh->interleave
@@ -1339,8 +1339,8 @@ clone_update_actions(action_t * first, action_t * then, node_t * node, enum pe_a
     enum pe_graph_flags changed = pe_graph_none;
 
     if (first->rsc != then->rsc
-        && first->rsc && first->rsc->variant >= pe_clone
-        && then->rsc && then->rsc->variant >= pe_clone) {
+        && pe_rsc_is_clone(first->rsc)
+        && pe_rsc_is_clone(then->rsc)) {
         clone_variant_data_t *clone_data = NULL;
 
         if (crm_ends_with(then->uuid, "_stop_0")
diff --git a/pengine/constraints.c b/pengine/constraints.c
index 92b9dd0..501cb57 100644
--- a/pengine/constraints.c
+++ b/pengine/constraints.c
@@ -316,13 +316,13 @@ unpack_simple_rsc_order(xmlNode * xml_obj, pe_working_set_t * data_set)
         crm_config_err("Constraint %s: no resource found for name '%s'", id, id_first);
         return FALSE;
 
-    } else if (instance_then && rsc_then->variant < pe_clone) {
+    } else if (instance_then && pe_rsc_is_clone(rsc_then) == FALSE) {
         crm_config_err("Invalid constraint '%s':"
                        " Resource '%s' is not a clone but instance %s was requested",
                        id, id_then, instance_then);
         return FALSE;
 
-    } else if (instance_first && rsc_first->variant < pe_clone) {
+    } else if (instance_first && pe_rsc_is_clone(rsc_first) == FALSE) {
         crm_config_err("Invalid constraint '%s':"
                        " Resource '%s' is not a clone but instance %s was requested",
                        id, id_first, instance_first);
@@ -350,11 +350,11 @@ unpack_simple_rsc_order(xmlNode * xml_obj, pe_working_set_t * data_set)
     require_all_s = crm_element_value(xml_obj, "require-all");
     if (require_all_s
         && crm_is_true(require_all_s) == FALSE
-        && rsc_first->variant >= pe_clone) {
+        && pe_rsc_is_clone(rsc_first)) {
 
         /* require-all=false means only one instance of the clone is required */
         min_required_before = 1;
-    } else if (rsc_first->variant >= pe_clone) {
+    } else if (pe_rsc_is_clone(rsc_first)) {
         const char *min_clones_s = g_hash_table_lookup(rsc_first->meta, XML_RSC_ATTR_INCARNATION_MIN);
         if (min_clones_s) {
             /* if clone min is set, we require at a minimum X number of instances
@@ -2343,13 +2343,13 @@ unpack_simple_colocation(xmlNode * xml_obj, pe_working_set_t * data_set)
         crm_config_err("Invalid constraint '%s': No resource named '%s'", id, id_rh);
         return FALSE;
 
-    } else if (instance_lh && rsc_lh->variant < pe_clone) {
+    } else if (instance_lh && pe_rsc_is_clone(rsc_lh) == FALSE) {
         crm_config_err
             ("Invalid constraint '%s': Resource '%s' is not a clone but instance %s was requested",
              id, id_lh, instance_lh);
         return FALSE;
 
-    } else if (instance_rh && rsc_rh->variant < pe_clone) {
+    } else if (instance_rh && pe_rsc_is_clone(rsc_rh) == FALSE) {
         crm_config_err
             ("Invalid constraint '%s': Resource '%s' is not a clone but instance %s was requested",
              id, id_rh, instance_rh);
@@ -2721,7 +2721,7 @@ unpack_simple_rsc_ticket(xmlNode * xml_obj, pe_working_set_t * data_set)
         crm_config_err("Invalid constraint '%s': No resource named '%s'", id, id_lh);
         return FALSE;
 
-    } else if (instance_lh && rsc_lh->variant < pe_clone) {
+    } else if (instance_lh && pe_rsc_is_clone(rsc_lh) == FALSE) {
         crm_config_err
             ("Invalid constraint '%s': Resource '%s' is not a clone but instance %s was requested",
              id, id_lh, instance_lh);
diff --git a/pengine/graph.c b/pengine/graph.c
index 07fc60a..2dba08e 100644
--- a/pengine/graph.c
+++ b/pengine/graph.c
@@ -40,7 +40,7 @@ get_action_flags(action_t * action, node_t * node)
     if (action->rsc) {
         flags = action->rsc->cmds->action_flags(action, NULL);
 
-        if (action->rsc->variant >= pe_clone && node) {
+        if (pe_rsc_is_clone(action->rsc) && node) {
 
             /* We only care about activity on $node */
             enum pe_action_flags clone_flags = action->rsc->cmds->action_flags(action, node);
@@ -1426,7 +1426,7 @@ check_dump_input(int last_action, action_t * action, action_wrapper_t * wrapper)
                && is_set(wrapper->action->rsc->flags, pe_rsc_failed)
                && is_not_set(wrapper->action->rsc->flags, pe_rsc_managed)
                && crm_ends_with(wrapper->action->uuid, "_stop_0")
-               && action->rsc && action->rsc->variant >= pe_clone) {
+               && action->rsc && pe_rsc_is_clone(action->rsc)) {
         crm_warn("Ignoring requirement that %s complete before %s:"
                  " unmanaged failed resources cannot prevent clone shutdown",
                  wrapper->action->uuid, action->uuid);
diff --git a/pengine/native.c b/pengine/native.c
index 4d91c00..d0cebb3 100644
--- a/pengine/native.c
+++ b/pengine/native.c
@@ -2827,7 +2827,7 @@ native_create_probe(resource_t * rsc, node_t * node, action_t * complete,
     if(is_set(rsc->flags, pe_rsc_fence_device) && is_set(data_set->flags, pe_flag_enable_unfencing)) {
         top = rsc;
 
-    } else if (top->variant < pe_clone) {
+    } else if (pe_rsc_is_clone(top) == FALSE) {
         top = rsc;
 
     } else {
@@ -3221,7 +3221,7 @@ native_append_meta(resource_t * rsc, xmlNode * xml)
 
         /* instance name for isolated environment */
         name = crm_meta_name(XML_RSC_ATTR_ISOLATION_INSTANCE);
-        if (iso_parent->variant >= pe_clone) { 
+        if (pe_rsc_is_clone(iso_parent)) { 
             /* if isolation is set at the clone/master level, we have to 
              * give this resource the unique isolation instance associated
              * with the clone child (last_parent)*/
diff --git a/pengine/utilization.c b/pengine/utilization.c
index e3996e2..5219fb8 100644
--- a/pengine/utilization.c
+++ b/pengine/utilization.c
@@ -201,8 +201,7 @@ add_unallocated_utilization(GHashTable * all_utilization, resource_t * rsc,
                      orig_rsc->id, rsc->id);
         group_add_unallocated_utilization(all_utilization, rsc, all_rscs);
 
-    } else if (rsc->variant == pe_clone ||
-               rsc->variant == pe_master) {
+    } else if (pe_rsc_is_clone(rsc)) {
         GListPtr gIter1 = NULL;
         gboolean existing = FALSE;
 
@@ -317,7 +316,7 @@ find_colocated_rscs(GListPtr colocated_rscs, resource_t * rsc, resource_t * orig
             continue;
         }
 
-        if (rsc_lh->variant <= pe_group && rsc->variant >= pe_clone) {
+        if (pe_rsc_is_clone(rsc_lh) == FALSE && pe_rsc_is_clone(rsc)) {
             /* We do not know if rsc_lh will be colocated with orig_rsc in this case */
             continue;
         }
@@ -427,9 +426,7 @@ group_find_colocated_rscs(GListPtr colocated_rscs, resource_t * rsc, resource_t
     group_variant_data_t *group_data = NULL;
 
     get_group_variant_data(group_data, rsc);
-    if (group_data->colocated ||
-        (rsc->parent &&
-         (rsc->parent->variant == pe_clone || rsc->parent->variant == pe_master))) {
+    if (group_data->colocated || pe_rsc_is_clone(rsc->parent)) {
         GListPtr gIter = rsc->children;
 
         for (; gIter != NULL; gIter = gIter->next) {
@@ -456,9 +453,7 @@ group_add_unallocated_utilization(GHashTable * all_utilization, resource_t * rsc
     group_variant_data_t *group_data = NULL;
 
     get_group_variant_data(group_data, rsc);
-    if (group_data->colocated ||
-        (rsc->parent &&
-         (rsc->parent->variant == pe_clone || rsc->parent->variant == pe_master))) {
+    if (group_data->colocated || pe_rsc_is_clone(rsc->parent)) {
         GListPtr gIter = rsc->children;
 
         for (; gIter != NULL; gIter = gIter->next) {
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c
index 9c201a0..af96909 100644
--- a/tools/crm_resource_runtime.c
+++ b/tools/crm_resource_runtime.c
@@ -40,7 +40,7 @@ do_find_resource(const char *rsc, resource_t * the_rsc, pe_working_set_t * data_
         } else {
             const char *state = "";
 
-            if (the_rsc->variant < pe_clone && the_rsc->fns->state(the_rsc, TRUE) == RSC_ROLE_MASTER) {
+            if (!pe_rsc_is_clone(the_rsc) && the_rsc->fns->state(the_rsc, TRUE) == RSC_ROLE_MASTER) {
                 state = "Master";
             }
             fprintf(stdout, "resource %s is running on: %s %s\n", rsc, node->details->uname, state);
@@ -71,7 +71,7 @@ cli_resource_search(const char *rsc, pe_working_set_t * data_set)
         return -ENXIO;
     }
 
-    if (the_rsc->variant >= pe_clone) {
+    if (pe_rsc_is_clone(the_rsc)) {
         GListPtr gIter = the_rsc->children;
 
         for (; gIter != NULL; gIter = gIter->next) {
@@ -80,7 +80,7 @@ cli_resource_search(const char *rsc, pe_working_set_t * data_set)
 
     /* The anonymous clone children's common ID is supplied */
     } else if ((parent = uber_parent(the_rsc)) != NULL
-               && parent->variant >= pe_clone
+               && pe_rsc_is_clone(parent)
                && is_not_set(the_rsc->flags, pe_rsc_unique)
                && the_rsc->clone_name
                && safe_str_eq(rsc, the_rsc->clone_name)
@@ -618,8 +618,7 @@ cli_resource_delete(cib_t *cib_conn, crm_ipc_t *crmd_channel, const char *host_uname,
             resource_t *child = (resource_t *) lpc->data;
 
             rc = cli_resource_delete(cib_conn, crmd_channel, host_uname, child, data_set);
-            if(rc != pcmk_ok
-               || (rsc->variant >= pe_clone && is_not_set(rsc->flags, pe_rsc_unique))) {
+            if(rc != pcmk_ok || (pe_rsc_is_clone(rsc) && is_not_set(rsc->flags, pe_rsc_unique))) {
                 return rc;
             }
         }
@@ -711,7 +710,7 @@ cli_resource_check(cib_t * cib_conn, resource_t *rsc)
             printf("\n  * The configuration specifies that '%s' should remain stopped\n", parent->id);
             need_nl++;
 
-        } else if(parent->variant > pe_clone && role == RSC_ROLE_SLAVE) {
+        } else if(parent->variant == pe_master && role == RSC_ROLE_SLAVE) {
             printf("\n  * The configuration specifies that '%s' should not be promoted\n", parent->id);
             need_nl++;
         }
@@ -1117,7 +1116,7 @@ cli_resource_restart(resource_t * rsc, const char *host, int timeout_ms, cib_t *
     attr_set_type = XML_TAG_META_SETS;
 
     rsc_id = strdup(rsc->id);
-    if(rsc->variant >= pe_clone) {
+    if(pe_rsc_is_clone(rsc)) {
         is_clone = TRUE;
     }
 
@@ -1489,7 +1488,7 @@ cli_resource_execute(const char *rsc_id, const char *rsc_action, GHashTable *ove
                || safe_str_eq(rsc_action, "force-promote")) {
         action = rsc_action+6;
 
-        if(rsc->variant >= pe_clone) {
+        if(pe_rsc_is_clone(rsc)) {
             rc = cli_resource_search(rsc_id, data_set);
             if(rc > 0 && do_force == FALSE) {
                 CMD_ERR("It is not safe to %s %s here: the cluster claims it is already active", action, rsc_id);
@@ -1499,7 +1498,7 @@ cli_resource_execute(const char *rsc_id, const char *rsc_action, GHashTable *ove
         }
     }
 
-    if(rsc->variant == pe_clone || rsc->variant == pe_master) {
+    if(pe_rsc_is_clone(rsc)) {
         /* Grab the first child resource in the hope it's not a group */
         rsc = rsc->children->data;
     }
@@ -1613,7 +1612,7 @@ cli_resource_move(const char *rsc_id, const char *host_name, cib_t * cib, pe_wor
         CMD_ERR("Resource '%s' not moved: not found", rsc_id);
         return -ENXIO;
 
-    } else if (scope_master && rsc->variant < pe_master) {
+    } else if (scope_master && rsc->variant != pe_master) {
         resource_t *p = uber_parent(rsc);
         if(p->variant == pe_master) {
             CMD_ERR("Using parent '%s' for --move command instead of '%s'.", rsc->id, rsc_id);
@@ -1644,7 +1643,7 @@ cli_resource_move(const char *rsc_id, const char *host_name, cib_t * cib, pe_wor
             count = g_list_length(rsc->running_on);
         }
 
-    } else if (rsc->variant >= pe_clone) {
+    } else if (pe_rsc_is_clone(rsc)) {
         count = g_list_length(rsc->running_on);
 
     } else if (g_list_length(rsc->running_on) > 1) {
-- 
1.8.3.1


From 41e08386cb3671c19a5045b5a3084c9c8c4799c1 Mon Sep 17 00:00:00 2001
From: Andrew Beekhof <andrew@beekhof.net>
Date: Tue, 21 Mar 2017 14:47:16 +1100
Subject: [PATCH 2/2] PE: Rename 'bucket' to 'bundle' for public consumption

---
 include/crm/msg_xml.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/crm/msg_xml.h b/include/crm/msg_xml.h
index 7f8ee7e..7198fe5 100644
--- a/include/crm/msg_xml.h
+++ b/include/crm/msg_xml.h
@@ -186,7 +186,7 @@
 #  define XML_CIB_TAG_GROUP	  	"group"
 #  define XML_CIB_TAG_INCARNATION	"clone"
 #  define XML_CIB_TAG_MASTER		"master"
-#  define XML_CIB_TAG_CONTAINER		"bucket"
+#  define XML_CIB_TAG_CONTAINER		"bundle"
 
 #  define XML_CIB_TAG_RSC_TEMPLATE	"template"
 
-- 
1.8.3.1