root/daemons/controld/controld_te_callbacks.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. shutdown_lock_cleared
  2. te_update_diff_v1
  3. process_lrm_resource_diff
  4. process_resource_updates
  5. extract_node_uuid
  6. abort_unless_down
  7. process_op_deletion
  8. process_delete_diff
  9. process_node_state_diff
  10. process_status_diff
  11. process_cib_diff
  12. te_update_diff_v2
  13. te_update_diff
  14. process_te_message
  15. cib_action_updated
  16. action_timer_callback

   1 /*
   2  * Copyright 2004-2021 the Pacemaker project contributors
   3  *
   4  * The version control history for this file may have further details.
   5  *
   6  * This source code is licensed under the GNU General Public License version 2
   7  * or later (GPLv2+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #include <crm_internal.h>
  11 
  12 #include <sys/stat.h>
  13 
  14 #include <crm/crm.h>
  15 #include <crm/common/xml.h>
  16 #include <crm/common/xml_internal.h>
  17 #include <crm/msg_xml.h>
  18 #include <crm/cluster.h>        /* For ONLINESTATUS etc */
  19 
  20 #include <pacemaker-controld.h>
  21 
  22 void te_update_confirm(const char *event, xmlNode * msg);
  23 
  24 extern char *te_uuid;
  25 gboolean shuttingdown = FALSE;
  26 crm_graph_t *transition_graph;
  27 crm_trigger_t *transition_trigger = NULL;
  28 
  29 /* #define RSC_OP_TEMPLATE "//"XML_TAG_DIFF_ADDED"//"XML_TAG_CIB"//"XML_CIB_TAG_STATE"[@uname='%s']"//"XML_LRM_TAG_RSC_OP"[@id='%s]" */
  30 #define RSC_OP_TEMPLATE "//"XML_TAG_DIFF_ADDED"//"XML_TAG_CIB"//"XML_LRM_TAG_RSC_OP"[@id='%s']"
  31 
  32 // An explicit shutdown-lock of 0 means the lock has been cleared
  33 static bool
  34 shutdown_lock_cleared(xmlNode *lrm_resource)
     /* [previous][next][first][last][top][bottom][index][help] */
  35 {
  36     time_t shutdown_lock = 0;
  37 
  38     return (crm_element_value_epoch(lrm_resource, XML_CONFIG_ATTR_SHUTDOWN_LOCK,
  39                                     &shutdown_lock) == pcmk_ok)
  40            && (shutdown_lock == 0);
  41 }
  42 
  43 static void
  44 te_update_diff_v1(const char *event, xmlNode *diff)
     /* [previous][next][first][last][top][bottom][index][help] */
  45 {
  46     int lpc, max;
  47     xmlXPathObject *xpathObj = NULL;
  48 
  49     CRM_CHECK(diff != NULL, return);
  50 
  51     xml_log_patchset(LOG_TRACE, __func__, diff);
  52     if (cib_config_changed(NULL, NULL, &diff)) {
  53         abort_transition(INFINITY, tg_restart, "Non-status change", diff);
  54         goto bail;              /* configuration changed */
  55     }
  56 
  57     /* Tickets Attributes - Added/Updated */
  58     xpathObj =
  59         xpath_search(diff,
  60                      "//" F_CIB_UPDATE_RESULT "//" XML_TAG_DIFF_ADDED "//" XML_CIB_TAG_TICKETS);
  61     if (numXpathResults(xpathObj) > 0) {
  62         xmlNode *aborted = getXpathResult(xpathObj, 0);
  63 
  64         abort_transition(INFINITY, tg_restart, "Ticket attribute: update", aborted);
  65         goto bail;
  66 
  67     }
  68     freeXpathObject(xpathObj);
  69 
  70     /* Tickets Attributes - Removed */
  71     xpathObj =
  72         xpath_search(diff,
  73                      "//" F_CIB_UPDATE_RESULT "//" XML_TAG_DIFF_REMOVED "//" XML_CIB_TAG_TICKETS);
  74     if (numXpathResults(xpathObj) > 0) {
  75         xmlNode *aborted = getXpathResult(xpathObj, 0);
  76 
  77         abort_transition(INFINITY, tg_restart, "Ticket attribute: removal", aborted);
  78         goto bail;
  79     }
  80     freeXpathObject(xpathObj);
  81 
  82     /* Transient Attributes - Added/Updated */
  83     xpathObj =
  84         xpath_search(diff,
  85                      "//" F_CIB_UPDATE_RESULT "//" XML_TAG_DIFF_ADDED "//"
  86                      XML_TAG_TRANSIENT_NODEATTRS "//" XML_CIB_TAG_NVPAIR);
  87     max = numXpathResults(xpathObj);
  88 
  89     for (lpc = 0; lpc < max; lpc++) {
  90         xmlNode *attr = getXpathResult(xpathObj, lpc);
  91         const char *name = crm_element_value(attr, XML_NVPAIR_ATTR_NAME);
  92         const char *value = NULL;
  93 
  94         if (pcmk__str_eq(CRM_OP_PROBED, name, pcmk__str_casei)) {
  95             value = crm_element_value(attr, XML_NVPAIR_ATTR_VALUE);
  96         }
  97 
  98         if (crm_is_true(value) == FALSE) {
  99             abort_transition(INFINITY, tg_restart, "Transient attribute: update", attr);
 100             crm_log_xml_trace(attr, "Abort");
 101             goto bail;
 102         }
 103     }
 104 
 105     freeXpathObject(xpathObj);
 106 
 107     /* Transient Attributes - Removed */
 108     xpathObj =
 109         xpath_search(diff,
 110                      "//" F_CIB_UPDATE_RESULT "//" XML_TAG_DIFF_REMOVED "//"
 111                      XML_TAG_TRANSIENT_NODEATTRS);
 112     if (numXpathResults(xpathObj) > 0) {
 113         xmlNode *aborted = getXpathResult(xpathObj, 0);
 114 
 115         abort_transition(INFINITY, tg_restart, "Transient attribute: removal", aborted);
 116         goto bail;
 117 
 118     }
 119     freeXpathObject(xpathObj);
 120 
 121     // Check for lrm_resource entries
 122     xpathObj = xpath_search(diff,
 123                             "//" F_CIB_UPDATE_RESULT
 124                             "//" XML_TAG_DIFF_ADDED
 125                             "//" XML_LRM_TAG_RESOURCE);
 126     max = numXpathResults(xpathObj);
 127 
 128     /*
 129      * Updates by, or in response to, graph actions will never affect more than
 130      * one resource at a time, so such updates indicate an LRM refresh. In that
 131      * case, start a new transition rather than check each result individually,
 132      * which can result in _huge_ speedups in large clusters.
 133      *
 134      * Unfortunately, we can only do so when there are no pending actions.
 135      * Otherwise, we could mistakenly throw away those results here, and
 136      * the cluster will stall waiting for them and time out the operation.
 137      */
 138     if ((transition_graph->pending == 0) && (max > 1)) {
 139         crm_debug("Ignoring resource operation updates due to history refresh of %d resources",
 140                   max);
 141         crm_log_xml_trace(diff, "lrm-refresh");
 142         abort_transition(INFINITY, tg_restart, "History refresh", NULL);
 143         goto bail;
 144     }
 145 
 146     if (max == 1) {
 147         xmlNode *lrm_resource = getXpathResult(xpathObj, 0);
 148 
 149         if (shutdown_lock_cleared(lrm_resource)) {
 150             // @TODO would be more efficient to abort once after transition done
 151             abort_transition(INFINITY, tg_restart, "Shutdown lock cleared",
 152                              lrm_resource);
 153             // Still process results, so we stop timers and update failcounts
 154         }
 155     }
 156     freeXpathObject(xpathObj);
 157 
 158     /* Process operation updates */
 159     xpathObj =
 160         xpath_search(diff,
 161                      "//" F_CIB_UPDATE_RESULT "//" XML_TAG_DIFF_ADDED "//" XML_LRM_TAG_RSC_OP);
 162     max = numXpathResults(xpathObj);
 163     if (max > 0) {
 164         int lpc = 0;
 165 
 166         for (lpc = 0; lpc < max; lpc++) {
 167             xmlNode *rsc_op = getXpathResult(xpathObj, lpc);
 168             const char *node = get_node_id(rsc_op);
 169 
 170             process_graph_event(rsc_op, node);
 171         }
 172     }
 173     freeXpathObject(xpathObj);
 174 
 175     /* Detect deleted (as opposed to replaced or added) actions - eg. crm_resource -C */
 176     xpathObj = xpath_search(diff, "//" XML_TAG_DIFF_REMOVED "//" XML_LRM_TAG_RSC_OP);
 177     max = numXpathResults(xpathObj);
 178     for (lpc = 0; lpc < max; lpc++) {
 179         int path_max = 0;
 180         const char *op_id = NULL;
 181         char *rsc_op_xpath = NULL;
 182         xmlXPathObject *op_match = NULL;
 183         xmlNode *match = getXpathResult(xpathObj, lpc);
 184 
 185         CRM_LOG_ASSERT(match != NULL);
 186         if(match == NULL) { continue; };
 187 
 188         op_id = ID(match);
 189 
 190         path_max = strlen(RSC_OP_TEMPLATE) + strlen(op_id) + 1;
 191         rsc_op_xpath = calloc(1, path_max);
 192         snprintf(rsc_op_xpath, path_max, RSC_OP_TEMPLATE, op_id);
 193 
 194         op_match = xpath_search(diff, rsc_op_xpath);
 195         if (numXpathResults(op_match) == 0) {
 196             /* Prevent false positives by matching cancelations too */
 197             const char *node = get_node_id(match);
 198             crm_action_t *cancelled = get_cancel_action(op_id, node);
 199 
 200             if (cancelled == NULL) {
 201                 crm_debug("No match for deleted action %s (%s on %s)", rsc_op_xpath, op_id,
 202                           node);
 203                 abort_transition(INFINITY, tg_restart, "Resource op removal", match);
 204                 freeXpathObject(op_match);
 205                 free(rsc_op_xpath);
 206                 goto bail;
 207 
 208             } else {
 209                 crm_debug("Deleted lrm_rsc_op %s on %s was for graph event %d",
 210                           op_id, node, cancelled->id);
 211             }
 212         }
 213 
 214         freeXpathObject(op_match);
 215         free(rsc_op_xpath);
 216     }
 217 
 218   bail:
 219     freeXpathObject(xpathObj);
 220 }
 221 
 222 static void
 223 process_lrm_resource_diff(xmlNode *lrm_resource, const char *node)
     /* [previous][next][first][last][top][bottom][index][help] */
 224 {
 225     for (xmlNode *rsc_op = pcmk__xml_first_child(lrm_resource); rsc_op != NULL;
 226          rsc_op = pcmk__xml_next(rsc_op)) {
 227         process_graph_event(rsc_op, node);
 228     }
 229     if (shutdown_lock_cleared(lrm_resource)) {
 230         // @TODO would be more efficient to abort once after transition done
 231         abort_transition(INFINITY, tg_restart, "Shutdown lock cleared",
 232                          lrm_resource);
 233     }
 234 }
 235 
 236 static void
 237 process_resource_updates(const char *node, xmlNode *xml, xmlNode *change,
     /* [previous][next][first][last][top][bottom][index][help] */
 238                          const char *op, const char *xpath)
 239 {
 240     xmlNode *rsc = NULL;
 241 
 242     if (xml == NULL) {
 243         return;
 244     }
 245 
 246     if (strcmp(TYPE(xml), XML_CIB_TAG_LRM) == 0) {
 247         xml = first_named_child(xml, XML_LRM_TAG_RESOURCES);
 248         CRM_CHECK(xml != NULL, return);
 249     }
 250 
 251     CRM_CHECK(strcmp(TYPE(xml), XML_LRM_TAG_RESOURCES) == 0, return);
 252 
 253     /*
 254      * Updates by, or in response to, TE actions will never contain updates
 255      * for more than one resource at a time, so such updates indicate an
 256      * LRM refresh.
 257      *
 258      * In that case, start a new transition rather than check each result
 259      * individually, which can result in _huge_ speedups in large clusters.
 260      *
 261      * Unfortunately, we can only do so when there are no pending actions.
 262      * Otherwise, we could mistakenly throw away those results here, and
 263      * the cluster will stall waiting for them and time out the operation.
 264      */
 265     if ((transition_graph->pending == 0)
 266         && xml->children && xml->children->next) {
 267 
 268         crm_log_xml_trace(change, "lrm-refresh");
 269         abort_transition(INFINITY, tg_restart, "History refresh", NULL);
 270         return;
 271     }
 272 
 273     for (rsc = pcmk__xml_first_child(xml); rsc != NULL;
 274          rsc = pcmk__xml_next(rsc)) {
 275         crm_trace("Processing %s", ID(rsc));
 276         process_lrm_resource_diff(rsc, node);
 277     }
 278 }
 279 
 280 static char *extract_node_uuid(const char *xpath) 
     /* [previous][next][first][last][top][bottom][index][help] */
 281 {
 282     char *mutable_path = strdup(xpath);
 283     char *node_uuid = NULL;
 284     char *search = NULL;
 285     char *match = NULL;
 286 
 287     match = strstr(mutable_path, "node_state[@id=\'");
 288     if (match == NULL) {
 289         free(mutable_path);
 290         return NULL;
 291     }
 292     match += strlen("node_state[@id=\'");
 293 
 294     search = strchr(match, '\'');
 295     if (search == NULL) {
 296         free(mutable_path);
 297         return NULL;
 298     }
 299     search[0] = 0;
 300 
 301     node_uuid = strdup(match);
 302     free(mutable_path);
 303     return node_uuid;
 304 }
 305 
 306 static void
 307 abort_unless_down(const char *xpath, const char *op, xmlNode *change,
     /* [previous][next][first][last][top][bottom][index][help] */
 308                   const char *reason)
 309 {
 310     char *node_uuid = NULL;
 311     crm_action_t *down = NULL;
 312 
 313     if(!pcmk__str_eq(op, "delete", pcmk__str_casei)) {
 314         abort_transition(INFINITY, tg_restart, reason, change);
 315         return;
 316     }
 317 
 318     node_uuid = extract_node_uuid(xpath);
 319     if(node_uuid == NULL) {
 320         crm_err("Could not extract node ID from %s", xpath);
 321         abort_transition(INFINITY, tg_restart, reason, change);
 322         return;
 323     }
 324 
 325     down = match_down_event(node_uuid);
 326     if (down == NULL) {
 327         crm_trace("Not expecting %s to be down (%s)", node_uuid, xpath);
 328         abort_transition(INFINITY, tg_restart, reason, change);
 329     } else {
 330         crm_trace("Expecting changes to %s (%s)", node_uuid, xpath);
 331     }
 332     free(node_uuid);
 333 }
 334 
 335 static void
 336 process_op_deletion(const char *xpath, xmlNode *change)
     /* [previous][next][first][last][top][bottom][index][help] */
 337 {
 338     char *mutable_key = strdup(xpath);
 339     char *key;
 340     char *node_uuid;
 341 
 342     // Extract the part of xpath between last pair of single quotes
 343     key = strrchr(mutable_key, '\'');
 344     if (key != NULL) {
 345         *key = '\0';
 346         key = strrchr(mutable_key, '\'');
 347     }
 348     if (key == NULL) {
 349         crm_warn("Ignoring malformed CIB update (resource deletion of %s)",
 350                  xpath);
 351         free(mutable_key);
 352         return;
 353     }
 354     ++key;
 355 
 356     node_uuid = extract_node_uuid(xpath);
 357     if (confirm_cancel_action(key, node_uuid) == FALSE) {
 358         abort_transition(INFINITY, tg_restart, "Resource operation removal",
 359                          change);
 360     }
 361     free(mutable_key);
 362     free(node_uuid);
 363 }
 364 
 365 static void
 366 process_delete_diff(const char *xpath, const char *op, xmlNode *change)
     /* [previous][next][first][last][top][bottom][index][help] */
 367 {
 368     if (strstr(xpath, "/" XML_LRM_TAG_RSC_OP "[")) {
 369         process_op_deletion(xpath, change);
 370 
 371     } else if (strstr(xpath, "/" XML_CIB_TAG_LRM "[")) {
 372         abort_unless_down(xpath, op, change, "Resource state removal");
 373 
 374     } else if (strstr(xpath, "/" XML_CIB_TAG_STATE "[")) {
 375         abort_unless_down(xpath, op, change, "Node state removal");
 376 
 377     } else {
 378         crm_trace("Ignoring delete of %s", xpath);
 379     }
 380 }
 381 
 382 static void
 383 process_node_state_diff(xmlNode *state, xmlNode *change, const char *op,
     /* [previous][next][first][last][top][bottom][index][help] */
 384                         const char *xpath)
 385 {
 386     xmlNode *lrm = first_named_child(state, XML_CIB_TAG_LRM);
 387 
 388     process_resource_updates(ID(state), lrm, change, op, xpath);
 389 }
 390 
 391 static void
 392 process_status_diff(xmlNode *status, xmlNode *change, const char *op,
     /* [previous][next][first][last][top][bottom][index][help] */
 393                     const char *xpath)
 394 {
 395     for (xmlNode *state = pcmk__xml_first_child(status); state != NULL;
 396          state = pcmk__xml_next(state)) {
 397         process_node_state_diff(state, change, op, xpath);
 398     }
 399 }
 400 
 401 static void
 402 process_cib_diff(xmlNode *cib, xmlNode *change, const char *op,
     /* [previous][next][first][last][top][bottom][index][help] */
 403                  const char *xpath)
 404 {
 405     xmlNode *status = first_named_child(cib, XML_CIB_TAG_STATUS);
 406     xmlNode *config = first_named_child(cib, XML_CIB_TAG_CONFIGURATION);
 407 
 408     if (status) {
 409         process_status_diff(status, change, op, xpath);
 410     }
 411     if (config) {
 412         abort_transition(INFINITY, tg_restart,
 413                          "Non-status-only change", change);
 414     }
 415 }
 416 
 417 static void
 418 te_update_diff_v2(xmlNode *diff)
     /* [previous][next][first][last][top][bottom][index][help] */
 419 {
 420     crm_log_xml_trace(diff, "Patch:Raw");
 421 
 422     for (xmlNode *change = pcmk__xml_first_child(diff); change != NULL;
 423          change = pcmk__xml_next(change)) {
 424 
 425         xmlNode *match = NULL;
 426         const char *name = NULL;
 427         const char *xpath = crm_element_value(change, XML_DIFF_PATH);
 428 
 429         // Possible ops: create, modify, delete, move
 430         const char *op = crm_element_value(change, XML_DIFF_OP);
 431 
 432         // Ignore uninteresting updates
 433         if (op == NULL) {
 434             continue;
 435 
 436         } else if (xpath == NULL) {
 437             crm_trace("Ignoring %s change for version field", op);
 438             continue;
 439 
 440         } else if (strcmp(op, "move") == 0) {
 441             crm_trace("Ignoring move change at %s", xpath);
 442             continue;
 443         }
 444 
 445         // Find the result of create/modify ops
 446         if (strcmp(op, "create") == 0) {
 447             match = change->children;
 448 
 449         } else if (strcmp(op, "modify") == 0) {
 450             match = first_named_child(change, XML_DIFF_RESULT);
 451             if(match) {
 452                 match = match->children;
 453             }
 454 
 455         } else if (strcmp(op, "delete") != 0) {
 456             crm_warn("Ignoring malformed CIB update (%s operation on %s is unrecognized)",
 457                      op, xpath);
 458             continue;
 459         }
 460 
 461         if (match) {
 462             if (match->type == XML_COMMENT_NODE) {
 463                 crm_trace("Ignoring %s operation for comment at %s", op, xpath);
 464                 continue;
 465             }
 466             name = (const char *)match->name;
 467         }
 468 
 469         crm_trace("Handling %s operation for %s%s%s",
 470                   op, (xpath? xpath : "CIB"),
 471                   (name? " matched by " : ""), (name? name : ""));
 472 
 473         if (strstr(xpath, "/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION)) {
 474             abort_transition(INFINITY, tg_restart, "Configuration change",
 475                              change);
 476             break; // Won't be packaged with operation results we may be waiting for
 477 
 478         } else if (strstr(xpath, "/" XML_CIB_TAG_TICKETS)
 479                    || pcmk__str_eq(name, XML_CIB_TAG_TICKETS, pcmk__str_casei)) {
 480             abort_transition(INFINITY, tg_restart, "Ticket attribute change", change);
 481             break; // Won't be packaged with operation results we may be waiting for
 482 
 483         } else if (strstr(xpath, "/" XML_TAG_TRANSIENT_NODEATTRS "[")
 484                    || pcmk__str_eq(name, XML_TAG_TRANSIENT_NODEATTRS, pcmk__str_casei)) {
 485             abort_unless_down(xpath, op, change, "Transient attribute change");
 486             break; // Won't be packaged with operation results we may be waiting for
 487 
 488         } else if (strcmp(op, "delete") == 0) {
 489             process_delete_diff(xpath, op, change);
 490 
 491         } else if (name == NULL) {
 492             crm_warn("Ignoring malformed CIB update (%s at %s has no result)",
 493                      op, xpath);
 494 
 495         } else if (strcmp(name, XML_TAG_CIB) == 0) {
 496             process_cib_diff(match, change, op, xpath);
 497 
 498         } else if (strcmp(name, XML_CIB_TAG_STATUS) == 0) {
 499             process_status_diff(match, change, op, xpath);
 500 
 501         } else if (strcmp(name, XML_CIB_TAG_STATE) == 0) {
 502             process_node_state_diff(match, change, op, xpath);
 503 
 504         } else if (strcmp(name, XML_CIB_TAG_LRM) == 0) {
 505             process_resource_updates(ID(match), match, change, op, xpath);
 506 
 507         } else if (strcmp(name, XML_LRM_TAG_RESOURCES) == 0) {
 508             char *local_node = pcmk__xpath_node_id(xpath, "lrm");
 509 
 510             process_resource_updates(local_node, match, change, op, xpath);
 511             free(local_node);
 512 
 513         } else if (strcmp(name, XML_LRM_TAG_RESOURCE) == 0) {
 514             char *local_node = pcmk__xpath_node_id(xpath, "lrm");
 515 
 516             process_lrm_resource_diff(match, local_node);
 517             free(local_node);
 518 
 519         } else if (strcmp(name, XML_LRM_TAG_RSC_OP) == 0) {
 520             char *local_node = pcmk__xpath_node_id(xpath, "lrm");
 521 
 522             process_graph_event(match, local_node);
 523             free(local_node);
 524 
 525         } else {
 526             crm_warn("Ignoring malformed CIB update (%s at %s has unrecognized result %s)",
 527                      op, xpath, name);
 528         }
 529     }
 530 }
 531 
 532 void
 533 te_update_diff(const char *event, xmlNode * msg)
     /* [previous][next][first][last][top][bottom][index][help] */
 534 {
 535     xmlNode *diff = NULL;
 536     const char *op = NULL;
 537     int rc = -EINVAL;
 538     int format = 1;
 539     int p_add[] = { 0, 0, 0 };
 540     int p_del[] = { 0, 0, 0 };
 541 
 542     CRM_CHECK(msg != NULL, return);
 543     crm_element_value_int(msg, F_CIB_RC, &rc);
 544 
 545     if (transition_graph == NULL) {
 546         crm_trace("No graph");
 547         return;
 548 
 549     } else if (rc < pcmk_ok) {
 550         crm_trace("Filter rc=%d (%s)", rc, pcmk_strerror(rc));
 551         return;
 552 
 553     } else if (transition_graph->complete
 554                && fsa_state != S_IDLE
 555                && fsa_state != S_TRANSITION_ENGINE
 556                && fsa_state != S_POLICY_ENGINE) {
 557         crm_trace("Filter state=%s, complete=%d", fsa_state2string(fsa_state),
 558                   transition_graph->complete);
 559         return;
 560     }
 561 
 562     op = crm_element_value(msg, F_CIB_OPERATION);
 563     diff = get_message_xml(msg, F_CIB_UPDATE_RESULT);
 564 
 565     xml_patch_versions(diff, p_add, p_del);
 566     crm_debug("Processing (%s) diff: %d.%d.%d -> %d.%d.%d (%s)", op,
 567               p_del[0], p_del[1], p_del[2], p_add[0], p_add[1], p_add[2],
 568               fsa_state2string(fsa_state));
 569 
 570     crm_element_value_int(diff, "format", &format);
 571     switch (format) {
 572         case 1:
 573             te_update_diff_v1(event, diff);
 574             break;
 575         case 2:
 576             te_update_diff_v2(diff);
 577             break;
 578         default:
 579             crm_warn("Ignoring malformed CIB update (unknown patch format %d)",
 580                      format);
 581     }
 582 }
 583 
 584 gboolean
 585 process_te_message(xmlNode * msg, xmlNode * xml_data)
     /* [previous][next][first][last][top][bottom][index][help] */
 586 {
 587     const char *from = crm_element_value(msg, F_ORIG);
 588     const char *sys_to = crm_element_value(msg, F_CRM_SYS_TO);
 589     const char *sys_from = crm_element_value(msg, F_CRM_SYS_FROM);
 590     const char *ref = crm_element_value(msg, F_CRM_REFERENCE);
 591     const char *op = crm_element_value(msg, F_CRM_TASK);
 592     const char *type = crm_element_value(msg, F_CRM_MSG_TYPE);
 593 
 594     crm_trace("Processing %s (%s) message", op, ref);
 595     crm_log_xml_trace(msg, "ipc");
 596 
 597     if (op == NULL) {
 598         /* error */
 599 
 600     } else if (sys_to == NULL || strcasecmp(sys_to, CRM_SYSTEM_TENGINE) != 0) {
 601         crm_trace("Bad sys-to %s", crm_str(sys_to));
 602         return FALSE;
 603 
 604     } else if (pcmk__str_eq(op, CRM_OP_INVOKE_LRM, pcmk__str_casei)
 605                && pcmk__str_eq(sys_from, CRM_SYSTEM_LRMD, pcmk__str_casei)
 606 /*                && pcmk__str_eq(type, XML_ATTR_RESPONSE, pcmk__str_casei) */
 607         ) {
 608         xmlXPathObject *xpathObj = NULL;
 609 
 610         crm_log_xml_trace(msg, "Processing (N)ACK");
 611         crm_debug("Processing (N)ACK %s from %s", crm_element_value(msg, F_CRM_REFERENCE), from);
 612 
 613         xpathObj = xpath_search(xml_data, "//" XML_LRM_TAG_RSC_OP);
 614         if (numXpathResults(xpathObj)) {
 615             int lpc = 0, max = numXpathResults(xpathObj);
 616 
 617             for (lpc = 0; lpc < max; lpc++) {
 618                 xmlNode *rsc_op = getXpathResult(xpathObj, lpc);
 619                 const char *node = get_node_id(rsc_op);
 620 
 621                 process_graph_event(rsc_op, node);
 622             }
 623             freeXpathObject(xpathObj);
 624 
 625         } else {
 626             crm_log_xml_err(msg, "Invalid (N)ACK");
 627             freeXpathObject(xpathObj);
 628             return FALSE;
 629         }
 630 
 631     } else {
 632         crm_err("Unknown command: %s::%s from %s", type, op, sys_from);
 633     }
 634 
 635     crm_trace("finished processing message");
 636 
 637     return TRUE;
 638 }
 639 
 640 void
 641 cib_action_updated(xmlNode * msg, int call_id, int rc, xmlNode * output, void *user_data)
     /* [previous][next][first][last][top][bottom][index][help] */
 642 {
 643     if (rc < pcmk_ok) {
 644         crm_err("Update %d FAILED: %s", call_id, pcmk_strerror(rc));
 645     }
 646 }
 647 
 648 /*!
 649  * \brief Handle a timeout in node-to-node communication
 650  *
 651  * \param[in] data  Pointer to action timer
 652  *
 653  * \return FALSE (indicating that source should be not be re-added)
 654  */
 655 gboolean
 656 action_timer_callback(gpointer data)
     /* [previous][next][first][last][top][bottom][index][help] */
 657 {
 658     crm_action_timer_t *timer = NULL;
 659     const char *task = NULL;
 660     const char *on_node = NULL;
 661     const char *via_node = NULL;
 662 
 663     CRM_CHECK(data != NULL, return FALSE);
 664 
 665     timer = (crm_action_timer_t *) data;
 666     stop_te_timer(timer);
 667 
 668     CRM_CHECK(timer->action != NULL, return FALSE);
 669 
 670     task = crm_element_value(timer->action->xml, XML_LRM_ATTR_TASK);
 671     on_node = crm_element_value(timer->action->xml, XML_LRM_ATTR_TARGET);
 672     via_node = crm_element_value(timer->action->xml, XML_LRM_ATTR_ROUTER_NODE);
 673 
 674     if (transition_graph->complete) {
 675         crm_notice("Node %s did not send %s result (via %s) within %dms "
 676                    "(ignoring because transition not in progress)",
 677                    (on_node? on_node : ""), (task? task : "unknown action"),
 678                    (via_node? via_node : "controller"), timer->timeout);
 679     } else {
 680         /* fail the action */
 681 
 682         crm_err("Node %s did not send %s result (via %s) within %dms "
 683                 "(action timeout plus cluster-delay)",
 684                 (on_node? on_node : ""), (task? task : "unknown action"),
 685                 (via_node? via_node : "controller"),
 686                 timer->timeout + transition_graph->network_delay);
 687         pcmk__log_graph_action(LOG_ERR, timer->action);
 688 
 689         crm__set_graph_action_flags(timer->action, pcmk__graph_action_failed);
 690 
 691         te_action_confirmed(timer->action, transition_graph);
 692         abort_transition(INFINITY, tg_restart, "Action lost", NULL);
 693 
 694         // Record timeout in the CIB if appropriate
 695         if ((timer->action->type == action_type_rsc)
 696             && controld_action_is_recordable(task)) {
 697             controld_record_action_timeout(timer->action);
 698         }
 699     }
 700 
 701     return FALSE;
 702 }

/* [previous][next][first][last][top][bottom][index][help] */