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     } else if (strcmp((const char*)xml->name, XML_CIB_TAG_LRM) == 0) {
 246         xml = first_named_child(xml, XML_LRM_TAG_RESOURCES);
 247         crm_trace("Got %p in %s", xml, XML_CIB_TAG_LRM);
 248     }
 249 
 250     CRM_ASSERT(strcmp((const char*)xml->name, XML_LRM_TAG_RESOURCES) == 0);
 251 
 252     /*
 253      * Updates by, or in response to, TE actions will never contain updates
 254      * for more than one resource at a time, so such updates indicate an
 255      * LRM refresh.
 256      *
 257      * In that case, start a new transition rather than check each result
 258      * individually, which can result in _huge_ speedups in large clusters.
 259      *
 260      * Unfortunately, we can only do so when there are no pending actions.
 261      * Otherwise, we could mistakenly throw away those results here, and
 262      * the cluster will stall waiting for them and time out the operation.
 263      */
 264     if ((transition_graph->pending == 0)
 265         && xml->children && xml->children->next) {
 266 
 267         crm_log_xml_trace(change, "lrm-refresh");
 268         abort_transition(INFINITY, tg_restart, "History refresh", NULL);
 269         return;
 270     }
 271 
 272     for (rsc = pcmk__xml_first_child(xml); rsc != NULL;
 273          rsc = pcmk__xml_next(rsc)) {
 274         crm_trace("Processing %s", ID(rsc));
 275         process_lrm_resource_diff(rsc, node);
 276     }
 277 }
 278 
 279 static char *extract_node_uuid(const char *xpath) 
     /* [previous][next][first][last][top][bottom][index][help] */
 280 {
 281     char *mutable_path = strdup(xpath);
 282     char *node_uuid = NULL;
 283     char *search = NULL;
 284     char *match = NULL;
 285 
 286     match = strstr(mutable_path, "node_state[@id=\'");
 287     if (match == NULL) {
 288         free(mutable_path);
 289         return NULL;
 290     }
 291     match += strlen("node_state[@id=\'");
 292 
 293     search = strchr(match, '\'');
 294     if (search == NULL) {
 295         free(mutable_path);
 296         return NULL;
 297     }
 298     search[0] = 0;
 299 
 300     node_uuid = strdup(match);
 301     free(mutable_path);
 302     return node_uuid;
 303 }
 304 
 305 static void
 306 abort_unless_down(const char *xpath, const char *op, xmlNode *change,
     /* [previous][next][first][last][top][bottom][index][help] */
 307                   const char *reason)
 308 {
 309     char *node_uuid = NULL;
 310     crm_action_t *down = NULL;
 311 
 312     if(!pcmk__str_eq(op, "delete", pcmk__str_casei)) {
 313         abort_transition(INFINITY, tg_restart, reason, change);
 314         return;
 315     }
 316 
 317     node_uuid = extract_node_uuid(xpath);
 318     if(node_uuid == NULL) {
 319         crm_err("Could not extract node ID from %s", xpath);
 320         abort_transition(INFINITY, tg_restart, reason, change);
 321         return;
 322     }
 323 
 324     down = match_down_event(node_uuid);
 325     if (down == NULL) {
 326         crm_trace("Not expecting %s to be down (%s)", node_uuid, xpath);
 327         abort_transition(INFINITY, tg_restart, reason, change);
 328     } else {
 329         crm_trace("Expecting changes to %s (%s)", node_uuid, xpath);
 330     }
 331     free(node_uuid);
 332 }
 333 
 334 static void
 335 process_op_deletion(const char *xpath, xmlNode *change)
     /* [previous][next][first][last][top][bottom][index][help] */
 336 {
 337     char *mutable_key = strdup(xpath);
 338     char *key;
 339     char *node_uuid;
 340 
 341     // Extract the part of xpath between last pair of single quotes
 342     key = strrchr(mutable_key, '\'');
 343     if (key != NULL) {
 344         *key = '\0';
 345         key = strrchr(mutable_key, '\'');
 346     }
 347     if (key == NULL) {
 348         crm_warn("Ignoring malformed CIB update (resource deletion of %s)",
 349                  xpath);
 350         free(mutable_key);
 351         return;
 352     }
 353     ++key;
 354 
 355     node_uuid = extract_node_uuid(xpath);
 356     if (confirm_cancel_action(key, node_uuid) == FALSE) {
 357         abort_transition(INFINITY, tg_restart, "Resource operation removal",
 358                          change);
 359     }
 360     free(mutable_key);
 361     free(node_uuid);
 362 }
 363 
 364 static void
 365 process_delete_diff(const char *xpath, const char *op, xmlNode *change)
     /* [previous][next][first][last][top][bottom][index][help] */
 366 {
 367     if (strstr(xpath, "/" XML_LRM_TAG_RSC_OP "[")) {
 368         process_op_deletion(xpath, change);
 369 
 370     } else if (strstr(xpath, "/" XML_CIB_TAG_LRM "[")) {
 371         abort_unless_down(xpath, op, change, "Resource state removal");
 372 
 373     } else if (strstr(xpath, "/" XML_CIB_TAG_STATE "[")) {
 374         abort_unless_down(xpath, op, change, "Node state removal");
 375 
 376     } else {
 377         crm_trace("Ignoring delete of %s", xpath);
 378     }
 379 }
 380 
 381 static void
 382 process_node_state_diff(xmlNode *state, xmlNode *change, const char *op,
     /* [previous][next][first][last][top][bottom][index][help] */
 383                         const char *xpath)
 384 {
 385     xmlNode *lrm = first_named_child(state, XML_CIB_TAG_LRM);
 386 
 387     process_resource_updates(ID(state), lrm, change, op, xpath);
 388 }
 389 
 390 static void
 391 process_status_diff(xmlNode *status, xmlNode *change, const char *op,
     /* [previous][next][first][last][top][bottom][index][help] */
 392                     const char *xpath)
 393 {
 394     for (xmlNode *state = pcmk__xml_first_child(status); state != NULL;
 395          state = pcmk__xml_next(state)) {
 396         process_node_state_diff(state, change, op, xpath);
 397     }
 398 }
 399 
 400 static void
 401 process_cib_diff(xmlNode *cib, xmlNode *change, const char *op,
     /* [previous][next][first][last][top][bottom][index][help] */
 402                  const char *xpath)
 403 {
 404     xmlNode *status = first_named_child(cib, XML_CIB_TAG_STATUS);
 405     xmlNode *config = first_named_child(cib, XML_CIB_TAG_CONFIGURATION);
 406 
 407     if (status) {
 408         process_status_diff(status, change, op, xpath);
 409     }
 410     if (config) {
 411         abort_transition(INFINITY, tg_restart,
 412                          "Non-status-only change", change);
 413     }
 414 }
 415 
 416 static void
 417 te_update_diff_v2(xmlNode *diff)
     /* [previous][next][first][last][top][bottom][index][help] */
 418 {
 419     crm_log_xml_trace(diff, "Patch:Raw");
 420 
 421     for (xmlNode *change = pcmk__xml_first_child(diff); change != NULL;
 422          change = pcmk__xml_next(change)) {
 423 
 424         xmlNode *match = NULL;
 425         const char *name = NULL;
 426         const char *xpath = crm_element_value(change, XML_DIFF_PATH);
 427 
 428         // Possible ops: create, modify, delete, move
 429         const char *op = crm_element_value(change, XML_DIFF_OP);
 430 
 431         // Ignore uninteresting updates
 432         if (op == NULL) {
 433             continue;
 434 
 435         } else if (xpath == NULL) {
 436             crm_trace("Ignoring %s change for version field", op);
 437             continue;
 438 
 439         } else if (strcmp(op, "move") == 0) {
 440             crm_trace("Ignoring move change at %s", xpath);
 441             continue;
 442         }
 443 
 444         // Find the result of create/modify ops
 445         if (strcmp(op, "create") == 0) {
 446             match = change->children;
 447 
 448         } else if (strcmp(op, "modify") == 0) {
 449             match = first_named_child(change, XML_DIFF_RESULT);
 450             if(match) {
 451                 match = match->children;
 452             }
 453 
 454         } else if (strcmp(op, "delete") != 0) {
 455             crm_warn("Ignoring malformed CIB update (%s operation on %s is unrecognized)",
 456                      op, xpath);
 457             continue;
 458         }
 459 
 460         if (match) {
 461             if (match->type == XML_COMMENT_NODE) {
 462                 crm_trace("Ignoring %s operation for comment at %s", op, xpath);
 463                 continue;
 464             }
 465             name = (const char *)match->name;
 466         }
 467 
 468         crm_trace("Handling %s operation for %s%s%s",
 469                   op, (xpath? xpath : "CIB"),
 470                   (name? " matched by " : ""), (name? name : ""));
 471 
 472         if (strstr(xpath, "/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION)) {
 473             abort_transition(INFINITY, tg_restart, "Configuration change",
 474                              change);
 475             break; // Won't be packaged with operation results we may be waiting for
 476 
 477         } else if (strstr(xpath, "/" XML_CIB_TAG_TICKETS)
 478                    || pcmk__str_eq(name, XML_CIB_TAG_TICKETS, pcmk__str_casei)) {
 479             abort_transition(INFINITY, tg_restart, "Ticket attribute change", change);
 480             break; // Won't be packaged with operation results we may be waiting for
 481 
 482         } else if (strstr(xpath, "/" XML_TAG_TRANSIENT_NODEATTRS "[")
 483                    || pcmk__str_eq(name, XML_TAG_TRANSIENT_NODEATTRS, pcmk__str_casei)) {
 484             abort_unless_down(xpath, op, change, "Transient attribute change");
 485             break; // Won't be packaged with operation results we may be waiting for
 486 
 487         } else if (strcmp(op, "delete") == 0) {
 488             process_delete_diff(xpath, op, change);
 489 
 490         } else if (name == NULL) {
 491             crm_warn("Ignoring malformed CIB update (%s at %s has no result)",
 492                      op, xpath);
 493 
 494         } else if (strcmp(name, XML_TAG_CIB) == 0) {
 495             process_cib_diff(match, change, op, xpath);
 496 
 497         } else if (strcmp(name, XML_CIB_TAG_STATUS) == 0) {
 498             process_status_diff(match, change, op, xpath);
 499 
 500         } else if (strcmp(name, XML_CIB_TAG_STATE) == 0) {
 501             process_node_state_diff(match, change, op, xpath);
 502 
 503         } else if (strcmp(name, XML_CIB_TAG_LRM) == 0) {
 504             process_resource_updates(ID(match), match, change, op, xpath);
 505 
 506         } else if (strcmp(name, XML_LRM_TAG_RESOURCES) == 0) {
 507             char *local_node = pcmk__xpath_node_id(xpath, "lrm");
 508 
 509             process_resource_updates(local_node, match, change, op, xpath);
 510             free(local_node);
 511 
 512         } else if (strcmp(name, XML_LRM_TAG_RESOURCE) == 0) {
 513             char *local_node = pcmk__xpath_node_id(xpath, "lrm");
 514 
 515             process_lrm_resource_diff(match, local_node);
 516             free(local_node);
 517 
 518         } else if (strcmp(name, XML_LRM_TAG_RSC_OP) == 0) {
 519             char *local_node = pcmk__xpath_node_id(xpath, "lrm");
 520 
 521             process_graph_event(match, local_node);
 522             free(local_node);
 523 
 524         } else {
 525             crm_warn("Ignoring malformed CIB update (%s at %s has unrecognized result %s)",
 526                      op, xpath, name);
 527         }
 528     }
 529 }
 530 
 531 void
 532 te_update_diff(const char *event, xmlNode * msg)
     /* [previous][next][first][last][top][bottom][index][help] */
 533 {
 534     xmlNode *diff = NULL;
 535     const char *op = NULL;
 536     int rc = -EINVAL;
 537     int format = 1;
 538     int p_add[] = { 0, 0, 0 };
 539     int p_del[] = { 0, 0, 0 };
 540 
 541     CRM_CHECK(msg != NULL, return);
 542     crm_element_value_int(msg, F_CIB_RC, &rc);
 543 
 544     if (transition_graph == NULL) {
 545         crm_trace("No graph");
 546         return;
 547 
 548     } else if (rc < pcmk_ok) {
 549         crm_trace("Filter rc=%d (%s)", rc, pcmk_strerror(rc));
 550         return;
 551 
 552     } else if (transition_graph->complete
 553                && fsa_state != S_IDLE
 554                && fsa_state != S_TRANSITION_ENGINE
 555                && fsa_state != S_POLICY_ENGINE) {
 556         crm_trace("Filter state=%s, complete=%d", fsa_state2string(fsa_state),
 557                   transition_graph->complete);
 558         return;
 559     }
 560 
 561     op = crm_element_value(msg, F_CIB_OPERATION);
 562     diff = get_message_xml(msg, F_CIB_UPDATE_RESULT);
 563 
 564     xml_patch_versions(diff, p_add, p_del);
 565     crm_debug("Processing (%s) diff: %d.%d.%d -> %d.%d.%d (%s)", op,
 566               p_del[0], p_del[1], p_del[2], p_add[0], p_add[1], p_add[2],
 567               fsa_state2string(fsa_state));
 568 
 569     crm_element_value_int(diff, "format", &format);
 570     switch (format) {
 571         case 1:
 572             te_update_diff_v1(event, diff);
 573             break;
 574         case 2:
 575             te_update_diff_v2(diff);
 576             break;
 577         default:
 578             crm_warn("Ignoring malformed CIB update (unknown patch format %d)",
 579                      format);
 580     }
 581 }
 582 
 583 gboolean
 584 process_te_message(xmlNode * msg, xmlNode * xml_data)
     /* [previous][next][first][last][top][bottom][index][help] */
 585 {
 586     const char *from = crm_element_value(msg, F_ORIG);
 587     const char *sys_to = crm_element_value(msg, F_CRM_SYS_TO);
 588     const char *sys_from = crm_element_value(msg, F_CRM_SYS_FROM);
 589     const char *ref = crm_element_value(msg, F_CRM_REFERENCE);
 590     const char *op = crm_element_value(msg, F_CRM_TASK);
 591     const char *type = crm_element_value(msg, F_CRM_MSG_TYPE);
 592 
 593     crm_trace("Processing %s (%s) message", op, ref);
 594     crm_log_xml_trace(msg, "ipc");
 595 
 596     if (op == NULL) {
 597         /* error */
 598 
 599     } else if (sys_to == NULL || strcasecmp(sys_to, CRM_SYSTEM_TENGINE) != 0) {
 600         crm_trace("Bad sys-to %s", crm_str(sys_to));
 601         return FALSE;
 602 
 603     } else if (pcmk__str_eq(op, CRM_OP_INVOKE_LRM, pcmk__str_casei)
 604                && pcmk__str_eq(sys_from, CRM_SYSTEM_LRMD, pcmk__str_casei)
 605 /*                && pcmk__str_eq(type, XML_ATTR_RESPONSE, pcmk__str_casei) */
 606         ) {
 607         xmlXPathObject *xpathObj = NULL;
 608 
 609         crm_log_xml_trace(msg, "Processing (N)ACK");
 610         crm_debug("Processing (N)ACK %s from %s", crm_element_value(msg, F_CRM_REFERENCE), from);
 611 
 612         xpathObj = xpath_search(xml_data, "//" XML_LRM_TAG_RSC_OP);
 613         if (numXpathResults(xpathObj)) {
 614             int lpc = 0, max = numXpathResults(xpathObj);
 615 
 616             for (lpc = 0; lpc < max; lpc++) {
 617                 xmlNode *rsc_op = getXpathResult(xpathObj, lpc);
 618                 const char *node = get_node_id(rsc_op);
 619 
 620                 process_graph_event(rsc_op, node);
 621             }
 622             freeXpathObject(xpathObj);
 623 
 624         } else {
 625             crm_log_xml_err(msg, "Invalid (N)ACK");
 626             freeXpathObject(xpathObj);
 627             return FALSE;
 628         }
 629 
 630     } else {
 631         crm_err("Unknown command: %s::%s from %s", type, op, sys_from);
 632     }
 633 
 634     crm_trace("finished processing message");
 635 
 636     return TRUE;
 637 }
 638 
 639 void
 640 cib_action_updated(xmlNode * msg, int call_id, int rc, xmlNode * output, void *user_data)
     /* [previous][next][first][last][top][bottom][index][help] */
 641 {
 642     if (rc < pcmk_ok) {
 643         crm_err("Update %d FAILED: %s", call_id, pcmk_strerror(rc));
 644     }
 645 }
 646 
 647 /*!
 648  * \brief Handle a timeout in node-to-node communication
 649  *
 650  * \param[in] data  Pointer to action timer
 651  *
 652  * \return FALSE (indicating that source should be not be re-added)
 653  */
 654 gboolean
 655 action_timer_callback(gpointer data)
     /* [previous][next][first][last][top][bottom][index][help] */
 656 {
 657     crm_action_timer_t *timer = NULL;
 658     const char *task = NULL;
 659     const char *on_node = NULL;
 660     const char *via_node = NULL;
 661 
 662     CRM_CHECK(data != NULL, return FALSE);
 663 
 664     timer = (crm_action_timer_t *) data;
 665     stop_te_timer(timer);
 666 
 667     CRM_CHECK(timer->action != NULL, return FALSE);
 668 
 669     task = crm_element_value(timer->action->xml, XML_LRM_ATTR_TASK);
 670     on_node = crm_element_value(timer->action->xml, XML_LRM_ATTR_TARGET);
 671     via_node = crm_element_value(timer->action->xml, XML_LRM_ATTR_ROUTER_NODE);
 672 
 673     if (transition_graph->complete) {
 674         crm_notice("Node %s did not send %s result (via %s) within %dms "
 675                    "(ignoring because transition not in progress)",
 676                    (on_node? on_node : ""), (task? task : "unknown action"),
 677                    (via_node? via_node : "controller"), timer->timeout);
 678     } else {
 679         /* fail the action */
 680 
 681         crm_err("Node %s did not send %s result (via %s) within %dms "
 682                 "(action timeout plus cluster-delay)",
 683                 (on_node? on_node : ""), (task? task : "unknown action"),
 684                 (via_node? via_node : "controller"),
 685                 timer->timeout + transition_graph->network_delay);
 686         print_action(LOG_ERR, "Aborting transition, action lost: ", timer->action);
 687 
 688         timer->action->failed = TRUE;
 689         te_action_confirmed(timer->action, transition_graph);
 690         abort_transition(INFINITY, tg_restart, "Action lost", NULL);
 691 
 692         // Record timeout in the CIB if appropriate
 693         if ((timer->action->type == action_type_rsc)
 694             && controld_action_is_recordable(task)) {
 695             controld_record_action_timeout(timer->action);
 696         }
 697     }
 698 
 699     return FALSE;
 700 }

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