Skip to content

Commit

Permalink
Merge pull request #1211 from kgaillot/fixes
Browse files Browse the repository at this point in the history
Fix crm_diff --no-version
  • Loading branch information
kgaillot committed Jan 13, 2017
2 parents 2817a20 + 88472dc commit 6945262
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 145 deletions.
41 changes: 26 additions & 15 deletions crmd/lrm.c
Expand Up @@ -37,6 +37,8 @@
#define START_DELAY_THRESHOLD 5 * 60 * 1000
#define MAX_LRM_REG_FAILS 30

#define s_if_plural(i) (((i) == 1)? "" : "s")

struct delete_event_s {
int rc;
const char *rsc;
Expand Down Expand Up @@ -372,8 +374,10 @@ do_lrm_control(long long action,

if (ret != pcmk_ok) {
if (lrm_state->num_lrm_register_fails < MAX_LRM_REG_FAILS) {
crm_warn("Failed to sign on to the LRM %d"
" (%d max) times", lrm_state->num_lrm_register_fails, MAX_LRM_REG_FAILS);
crm_warn("Failed to connect to the LRM %d time%s (%d max)",
lrm_state->num_lrm_register_fails,
s_if_plural(lrm_state->num_lrm_register_fails),
MAX_LRM_REG_FAILS);

crm_timer_start(wait_timer);
crmd_fsa_stall(FALSE);
Expand All @@ -382,8 +386,9 @@ do_lrm_control(long long action,
}

if (ret != pcmk_ok) {
crm_err("Failed to sign on to the LRM %d" " (max) times",
lrm_state->num_lrm_register_fails);
crm_err("Failed to connect to the LRM the max allowed %d time%s",
lrm_state->num_lrm_register_fails,
s_if_plural(lrm_state->num_lrm_register_fails));
register_fsa_error(C_FSA_INTERNAL, I_ERROR, NULL);
return;
}
Expand Down Expand Up @@ -425,8 +430,8 @@ lrm_state_verify_stopped(lrm_state_t * lrm_state, enum crmd_fsa_state cur_state,
guint nremaining = g_hash_table_size(lrm_state->pending_ops);

if (removed || nremaining) {
crm_notice("Stopped %u recurring operations at %s (%u operations remaining)",
removed, when, nremaining);
crm_notice("Stopped %u recurring operation%s at %s (%u remaining)",
removed, s_if_plural(removed), when, nremaining);
}
}

Expand All @@ -441,7 +446,8 @@ lrm_state_verify_stopped(lrm_state_t * lrm_state, enum crmd_fsa_state cur_state,
}

if (counter > 0) {
do_crm_log(log_level, "%d pending LRM operations at %s", counter, when);
do_crm_log(log_level, "%d pending LRM operation%s at %s",
counter, s_if_plural(counter), when);

if (cur_state == S_TERMINATE || !is_set(fsa_input_register, R_SENT_RSC_STOP)) {
g_hash_table_iter_init(&gIter, lrm_state->pending_ops);
Expand All @@ -459,7 +465,7 @@ lrm_state_verify_stopped(lrm_state_t * lrm_state, enum crmd_fsa_state cur_state,
return rc;
}

if (cur_state == S_TERMINATE || is_set(fsa_input_register, R_SHUTDOWN)) {
if (is_set(fsa_input_register, R_SHUTDOWN)) {
/* At this point we're not waiting, we're just shutting down */
when = "shutdown";
}
Expand All @@ -472,7 +478,11 @@ lrm_state_verify_stopped(lrm_state_t * lrm_state, enum crmd_fsa_state cur_state,
}

counter++;
crm_trace("Found %s active", entry->id);
if (log_level == LOG_ERR) {
crm_info("Found %s active at %s", entry->id, when);
} else {
crm_trace("Found %s active at %s", entry->id, when);
}
if (lrm_state->pending_ops) {
GHashTableIter hIter;

Expand All @@ -488,7 +498,8 @@ lrm_state_verify_stopped(lrm_state_t * lrm_state, enum crmd_fsa_state cur_state,
}

if (counter) {
crm_err("%d resources were active at %s.", counter, when);
crm_err("%d resource%s active at %s",
counter, (counter == 1)? " was" : "s were", when);
}

return rc;
Expand Down Expand Up @@ -1489,8 +1500,8 @@ do_lrm_invoke(long long action,
lrm_state = lrm_state_find(target_node);

if (lrm_state == NULL && is_remote_node) {
crm_err("no lrmd connection for remote node %s found on cluster node %s. Can not process request.",
target_node, fsa_our_uname);
crm_err("Failing action because remote node %s has no connection to cluster node %s",
target_node, fsa_our_uname);

/* The action must be recorded here and in the CIB as failed */
synthesize_lrmd_failure(NULL, input->xml, PCMK_OCF_CONNECTION_DIED);
Expand Down Expand Up @@ -1785,7 +1796,7 @@ do_lrm_invoke(long long action,
lrmd_free_rsc_info(rsc);

} else {
crm_err("Operation was neither a lrm_query, nor a rsc op. %s", crm_str(crm_op));
crm_err("Cannot perform operation %s of unknown type", crm_str(crm_op));
register_fsa_error(C_FSA_INTERNAL, I_ERROR, NULL);
}
}
Expand Down Expand Up @@ -2108,8 +2119,8 @@ do_lrm_rsc_op(lrm_state_t * lrm_state, lrmd_rsc_info_t * rsc, const char *operat
lrm_state->pending_ops, stop_recurring_action_by_rsc, &data);

if (removed) {
crm_debug("Stopped %u recurring operations in preparation for %s_%s_%d",
removed, rsc->id, operation, op->interval);
crm_debug("Stopped %u recurring operation%s in preparation for %s_%s_%d",
removed, s_if_plural(removed), rsc->id, operation, op->interval);
}
}

Expand Down
15 changes: 4 additions & 11 deletions crmd/te_actions.c
Expand Up @@ -292,8 +292,6 @@ cib_action_update(crm_action_t * action, int status, int op_rc)

int rc = pcmk_ok;

const char *name = NULL;
const char *value = NULL;
const char *rsc_id = NULL;
const char *task = crm_element_value(action->xml, XML_LRM_ATTR_TASK);
const char *target = crm_element_value(action->xml, XML_LRM_ATTR_TARGET);
Expand Down Expand Up @@ -341,15 +339,10 @@ cib_action_update(crm_action_t * action, int status, int op_rc)
rsc = create_xml_node(rsc, XML_LRM_TAG_RESOURCE);
crm_xml_add(rsc, XML_ATTR_ID, rsc_id);

name = XML_ATTR_TYPE;
value = crm_element_value(action_rsc, name);
crm_xml_add(rsc, name, value);
name = XML_AGENT_ATTR_CLASS;
value = crm_element_value(action_rsc, name);
crm_xml_add(rsc, name, value);
name = XML_AGENT_ATTR_PROVIDER;
value = crm_element_value(action_rsc, name);
crm_xml_add(rsc, name, value);

crm_copy_xml_element(action_rsc, rsc, XML_ATTR_TYPE);
crm_copy_xml_element(action_rsc, rsc, XML_AGENT_ATTR_CLASS);
crm_copy_xml_element(action_rsc, rsc, XML_AGENT_ATTR_PROVIDER);

op = convert_graph_action(NULL, action, status, op_rc);
op->call_id = -1;
Expand Down
3 changes: 3 additions & 0 deletions doc/Pacemaker_Remote/en-US/Ch-Intro.txt
Expand Up @@ -107,6 +107,9 @@ version):
* Support for transient node attributes
* Support for clusters with mixed endian architectures

.1.1.10
* remote-connect-timeout for guest nodes

.1.1.9
* Initial version to include pacemaker_remote
* Limited to guest nodes in KVM/LXC environments using only IPv4;
Expand Down
18 changes: 18 additions & 0 deletions include/crm/common/xml.h
Expand Up @@ -210,6 +210,24 @@ crm_element_name(xmlNode *xml)

const char *crm_element_value(xmlNode * data, const char *name);

/*!
* \brief Copy an element from one XML object to another
*
* \param[in] obj1 Source XML
* \param[in,out] obj2 Destination XML
* \param[in] element Name of element to copy
*
* \return Pointer to copied value (from source)
*/
static inline const char *
crm_copy_xml_element(xmlNode *obj1, xmlNode *obj2, const char *element)
{
const char *value = crm_element_value(obj1, element);

crm_xml_add(obj2, element, value);
return value;
}

void xml_validate(const xmlNode * root);

gboolean xml_has_children(const xmlNode * root);
Expand Down
2 changes: 1 addition & 1 deletion tools/Makefile.am
Expand Up @@ -87,7 +87,7 @@ crm_simulate_LDADD = $(top_builddir)/lib/pengine/libpe_status.la \
$(top_builddir)/lib/transition/libtransitioner.la \
$(COMMONLIBS)

crm_diff_SOURCES = xml_diff.c
crm_diff_SOURCES = crm_diff.c
crm_diff_LDADD = $(COMMONLIBS)

crm_mon_SOURCES = crm_mon.c
Expand Down

0 comments on commit 6945262

Please sign in to comment.