Permalink
Browse files

Merge pull request #1258 from kgaillot/fixes

Bundle fixes
  • Loading branch information...
kgaillot committed Apr 4, 2017
2 parents e0fbf3d + ac735f7 commit e4d588c363335ed141d82787c754cf91ba19fcb9
View
@@ -31,7 +31,7 @@ static int alerts_inflight = 0;
static gboolean draining_alerts = FALSE;
/*
* syncronize local data with cib
* synchronize local data with cib
*/
static GHashTable *
View
@@ -150,7 +150,7 @@ start_subsystem(struct crm_subsystem_s * the_subsystem)
case 0: /* Child */
/* create a new process group to avoid
* being interupted by heartbeat
* being interrupted by heartbeat
*/
setpgid(0, 0);
break;
@@ -1147,6 +1147,14 @@ a bundle's Docker container.
indexterm:[network,Docker]
indexterm:[Docker,Property,network]
|run-command
|`/usr/sbin/pacemaker_remoted` if bundle contains a +primitive+, otherwise none
|This command will be run inside the container when launching it ("PID 1"). If
the bundle contains a +primitive+, this command 'must' start pacemaker_remoted
(but could, for example, be a script that does other stuff, too).
indexterm:[network,Docker]
indexterm:[Docker,Property,network]
|options
|
|Extra command-line options to pass to `docker run`
@@ -284,6 +284,13 @@ indexterm:[Cluster,Option,pe-input-series-max]
The number of "normal" PE inputs to save. Used when reporting problems.
A value of -1 means unlimited (report all).
| placement-strategy | default |
indexterm:[placement-strategy,Cluster Option]
indexterm:[Cluster,Option,placement-strategy]
How the cluster should allocate resources to nodes (see <<s-utilization>>).
Allowed values are +default+, +utilization+, +balanced+, and +minimal+.
'(since 1.1.0)'
| node-health-strategy | none |
indexterm:[node-health-strategy,Cluster Option]
indexterm:[Cluster,Option,node-health-strategy]
@@ -1,5 +1,7 @@
= Utilization and Placement Strategy =
[[s-utilization]]
Pacemaker decides where to place a resource according to the resource
allocation scores on every node. The resource will be allocated to the
node where the resource has the highest score.
View
@@ -37,13 +37,13 @@
# include <libxml/tree.h>
# include <libxml/xpath.h>
/* Compression costs a LOT, don't do it unless we're hitting message limits
/* Define compression parameters for IPC messages
*
* For now, use 256k as the lower size, which means we can have 4 big data fields
* before we hit heartbeat's message limit
*
* The previous limit was 10k, compressing 184 of 1071 messages accounted for 23%
* of the total CPU used by the cib
* Compression costs a LOT, so we don't want to do it unless we're hitting
* message limits. Currently, we use 128KB as the threshold, because higher
* values don't play well with the heartbeat stack. With an earlier limit of
* 10KB, compressing 184 of 1071 messages accounted for 23% of the total CPU
* used by the cib.
*/
# define CRM_BZ2_BLOCKS 4
# define CRM_BZ2_WORK 20
View
@@ -30,9 +30,6 @@
/* Build version */
#undef BUILD_VERSION
/* Current version of the Pacemaker Relax-NG Schema */
#undef CRM_DTD_VERSION
/****** Other ******/
/* Group to run Pacemaker daemons as */
View
@@ -1061,7 +1061,7 @@ mainloop_child_kill(pid_t pid)
rc = child_kill_helper(match);
if(rc == -ESRCH) {
/* Its gone, but hasn't shown up in waitpid() yet
/* It's gone, but hasn't shown up in waitpid() yet
*
* Wait until we get SIGCHLD and let child_death_dispatch()
* clean it up as normal (so we get the correct return
View
@@ -285,7 +285,7 @@ create_docker_resource(
/* TODO: Allow users to specify their own?
*
* We just want to know if the container is alive, we'll
* monitor the child independantly
* monitor the child independently
*/
create_nvp(xml_obj, "monitor_cmd", "/bin/true");
/* } else if(child && data->untrusted) {
@@ -301,6 +301,10 @@ create_docker_resource(
* create_nvp(xml_obj, "monitor_cmd", "/usr/libexec/pacemaker/lrmd_internal_ctl -c poke");
*/
} else {
if(data->docker_run_command) {
create_nvp(xml_obj, "run_cmd", data->docker_run_command);
}
/* TODO: Allow users to specify their own?
*
* We don't know what's in the container, so we just want
@@ -440,6 +444,7 @@ container_unpack(resource_t * rsc, pe_working_set_t * data_set)
xmlNode *xml_resource = NULL;
container_variant_data_t *container_data = NULL;
CRM_ASSERT(rsc != NULL);
pe_rsc_trace(rsc, "Processing resource %s...", rsc->id);
container_data = calloc(1, sizeof(container_variant_data_t));
@@ -599,10 +604,22 @@ container_unpack(resource_t * rsc, pe_working_set_t * data_set)
GListPtr childIter = NULL;
resource_t *new_rsc = NULL;
container_mount_t *mount = NULL;
container_port_t *port = calloc(1, sizeof(container_port_t));
container_port_t *port = NULL;
int offset = 0, max = 1024;
char *buffer = calloc(1, max+1);
char *buffer = NULL;
if (common_unpack(xml_resource, &new_rsc, rsc, data_set) == FALSE) {
pe_err("Failed unpacking resource %s", ID(rsc->xml));
if (new_rsc != NULL && new_rsc->fns != NULL) {
new_rsc->fns->free(new_rsc);
}
return FALSE;
}
container_data->child = new_rsc;
container_data->child->orig_xml = xml_obj; // Also the trigger for common_free()
// to free xml_resource as container_data->child->xml
mount = calloc(1, sizeof(container_mount_t));
mount->source = strdup(DEFAULT_REMOTE_KEY_LOCATION);
@@ -618,27 +635,16 @@ container_unpack(resource_t * rsc, pe_working_set_t * data_set)
mount->flags = 1;
container_data->mounts = g_list_append(container_data->mounts, mount);
port = calloc(1, sizeof(container_port_t));
if(container_data->control_port) {
port->source = strdup(container_data->control_port);
} else {
port->source = crm_itoa(DEFAULT_REMOTE_PORT);
}
port->target = strdup(port->source);
container_data->ports = g_list_append(container_data->ports, port);
if (common_unpack(xml_resource, &new_rsc, rsc, data_set) == FALSE) {
pe_err("Failed unpacking resource %s", crm_element_value(rsc->xml, XML_ATTR_ID));
if (new_rsc != NULL && new_rsc->fns != NULL) {
new_rsc->fns->free(new_rsc);
}
return FALSE;
}
container_data->child = new_rsc;
container_data->child->orig_xml = xml_obj; // Also the trigger for common_free()
// to free xml_resource as container_data->child->xml
buffer = calloc(1, max+1);
for(childIter = container_data->child->children; childIter != NULL; childIter = childIter->next) {
container_grouping_t *tuple = calloc(1, sizeof(container_grouping_t));
tuple->child = childIter->data;
@@ -677,10 +683,58 @@ container_unpack(resource_t * rsc, pe_working_set_t * data_set)
return TRUE;
}
static int
tuple_rsc_active(resource_t *rsc, gboolean all)
{
if (rsc) {
gboolean child_active = rsc->fns->active(rsc, all);
if (child_active && !all) {
return TRUE;
} else if (!child_active && all) {
return FALSE;
}
}
return -1;
}
gboolean
container_active(resource_t * rsc, gboolean all)
{
return TRUE;
container_variant_data_t *container_data = NULL;
GListPtr iter = NULL;
get_container_variant_data(container_data, rsc);
for (iter = container_data->tuples; iter != NULL; iter = iter->next) {
container_grouping_t *tuple = (container_grouping_t *)(iter->data);
int rsc_active;
rsc_active = tuple_rsc_active(tuple->ip, all);
if (rsc_active >= 0) {
return (gboolean) rsc_active;
}
rsc_active = tuple_rsc_active(tuple->child, all);
if (rsc_active >= 0) {
return (gboolean) rsc_active;
}
rsc_active = tuple_rsc_active(tuple->docker, all);
if (rsc_active >= 0) {
return (gboolean) rsc_active;
}
rsc_active = tuple_rsc_active(tuple->remote, all);
if (rsc_active >= 0) {
return (gboolean) rsc_active;
}
}
/* If "all" is TRUE, we've already checked that no resources were inactive,
* so return TRUE; if "all" is FALSE, we didn't find any active resources,
* so return FALSE.
*/
return all;
}
resource_t *
@@ -713,6 +767,21 @@ find_container_child(const char *stem, resource_t * rsc, node_t *node)
return rsc;
}
static void
print_rsc_in_list(resource_t *rsc, const char *pre_text, long options,
void *print_data)
{
if (rsc != NULL) {
if (options & pe_print_html) {
status_print("<li>");
}
rsc->fns->print(rsc, pre_text, options, print_data);
if (options & pe_print_html) {
status_print("</li>\n");
}
}
}
static void
container_print_xml(resource_t * rsc, const char *pre_text, long options, void *print_data)
{
@@ -723,39 +792,31 @@ container_print_xml(resource_t * rsc, const char *pre_text, long options, void *
if (pre_text == NULL) {
pre_text = "";
}
child_text = crm_concat(pre_text, " ", ' ');
child_text = crm_concat(pre_text, " ", ' ');
status_print("%s<container ", pre_text);
get_container_variant_data(container_data, rsc);
status_print("%s<bundle ", pre_text);
status_print("id=\"%s\" ", rsc->id);
status_print("type=\"docker\" ");
status_print("image=\"%s\" ", container_data->image);
status_print("unique=\"%s\" ", is_set(rsc->flags, pe_rsc_unique)? "true" : "false");
status_print("managed=\"%s\" ", is_set(rsc->flags, pe_rsc_managed) ? "true" : "false");
status_print("failed=\"%s\" ", is_set(rsc->flags, pe_rsc_failed) ? "true" : "false");
status_print(">\n");
get_container_variant_data(container_data, rsc);
status_print("%sDocker container: %s [%s]%s%s",
pre_text, rsc->id, container_data->image,
is_set(rsc->flags, pe_rsc_unique) ? " (unique)" : "",
is_set(rsc->flags, pe_rsc_managed) ? "" : " (unmanaged)");
for (GListPtr gIter = container_data->tuples; gIter != NULL; gIter = gIter->next) {
container_grouping_t *tuple = (container_grouping_t *)gIter->data;
CRM_ASSERT(tuple);
if(tuple->ip) {
tuple->ip->fns->print(tuple->ip, child_text, options, print_data);
}
if(tuple->child) {
tuple->child->fns->print(tuple->child, child_text, options, print_data);
}
if(tuple->docker) {
tuple->docker->fns->print(tuple->docker, child_text, options, print_data);
}
if(tuple->remote) {
tuple->remote->fns->print(tuple->remote, child_text, options, print_data);
}
}
status_print("%s</container>\n", pre_text);
status_print("%s <replica id=\"%d\">\n", pre_text, tuple->offset);
print_rsc_in_list(tuple->ip, child_text, options, print_data);
print_rsc_in_list(tuple->child, child_text, options, print_data);
print_rsc_in_list(tuple->docker, child_text, options, print_data);
print_rsc_in_list(tuple->remote, child_text, options, print_data);
status_print("%s </replica>\n", pre_text);
}
status_print("%s</bundle>\n", pre_text);
free(child_text);
}
@@ -807,37 +868,50 @@ container_print(resource_t * rsc, const char *pre_text, long options, void *prin
pre_text = " ";
}
child_text = crm_strdup_printf(" %s", pre_text);
status_print("%sDocker container%s: %s [%s]%s%s\n",
pre_text, container_data->replicas>1?" set":"", rsc->id, container_data->image,
is_set(rsc->flags, pe_rsc_unique) ? " (unique)" : "",
is_set(rsc->flags, pe_rsc_managed) ? "" : " (unmanaged)");
if (options & pe_print_html) {
status_print("<br />\n<ul>\n");
}
for (GListPtr gIter = container_data->tuples; gIter != NULL; gIter = gIter->next) {
container_grouping_t *tuple = (container_grouping_t *)gIter->data;
CRM_ASSERT(tuple);
if (options & pe_print_html) {
status_print("<li>");
}
if(is_set(options, pe_print_clone_details)) {
child_text = crm_strdup_printf(" %s", pre_text);
if(g_list_length(container_data->tuples) > 1) {
status_print(" %sReplica[%d]\n", pre_text, tuple->offset);
}
if(tuple->ip) {
tuple->ip->fns->print(tuple->ip, child_text, options, print_data);
}
if(tuple->docker) {
tuple->docker->fns->print(tuple->docker, child_text, options, print_data);
}
if(tuple->remote) {
tuple->remote->fns->print(tuple->remote, child_text, options, print_data);
if (options & pe_print_html) {
status_print("<br />\n<ul>\n");
}
if(tuple->child) {
tuple->child->fns->print(tuple->child, child_text, options, print_data);
print_rsc_in_list(tuple->ip, child_text, options, print_data);
print_rsc_in_list(tuple->docker, child_text, options, print_data);
print_rsc_in_list(tuple->remote, child_text, options, print_data);
print_rsc_in_list(tuple->child, child_text, options, print_data);
if (options & pe_print_html) {
status_print("</ul>\n");
}
} else {
char *child_text = crm_strdup_printf("%s ", pre_text);
child_text = crm_strdup_printf("%s ", pre_text);
tuple_print(tuple, child_text, options, print_data);
}
free(child_text);
if (options & pe_print_html) {
status_print("</li>\n");
}
}
if (options & pe_print_html) {
status_print("</ul>\n");
}
}
View
@@ -637,7 +637,6 @@ gboolean
unpack_remote_nodes(xmlNode * xml_resources, pe_working_set_t * data_set)
{
xmlNode *xml_obj = NULL;
GHashTable *rsc_name_check = NULL;
/* generate remote nodes from resource config before unpacking resources */
for (xml_obj = __xml_first_child(xml_resources); xml_obj != NULL; xml_obj = __xml_next_element(xml_obj)) {
@@ -691,10 +690,6 @@ unpack_remote_nodes(xmlNode * xml_resources, pe_working_set_t * data_set)
}
}
}
if (rsc_name_check) {
g_hash_table_destroy(rsc_name_check);
}
return TRUE;
}
Oops, something went wrong.

0 comments on commit e4d588c

Please sign in to comment.