Skip to content

Commit

Permalink
Low: crmd: Reduced logging format for incomplete transtions
Browse files Browse the repository at this point in the history
  • Loading branch information
beekhof committed Aug 29, 2012
1 parent 628bf6f commit 034dec8
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 81 deletions.
11 changes: 0 additions & 11 deletions TODO.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@
- Reduce the amount of stonith-ng logging
- Use dlopen for snmp in crm_mon
- Re-implement no-quorum filter for cib updates?
- More concise logging of print_graph() when a transition is cancelled or fails

warning: print_graph: Synapse 26 is pending (priority: 0)
warning: print_elem: [Action 11]: Pending (id: all_stopped, type: pseduo, priority: 0)
warning: print_elem: * [Input 36]: Pending (id: rsc_pcmk-1_stop_0, loc: pcmk-1, priority: 0)
warning: print_elem: * [Input 39]: Pending (id: rsc_pcmk-2_stop_0, loc: pcmk-3, priority: 0)
warning: print_elem: * [Input 42]: Pending (id: rsc_pcmk-3_stop_0, loc: pcmk-3, priority: 0)
warning: print_elem: * [Input 47]: Pending (id: migrator_stop_0, loc: pcmk-1, priority: 0)
warning: print_elem: * [Input 50]: Pending (id: ping-1_stop_0, loc: pcmk-3, priority: 0)
warning: print_elem: * [Input 53]: Pending (id: ping-1_stop_0, loc: pcmk-1, priority: 0)


## Targeted for 1.4

Expand Down
1 change: 1 addition & 0 deletions include/crm_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ crm_strlen_zero(const char *s)
return !s || *s == '\0';
}

char *add_list_element(char *list, const char *value);
char *generate_series_filename(const char *directory, const char *series, int sequence, gboolean bzip);
int get_last_sequence(const char *directory, const char *series);
void write_last_sequence(const char *directory, const char *series, int sequence, int max);
Expand Down
19 changes: 19 additions & 0 deletions lib/common/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -2145,6 +2145,25 @@ find_library_function(void **handle, const char *lib, const char *fn, gboolean f
return a_function;
}

char *
add_list_element(char *list, const char *value)
{
int len = 0;
int last = 0;

if (value == NULL) {
return list;
}
if (list) {
last = strlen(list);
}
len = last + 2; /* +1 space, +1 EOS */
len += strlen(value);
list = realloc(list, len);
sprintf(list + last, " %s", value);
return list;
}

void *
convert_const_pointer(const void *ptr)
{
Expand Down
19 changes: 0 additions & 19 deletions lib/pengine/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,25 +316,6 @@ clone_active(resource_t * rsc, gboolean all)
}
}

static char *
add_list_element(char *list, const char *value)
{
int len = 0;
int last = 0;

if (value == NULL) {
return list;
}
if (list) {
last = strlen(list);
}
len = last + 2; /* +1 space, +1 EOS */
len += strlen(value);
list = realloc(list, len);
sprintf(list + last, " %s", value);
return list;
}

static void
short_print(char *list, const char *prefix, const char *type, long options, void *print_data)
{
Expand Down
65 changes: 52 additions & 13 deletions lib/transition/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ actiontype2text(action_type_e type)
}

static void
print_elem(int log_level, const char *prefix, gboolean as_input, crm_action_t * action)
print_elem(int log_level, const char *prefix, gboolean as_input, gboolean unresolved, crm_action_t * action)
{
int priority = 0;
const char *key = NULL;
Expand All @@ -136,6 +136,10 @@ print_elem(int log_level, const char *prefix, gboolean as_input, crm_action_t *

} else if (action->sent_update) {
state = "Update sent";

} else if (unresolved) {
/* Present as an input only */
state = "Unresolved dependancy";
}

if (as_input) {
Expand Down Expand Up @@ -190,7 +194,27 @@ print_elem(int log_level, const char *prefix, gboolean as_input, crm_action_t *
void
print_action(int log_level, const char *prefix, crm_action_t * action)
{
print_elem(log_level, prefix, FALSE, action);
print_elem(log_level, prefix, FALSE, FALSE, action);
}

static crm_action_t *
find_action(crm_graph_t * graph, int id)
{
GListPtr sIter = NULL;

for (sIter = graph->synapses; sIter != NULL; sIter = sIter->next) {
GListPtr aIter = NULL;
synapse_t *synapse = (synapse_t *) sIter->data;

for (aIter = synapse->actions; aIter != NULL; aIter = aIter->next) {
crm_action_t *action = (crm_action_t *) aIter->data;

if(action->id == id) {
return action;
}
}
}
return NULL;
}

void
Expand All @@ -200,40 +224,55 @@ print_graph(unsigned int log_level, crm_graph_t * graph)

if (graph == NULL || graph->num_actions == 0) {
if (log_level > LOG_DEBUG) {
crm_debug("## Empty transition graph ##");
crm_debug("Empty transition graph");
}
return;
}

do_crm_log(log_level, "Graph %d (%d actions in %d synapses):"
do_crm_log(log_level, "Graph %d with %d actions:"
" batch-limit=%d jobs, network-delay=%dms",
graph->id, graph->num_actions, graph->num_synapses,
graph->batch_limit, graph->network_delay);

for (lpc = graph->synapses; lpc != NULL; lpc = lpc->next) {
synapse_t *synapse = (synapse_t *) lpc->data;

do_crm_log(log_level, "Synapse %d %s (priority: %d)",
synapse->id,
synapse->confirmed ? "was confirmed" :
synapse->executed ? "was executed" : "is pending", synapse->priority);

if (synapse->confirmed == FALSE) {
GListPtr lpc2 = NULL;

for (lpc2 = synapse->actions; lpc2 != NULL; lpc2 = lpc2->next) {
crm_action_t *action = (crm_action_t *) lpc2->data;

print_elem(log_level, " ", FALSE, action);
print_elem(log_level, " ", FALSE, FALSE, action);
}
}
if (synapse->executed == FALSE) {
GListPtr lpc2 = NULL;
char *pending = NULL;

for (lpc2 = synapse->inputs; lpc2 != NULL; lpc2 = lpc2->next) {
int id = 0;
crm_action_t *input = (crm_action_t *) lpc2->data;

print_elem(log_level, " * ", TRUE, input);
const char *id_string = crm_element_value(input->xml, XML_ATTR_ID);

crm_element_value_int(input->xml, XML_ATTR_ID, &id);
if (input->failed || input->executed) {
/* Unusual - expand */
print_elem(log_level, " * ", TRUE, FALSE, input);

} else if (input->confirmed || input->sent_update) {
/* Done - ignore */

} else if(find_action(graph, id)) {
/* Pending - compress */
pending = add_list_element(pending, id_string);
} else {
/* Unknown - expand */
print_elem(log_level, " * ", TRUE, TRUE, input);
}
}
if(pending) {
do_crm_log(log_level, " * Pending inputs: %s", pending);
free(pending);
}
}
}
Expand Down
19 changes: 0 additions & 19 deletions tools/crm_inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,25 +492,6 @@ exec_stonith_action(crm_graph_t * graph, crm_action_t * action)
return TRUE;
}

static char *
add_list_element(char *list, const char *value)
{
int len = 0;
int last = 0;

if (value == NULL) {
return list;
}
if (list) {
last = strlen(list);
}
len = last + 2; /* +1 space, +1 EOS */
len += strlen(value);
list = realloc(list, len);
sprintf(list + last, " %s", value);
return list;
}

static void
print_cluster_status(pe_working_set_t * data_set)
{
Expand Down
19 changes: 0 additions & 19 deletions tools/crm_mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1009,25 +1009,6 @@ print_cluster_tickets(pe_working_set_t * data_set)
return;
}

static char *
add_list_element(char *list, const char *value)
{
int len = 0;
int last = 0;

if (value == NULL) {
return list;
}
if (list) {
last = strlen(list);
}
len = last + 2; /* +1 space, +1 EOS */
len += strlen(value);
list = realloc(list, len);
sprintf(list + last, " %s", value);
return list;
}

static int
print_status(pe_working_set_t * data_set)
{
Expand Down

0 comments on commit 034dec8

Please sign in to comment.