pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
health.c
Go to the documentation of this file.
1/*
2 * Copyright 2024 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 Lesser General Public License
7 * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8 */
9
10#include <crm_internal.h>
11
12#include <stdio.h> // NULL
13
14#include <crm/common/scheduler.h> // pcmk_scheduler_t
15#include <crm/common/scheduler_internal.h> // pcmk_scheduler_t private data
16
25bool
36
47{
48 if (pcmk__str_eq(value, PCMK_VALUE_NONE,
51 }
52 if (pcmk__str_eq(value, PCMK_VALUE_MIGRATE_ON_RED, pcmk__str_casei)) {
54 }
55 if (pcmk__str_eq(value, PCMK_VALUE_ONLY_GREEN, pcmk__str_casei)) {
57 }
58 if (pcmk__str_eq(value, PCMK_VALUE_PROGRESSIVE, pcmk__str_casei)) {
60 }
61 if (pcmk__str_eq(value, PCMK_VALUE_CUSTOM, pcmk__str_casei)) {
63 } else {
64 pcmk__config_err("Using default of \"" PCMK_VALUE_NONE "\" for "
66 " because '%s' is not a valid value",
67 value);
69 }
70}
71
81int
83{
84 int score = 0;
85 int rc = pcmk_rc_ok;
86 const char *value = NULL;
87
88 CRM_CHECK((option != NULL) && (scheduler != NULL), return 0);
89
90 value = pcmk__cluster_option(scheduler->priv->options, option);
91 rc = pcmk_parse_score(value, &score, 0);
92 if (rc != pcmk_rc_ok) {
93 crm_warn("Using 0 for %s because '%s' is invalid: %s",
94 option, value, pcmk_rc_str(rc));
95 }
96 return score;
97}
int pcmk__health_score(const char *option, const pcmk_scheduler_t *scheduler)
Definition health.c:82
bool pcmk__validate_health_strategy(const char *value)
Definition health.c:26
enum pcmk__health_strategy pcmk__parse_health_strategy(const char *value)
Definition health.c:46
pcmk__health_strategy
@ pcmk__health_strategy_custom
@ pcmk__health_strategy_only_green
@ pcmk__health_strategy_progressive
@ pcmk__health_strategy_none
@ pcmk__health_strategy_no_red
#define crm_warn(fmt, args...)
Definition logging.h:360
#define CRM_CHECK(expr, failure_action)
Definition logging.h:213
#define pcmk__config_err(fmt...)
pcmk_scheduler_t * scheduler
#define PCMK_VALUE_ONLY_GREEN
Definition options.h:188
#define PCMK_VALUE_CUSTOM
Definition options.h:142
#define PCMK_OPT_NODE_HEALTH_STRATEGY
Definition options.h:52
#define PCMK_VALUE_PROGRESSIVE
Definition options.h:197
#define PCMK_VALUE_NONE
Definition options.h:180
#define PCMK_VALUE_MIGRATE_ON_RED
Definition options.h:173
const char * pcmk__cluster_option(GHashTable *options, const char *name)
Definition options.c:1410
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
Definition results.c:617
@ pcmk_rc_ok
Definition results.h:159
Scheduler API.
int pcmk_parse_score(const char *score_s, int *score, int default_score)
Parse an integer score from a string.
Definition scores.c:34
bool pcmk__strcase_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
Definition strings.c:1029
@ pcmk__str_null_matches
@ pcmk__str_casei
pcmk__scheduler_private_t * priv
Definition scheduler.h:99