|
|
139d2d |
From 648f048aeaee089ec74953107e6252543b710966 Mon Sep 17 00:00:00 2001
|
|
|
139d2d |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
139d2d |
Date: Wed, 21 Jun 2017 20:40:34 -0500
|
|
|
139d2d |
Subject: [PATCH] Fix: libpe_status: properly disallow other resources from
|
|
|
139d2d |
bundle nodes
|
|
|
139d2d |
|
|
|
139d2d |
---
|
|
|
139d2d |
lib/pengine/container.c | 34 +++++++++++++++++++++++++++++-----
|
|
|
139d2d |
1 file changed, 29 insertions(+), 5 deletions(-)
|
|
|
139d2d |
|
|
|
139d2d |
diff --git a/lib/pengine/container.c b/lib/pengine/container.c
|
|
|
139d2d |
index e916446..cf81253 100644
|
|
|
139d2d |
--- a/lib/pengine/container.c
|
|
|
139d2d |
+++ b/lib/pengine/container.c
|
|
|
139d2d |
@@ -335,6 +335,29 @@ create_docker_resource(
|
|
|
139d2d |
return TRUE;
|
|
|
139d2d |
}
|
|
|
139d2d |
|
|
|
139d2d |
+/*!
|
|
|
139d2d |
+ * \brief Ban a node from a resource's (and its children's) allowed nodes list
|
|
|
139d2d |
+ *
|
|
|
139d2d |
+ * \param[in,out] rsc Resource to modify
|
|
|
139d2d |
+ * \param[in] uname Name of node to ban
|
|
|
139d2d |
+ */
|
|
|
139d2d |
+static void
|
|
|
139d2d |
+disallow_node(resource_t *rsc, const char *uname)
|
|
|
139d2d |
+{
|
|
|
139d2d |
+ gpointer match = g_hash_table_lookup(rsc->allowed_nodes, uname);
|
|
|
139d2d |
+
|
|
|
139d2d |
+ if (match) {
|
|
|
139d2d |
+ ((pe_node_t *) match)->weight = -INFINITY;
|
|
|
139d2d |
+ }
|
|
|
139d2d |
+ if (rsc->children) {
|
|
|
139d2d |
+ GListPtr child;
|
|
|
139d2d |
+
|
|
|
139d2d |
+ for (child = rsc->children; child != NULL; child = child->next) {
|
|
|
139d2d |
+ disallow_node((resource_t *) (child->data), uname);
|
|
|
139d2d |
+ }
|
|
|
139d2d |
+ }
|
|
|
139d2d |
+}
|
|
|
139d2d |
+
|
|
|
139d2d |
static bool
|
|
|
139d2d |
create_remote_resource(
|
|
|
139d2d |
resource_t *parent, container_variant_data_t *data, container_grouping_t *tuple,
|
|
|
139d2d |
@@ -413,7 +436,7 @@ create_remote_resource(
|
|
|
139d2d |
}
|
|
|
139d2d |
|
|
|
139d2d |
/* unpack_remote_nodes() ensures that each remote node and guest node
|
|
|
139d2d |
- * has a node_t entry. Ideally, it would do the same for bundle nodes.
|
|
|
139d2d |
+ * has a pe_node_t entry. Ideally, it would do the same for bundle nodes.
|
|
|
139d2d |
* Unfortunately, a bundle has to be mostly unpacked before it's obvious
|
|
|
139d2d |
* what nodes will be needed, so we do it just above.
|
|
|
139d2d |
*
|
|
|
139d2d |
@@ -424,12 +447,13 @@ create_remote_resource(
|
|
|
139d2d |
* This adds a node *copy* to each resource's allowed nodes, and these
|
|
|
139d2d |
* copies will have the wrong weight.
|
|
|
139d2d |
*
|
|
|
139d2d |
- * As a hacky workaround, clear those copies here.
|
|
|
139d2d |
+ * As a hacky workaround, fix those copies here.
|
|
|
139d2d |
+ *
|
|
|
139d2d |
+ * @TODO Possible alternative: ensure bundles are unpacked before other
|
|
|
139d2d |
+ * resources, so the weight is correct before any copies are made.
|
|
|
139d2d |
*/
|
|
|
139d2d |
for (rsc_iter = data_set->resources; rsc_iter; rsc_iter = rsc_iter->next) {
|
|
|
139d2d |
- resource_t *rsc = (resource_t *) rsc_iter->data;
|
|
|
139d2d |
-
|
|
|
139d2d |
- g_hash_table_remove(rsc->allowed_nodes, uname);
|
|
|
139d2d |
+ disallow_node((resource_t *) (rsc_iter->data), uname);
|
|
|
139d2d |
}
|
|
|
139d2d |
|
|
|
139d2d |
tuple->node = node_copy(node);
|
|
|
139d2d |
--
|
|
|
139d2d |
1.8.3.1
|
|
|
139d2d |
|