From 4896a948713f748ba04d81ce028befe61ad3dace Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Mon, 27 Mar 2017 14:32:18 -0500
Subject: [PATCH 1/5] Low: xml: re-indent for consistency
---
xml/resources-2.8.rng | 166 +++++++++++++++++++++++++-------------------------
1 file changed, 83 insertions(+), 83 deletions(-)
diff --git a/xml/resources-2.8.rng b/xml/resources-2.8.rng
index 870e804..e6dfa3a 100644
--- a/xml/resources-2.8.rng
+++ b/xml/resources-2.8.rng
@@ -68,89 +68,89 @@
<define name="element-bundle">
<element name="bundle">
- <attribute name="id"><data type="ID"/></attribute>
- <optional>
- <attribute name="description"><text/></attribute>
- </optional>
- <choice>
- <group>
- <element name="docker">
- <attribute name="image"><text/></attribute>
- <optional>
- <attribute name="replicas"><data type="integer"/></attribute>
- </optional>
- <optional>
- <attribute name="replicas-per-host"><data type="integer"/></attribute>
- </optional>
- <optional>
- <attribute name="masters"><data type="integer"/></attribute>
- </optional>
- <optional>
- <attribute name="pcmk-remote-bin"> <text/></attribute>
- </optional>
- <optional>
- <attribute name="options"><text/></attribute>
- </optional>
- </element>
- </group>
- </choice>
- <optional>
- <element name="network">
- <optional>
- <attribute name="ip-range-start"><text/></attribute>
- </optional>
- <optional>
- <attribute name="control-port"><data type="integer"/></attribute>
- </optional>
- <optional>
- <attribute name="host-network"><text/></attribute>
- </optional>
- <optional>
- <attribute name="host-netmask"><data type="integer"/></attribute>
- </optional>
- <optional>
- <attribute name="docker-network"><text/></attribute>
- </optional>
- <zeroOrMore>
- <element name="port-mapping">
- <attribute name="id"><data type="ID"/></attribute>
- <choice>
- <group>
- <attribute name="port"><data type="integer"/></attribute>
- <optional>
- <attribute name="internal-port"><data type="integer"/></attribute>
- </optional>
- </group>
- <attribute name="range">
- <data type="string">
- <param name="pattern">([0-9\-]+)</param>
- </data>
- </attribute>
- </choice>
- </element>
- </zeroOrMore>
- </element>
- </optional>
- <optional>
- <element name="storage">
- <zeroOrMore>
- <element name="storage-mapping">
- <attribute name="id"><data type="ID"/></attribute>
- <choice>
- <attribute name="source-dir"><text/></attribute>
- <attribute name="source-dir-root"><text/></attribute>
- </choice>
- <attribute name="target-dir"><text/></attribute>
- <optional>
- <attribute name="options"><text/></attribute>
- </optional>
- </element>
- </zeroOrMore>
- </element>
- </optional>
- <optional>
- <ref name="element-primitive"/>
- </optional>
+ <attribute name="id"><data type="ID"/></attribute>
+ <optional>
+ <attribute name="description"><text/></attribute>
+ </optional>
+ <choice>
+ <group>
+ <element name="docker">
+ <attribute name="image"><text/></attribute>
+ <optional>
+ <attribute name="replicas"><data type="integer"/></attribute>
+ </optional>
+ <optional>
+ <attribute name="replicas-per-host"><data type="integer"/></attribute>
+ </optional>
+ <optional>
+ <attribute name="masters"><data type="integer"/></attribute>
+ </optional>
+ <optional>
+ <attribute name="pcmk-remote-bin"> <text/></attribute>
+ </optional>
+ <optional>
+ <attribute name="options"><text/></attribute>
+ </optional>
+ </element>
+ </group>
+ </choice>
+ <optional>
+ <element name="network">
+ <optional>
+ <attribute name="ip-range-start"><text/></attribute>
+ </optional>
+ <optional>
+ <attribute name="control-port"><data type="integer"/></attribute>
+ </optional>
+ <optional>
+ <attribute name="host-network"><text/></attribute>
+ </optional>
+ <optional>
+ <attribute name="host-netmask"><data type="integer"/></attribute>
+ </optional>
+ <optional>
+ <attribute name="docker-network"><text/></attribute>
+ </optional>
+ <zeroOrMore>
+ <element name="port-mapping">
+ <attribute name="id"><data type="ID"/></attribute>
+ <choice>
+ <group>
+ <attribute name="port"><data type="integer"/></attribute>
+ <optional>
+ <attribute name="internal-port"><data type="integer"/></attribute>
+ </optional>
+ </group>
+ <attribute name="range">
+ <data type="string">
+ <param name="pattern">([0-9\-]+)</param>
+ </data>
+ </attribute>
+ </choice>
+ </element>
+ </zeroOrMore>
+ </element>
+ </optional>
+ <optional>
+ <element name="storage">
+ <zeroOrMore>
+ <element name="storage-mapping">
+ <attribute name="id"><data type="ID"/></attribute>
+ <choice>
+ <attribute name="source-dir"><text/></attribute>
+ <attribute name="source-dir-root"><text/></attribute>
+ </choice>
+ <attribute name="target-dir"><text/></attribute>
+ <optional>
+ <attribute name="options"><text/></attribute>
+ </optional>
+ </element>
+ </zeroOrMore>
+ </element>
+ </optional>
+ <optional>
+ <ref name="element-primitive"/>
+ </optional>
</element>
</define>
--
1.8.3.1
From 7b5c34893ebd631c2d98269b19fa6226ebc4b5e2 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Mon, 27 Mar 2017 14:33:18 -0500
Subject: [PATCH 2/5] Low: libpe_status,xml: changes to new bundle syntax
Get rid of pcmk-remote-bin attribute, rename host-network to host-interface,
and change 'docker-network' attribute of network element to 'network' attribute
of docker element.
---
lib/pengine/container.c | 4 ++--
xml/resources-2.8.rng | 9 ++-------
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/lib/pengine/container.c b/lib/pengine/container.c
index ed63b80..0d22bca 100644
--- a/lib/pengine/container.c
+++ b/lib/pengine/container.c
@@ -459,15 +459,15 @@ container_unpack(resource_t * rsc, pe_working_set_t * data_set)
container_data->docker_run_options = crm_element_value_copy(xml_obj, "options");
container_data->image = crm_element_value_copy(xml_obj, "image");
+ container_data->docker_network = crm_element_value_copy(xml_obj, "network");
xml_obj = first_named_child(rsc->xml, "network");
if(xml_obj) {
container_data->ip_range_start = crm_element_value_copy(xml_obj, "ip-range-start");
container_data->host_netmask = crm_element_value_copy(xml_obj, "host-netmask");
- container_data->host_network = crm_element_value_copy(xml_obj, "host-network");
+ container_data->host_network = crm_element_value_copy(xml_obj, "host-interface");
container_data->control_port = crm_element_value_copy(xml_obj, "control-port");
- container_data->docker_network = crm_element_value_copy(xml_obj, "docker-network");
for (xmlNode *xml_child = __xml_first_child_element(xml_obj); xml_child != NULL;
xml_child = __xml_next_element(xml_child)) {
diff --git a/xml/resources-2.8.rng b/xml/resources-2.8.rng
index e6dfa3a..3bc74be 100644
--- a/xml/resources-2.8.rng
+++ b/xml/resources-2.8.rng
@@ -73,7 +73,6 @@
<attribute name="description"><text/></attribute>
</optional>
<choice>
- <group>
<element name="docker">
<attribute name="image"><text/></attribute>
<optional>
@@ -86,13 +85,12 @@
<attribute name="masters"><data type="integer"/></attribute>
</optional>
<optional>
- <attribute name="pcmk-remote-bin"> <text/></attribute>
+ <attribute name="network"><text/></attribute>
</optional>
<optional>
<attribute name="options"><text/></attribute>
</optional>
</element>
- </group>
</choice>
<optional>
<element name="network">
@@ -103,14 +101,11 @@
<attribute name="control-port"><data type="integer"/></attribute>
</optional>
<optional>
- <attribute name="host-network"><text/></attribute>
+ <attribute name="host-interface"><text/></attribute>
</optional>
<optional>
<attribute name="host-netmask"><data type="integer"/></attribute>
</optional>
- <optional>
- <attribute name="docker-network"><text/></attribute>
- </optional>
<zeroOrMore>
<element name="port-mapping">
<attribute name="id"><data type="ID"/></attribute>
--
1.8.3.1
From 758c51110e8a1b0bf2f3f1fdcf4241a3e365ffa2 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Mon, 27 Mar 2017 10:51:13 -0500
Subject: [PATCH 3/5] Low: libpe_status: improve bundle docker defaults
Masters now defaults to 0 instead of 1.
Replicas now defaults to masters if masters > 0, otherwise 1.
Replicas and replicas-per-host are now constrained to be positive.
---
lib/pengine/container.c | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/lib/pengine/container.c b/lib/pengine/container.c
index 0d22bca..316f341 100644
--- a/lib/pengine/container.c
+++ b/lib/pengine/container.c
@@ -123,6 +123,7 @@ valid_network(container_variant_data_t *data)
if(data->replicas_per_host > 1) {
pe_err("Specifying the 'control-port' for %s requires 'replicas-per-host=1'", data->prefix);
data->replicas_per_host = 1;
+ /* @TODO to be sure: clear_bit(rsc->flags, pe_rsc_unique); */
}
return TRUE;
}
@@ -436,11 +437,24 @@ container_unpack(resource_t * rsc, pe_working_set_t * data_set)
return FALSE;
}
+ value = crm_element_value(xml_obj, "masters");
+ container_data->masters = crm_parse_int(value, "0");
+ if (container_data->masters < 0) {
+ pe_err("'masters' for %s must be nonnegative integer, using 0",
+ rsc->id);
+ container_data->masters = 0;
+ }
+
value = crm_element_value(xml_obj, "replicas");
- if(value == NULL) {
- value = crm_element_value(xml_obj, "masters");
+ if ((value == NULL) && (container_data->masters > 0)) {
+ container_data->replicas = container_data->masters;
+ } else {
+ container_data->replicas = crm_parse_int(value, "1");
+ }
+ if (container_data->replicas < 1) {
+ pe_err("'replicas' for %s must be positive integer, using 1", rsc->id);
+ container_data->replicas = 1;
}
- container_data->replicas = crm_parse_int(value, "1");
/*
* Communication between containers on the same host via the
@@ -449,14 +463,15 @@ container_unpack(resource_t * rsc, pe_working_set_t * data_set)
*/
value = crm_element_value(xml_obj, "replicas-per-host");
container_data->replicas_per_host = crm_parse_int(value, "1");
-
- if(container_data->replicas_per_host == 1) {
+ if (container_data->replicas_per_host < 1) {
+ pe_err("'replicas-per-host' for %s must be positive integer, using 1",
+ rsc->id);
+ container_data->replicas_per_host = 1;
+ }
+ if (container_data->replicas_per_host == 1) {
clear_bit(rsc->flags, pe_rsc_unique);
}
- value = crm_element_value(xml_obj, "masters");
- container_data->masters = crm_parse_int(value, "1");
-
container_data->docker_run_options = crm_element_value_copy(xml_obj, "options");
container_data->image = crm_element_value_copy(xml_obj, "image");
container_data->docker_network = crm_element_value_copy(xml_obj, "network");
@@ -517,7 +532,7 @@ container_unpack(resource_t * rsc, pe_working_set_t * data_set)
}
xml_obj = first_named_child(rsc->xml, "primitive");
- if(xml_obj && valid_network(container_data) && container_data->replicas > 0) {
+ if (xml_obj && valid_network(container_data)) {
char *value = NULL;
xmlNode *xml_set = NULL;
--
1.8.3.1
From e07efba927386780227d1e19789d50e8c91a6b91 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Tue, 28 Mar 2017 11:37:05 -0500
Subject: [PATCH 4/5] Log: libpe_status: ip-start-range is not only possible
networking
---
lib/pengine/container.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/lib/pengine/container.c b/lib/pengine/container.c
index 316f341..7e99e68 100644
--- a/lib/pengine/container.c
+++ b/lib/pengine/container.c
@@ -113,6 +113,18 @@ create_op(xmlNode *parent, const char *prefix, const char *task, const char *int
crm_xml_add(xml_op, "name", task);
}
+/*!
+ * \internal
+ * \brief Check whether cluster can manage resource inside container
+ *
+ * \param[in] data Container variant data
+ *
+ * \return TRUE if networking configuration is acceptable, FALSE otherwise
+ *
+ * \note The resource is manageable if an IP range or control port has been
+ * specified. If a control port is used without an IP range, replicas per
+ * host must be 1.
+ */
static bool
valid_network(container_variant_data_t *data)
{
@@ -314,7 +326,7 @@ create_remote_resource(
resource_t *parent, container_variant_data_t *data, container_grouping_t *tuple,
pe_working_set_t * data_set)
{
- if(valid_network(data) && tuple->child) {
+ if (tuple->child && valid_network(data)) {
node_t *node = NULL;
xmlNode *xml_obj = NULL;
xmlNode *xml_remote = NULL;
@@ -573,11 +585,8 @@ container_unpack(resource_t * rsc, pe_working_set_t * data_set)
//crm_xml_add(xml_obj, XML_ATTR_ID, container_data->prefix);
add_node_copy(xml_resource, xml_obj);
- /* } else if(xml_obj && container_data->ip_range_start) { */
- /* xml_resource = copy_xml(xml_resource); */
-
} else if(xml_obj) {
- pe_err("Cannot control %s inside container %s without a value for ip-range-start",
+ pe_err("Cannot control %s inside %s without either ip-range-start or control-port",
rsc->id, ID(xml_obj));
return FALSE;
}
--
1.8.3.1
From 88d4114345adf5abacc3bb1fbea3f3d5c28373fd Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Thu, 23 Mar 2017 17:16:02 -0500
Subject: [PATCH 5/5] Low: liblrmd: remote_proxy_end_session() should be static
Looks like that was intended but got lost in a merge
---
include/crm_internal.h | 1 -
lib/lrmd/proxy_common.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/include/crm_internal.h b/include/crm_internal.h
index cf0f32d..ab96b8f 100644
--- a/include/crm_internal.h
+++ b/include/crm_internal.h
@@ -384,7 +384,6 @@ int remote_proxy_dispatch(const char *buffer, ssize_t length, gpointer userdata
void remote_proxy_disconnected(gpointer data);
void remote_proxy_free(gpointer data);
-void remote_proxy_end_session(remote_proxy_t *proxy);
void remote_proxy_relay_event(remote_proxy_t *proxy, xmlNode *msg);
void remote_proxy_relay_response(remote_proxy_t *proxy, xmlNode *msg, int msg_id);
diff --git a/lib/lrmd/proxy_common.c b/lib/lrmd/proxy_common.c
index 81796d4..67f310d 100644
--- a/lib/lrmd/proxy_common.c
+++ b/lib/lrmd/proxy_common.c
@@ -100,7 +100,7 @@ remote_proxy_relay_response(remote_proxy_t *proxy, xmlNode *msg, int msg_id)
free_xml(response);
}
-void
+static void
remote_proxy_end_session(remote_proxy_t *proxy)
{
if (proxy == NULL) {
--
1.8.3.1