| 672 | } |
| 673 | |
| 674 | static gboolean |
| 675 | apply_system_health(pe_working_set_t * data_set) |
| 676 | { |
| 677 | GListPtr gIter = NULL; |
| 678 | const char *health_strategy = pe_pref(data_set->config_hash, "node-health-strategy"); |
| 679 | |
| 680 | if (health_strategy == NULL || safe_str_eq(health_strategy, "none")) { |
| 681 | /* Prevent any accidental health -> score translation */ |
| 682 | node_score_red = 0; |
| 683 | node_score_yellow = 0; |
| 684 | node_score_green = 0; |
| 685 | return TRUE; |
| 686 | |
| 687 | } else if (safe_str_eq(health_strategy, "migrate-on-red")) { |
| 688 | |
| 689 | /* Resources on nodes which have health values of red are |
| 690 | * weighted away from that node. |
| 691 | */ |
| 692 | node_score_red = -INFINITY; |
| 693 | node_score_yellow = 0; |
| 694 | node_score_green = 0; |
| 695 | |
| 696 | } else if (safe_str_eq(health_strategy, "only-green")) { |
| 697 | |
| 698 | /* Resources on nodes which have health values of red or yellow |
| 699 | * are forced away from that node. |
| 700 | */ |
| 701 | node_score_red = -INFINITY; |
| 702 | node_score_yellow = -INFINITY; |
| 703 | node_score_green = 0; |
| 704 | |
| 705 | } else if (safe_str_eq(health_strategy, "progressive")) { |
| 706 | /* Same as the above, but use the r/y/g scores provided by the user |
| 707 | * Defaults are provided by the pe_prefs table |
| 708 | */ |
| 709 | |
| 710 | } else if (safe_str_eq(health_strategy, "custom")) { |
| 711 | |
| 712 | /* Requires the admin to configure the rsc_location constaints for |
| 713 | * processing the stored health scores |
| 714 | */ |
| 715 | /* TODO: Check for the existance of appropriate node health constraints */ |
| 716 | return TRUE; |
| 717 | |
| 718 | } else { |
| 719 | crm_err("Unknown node health strategy: %s", health_strategy); |
| 720 | return FALSE; |
| 721 | } |
| 722 | |
| 723 | crm_info("Applying automated node health strategy: %s", health_strategy); |
| 724 | |
| 725 | for (gIter = data_set->nodes; gIter != NULL; gIter = gIter->next) { |
| 726 | int system_health = 0; |
| 727 | node_t *node = (node_t *) gIter->data; |
| 728 | |
| 729 | /* Search through the node hash table for system health entries. */ |
| 730 | g_hash_table_foreach(node->details->attrs, calculate_system_health, &system_health); |
| 731 |
no test coverage detected