示例#1
0
gboolean
process_graph_event(xmlNode * event, const char *event_node)
{
    int rc = -1;
    int status = -1;

    int action = -1;
    int target_rc = -1;
    int transition_num = -1;
    char *update_te_uuid = NULL;

    gboolean stop_early = FALSE;
    gboolean passed = FALSE;
    const char *id = NULL;
    const char *magic = NULL;

    CRM_ASSERT(event != NULL);

    id = crm_element_value(event, XML_LRM_ATTR_TASK_KEY);
    magic = crm_element_value(event, XML_ATTR_TRANSITION_MAGIC);

    if (magic == NULL) {
        /* non-change */
        return FALSE;
    }

    CRM_CHECK(decode_transition_magic(magic, &update_te_uuid, &transition_num, &action,
                                      &status, &rc, &target_rc),
              crm_err("Invalid event %s detected", id);
              abort_transition(INFINITY, tg_restart, "Bad event", event);
              return FALSE;
        );
示例#2
0
gboolean
process_graph_event(xmlNode * event, const char *event_node)
{
    int rc = -1;
    int status = -1;

    int action = -1;
    int target_rc = -1;
    int transition_num = -1;
    char *update_te_uuid = NULL;

    gboolean stop_early = FALSE;
    gboolean passed = FALSE;
    const char *id = NULL;
    const char *magic = NULL;

    CRM_ASSERT(event != NULL);

    id = crm_element_value(event, XML_LRM_ATTR_TASK_KEY);
    magic = crm_element_value(event, XML_ATTR_TRANSITION_MAGIC);

    if (magic == NULL) {
        /* non-change */
        return FALSE;
    }

    if(decode_transition_magic(magic, &update_te_uuid, &transition_num, &action,
                               &status, &rc, &target_rc) == FALSE) {
        crm_err("Invalid event %s detected: %s", id, magic);
        abort_transition(INFINITY, tg_restart, "Bad event", event);
        return FALSE;
    }

    if (status == LRM_OP_PENDING) {
        goto bail;
    }

    if (transition_num == -1) {
        crm_err("Action %s (%s) initiated outside of a transition", id, magic);
        abort_transition(INFINITY, tg_restart, "Unexpected event", event);

    } else if (action < 0 || crm_str_eq(update_te_uuid, te_uuid, TRUE) == FALSE) {
        crm_info("Action %s/%d (%s) initiated by a different transitioner", id, action, magic);
        abort_transition(INFINITY, tg_restart, "Foreign event", event);
        stop_early = TRUE;      /* This could be an lrm status refresh */

    } else if (transition_graph->id != transition_num) {
        crm_info("Detected action %s from a different transition:"
                 " %d vs. %d", id, transition_num, transition_graph->id);
        abort_transition(INFINITY, tg_restart, "Old event", event);
        stop_early = TRUE;      /* This could be an lrm status refresh */

    } else if (transition_graph->complete) {
        crm_info("Action %s arrived after a completed transition", id);
        abort_transition(INFINITY, tg_restart, "Inactive graph", event);

    } else if (match_graph_event(action, event, event_node, status, rc, target_rc) < 0) {
        crm_err("Unknown graph action %s", id);
        abort_transition(INFINITY, tg_restart, "Unknown event", event);

    } else {
        passed = TRUE;
        crm_debug_2("Processed update to %s: %s", id, magic);
    }

    if (passed == FALSE) {
        if (update_failcount(event, event_node, rc, target_rc, transition_num == -1)) {
            /* Turns out this wasn't an lrm status refresh update aferall */
            stop_early = FALSE;
        }
    }

  bail:
    crm_free(update_te_uuid);
    return stop_early;
}