| 561 | } |
| 562 | |
| 563 | static void |
| 564 | common_apply_stickiness(resource_t * rsc, node_t * node, pe_working_set_t * data_set) |
| 565 | { |
| 566 | int fail_count = 0; |
| 567 | resource_t *failed = rsc; |
| 568 | |
| 569 | if (rsc->children) { |
| 570 | GListPtr gIter = rsc->children; |
| 571 | |
| 572 | for (; gIter != NULL; gIter = gIter->next) { |
| 573 | resource_t *child_rsc = (resource_t *) gIter->data; |
| 574 | |
| 575 | common_apply_stickiness(child_rsc, node, data_set); |
| 576 | } |
| 577 | return; |
| 578 | } |
| 579 | |
| 580 | if (is_set(rsc->flags, pe_rsc_managed) |
| 581 | && rsc->stickiness != 0 && g_list_length(rsc->running_on) == 1) { |
| 582 | node_t *current = pe_find_node_id(rsc->running_on, node->details->id); |
| 583 | node_t *match = pe_hash_table_lookup(rsc->allowed_nodes, node->details->id); |
| 584 | |
| 585 | if (current == NULL) { |
| 586 | |
| 587 | } else if (match != NULL || is_set(data_set->flags, pe_flag_symmetric_cluster)) { |
| 588 | resource_t *sticky_rsc = rsc; |
| 589 | |
| 590 | resource_location(sticky_rsc, node, rsc->stickiness, "stickiness", data_set); |
| 591 | pe_rsc_debug(sticky_rsc, "Resource %s: preferring current location" |
| 592 | " (node=%s, weight=%d)", sticky_rsc->id, |
| 593 | node->details->uname, rsc->stickiness); |
| 594 | } else { |
| 595 | GHashTableIter iter; |
| 596 | node_t *nIter = NULL; |
| 597 | |
| 598 | pe_rsc_debug(rsc, "Ignoring stickiness for %s: the cluster is asymmetric" |
| 599 | " and node %s is not explicitly allowed", rsc->id, node->details->uname); |
| 600 | g_hash_table_iter_init(&iter, rsc->allowed_nodes); |
| 601 | while (g_hash_table_iter_next(&iter, NULL, (void **)&nIter)) { |
| 602 | crm_err("%s[%s] = %d", rsc->id, nIter->details->uname, nIter->weight); |
| 603 | } |
| 604 | } |
| 605 | } |
| 606 | |
| 607 | if (is_not_set(rsc->flags, pe_rsc_unique)) { |
| 608 | failed = uber_parent(rsc); |
| 609 | } |
| 610 | |
| 611 | fail_count = get_failcount(node, rsc, NULL, data_set); |
| 612 | if (fail_count > 0 && rsc->migration_threshold != 0) { |
| 613 | if (rsc->migration_threshold <= fail_count) { |
| 614 | resource_location(failed, node, -INFINITY, "__fail_limit__", data_set); |
| 615 | crm_warn("Forcing %s away from %s after %d failures (max=%d)", |
| 616 | failed->id, node->details->uname, fail_count, rsc->migration_threshold); |
| 617 | } else { |
| 618 | crm_info("%s can fail %d more times on %s before being forced off", |
| 619 | failed->id, rsc->migration_threshold - fail_count, node->details->uname); |
| 620 | } |
no test coverage detected