pacemaker 2.1.5-a3f44794f94
Scalable High-Availability cluster resource manager
common.h
Go to the documentation of this file.
1/*
2 * Copyright 2004-2022 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#ifndef PCMK__CRM_PENGINE_COMMON__H
11# define PCMK__CRM_PENGINE_COMMON__H
12
13# include <glib.h>
14# include <regex.h>
15# include <crm/common/iso8601.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21extern gboolean was_processing_error;
22extern gboolean was_processing_warning;
23
24/* The order is (partially) significant here; the values from action_fail_ignore
25 * through action_fail_fence are in order of increasing severity.
26 *
27 * @COMPAT The values should be ordered and numbered per the "TODO" comments
28 * below, so all values are in order of severity and there is room for
29 * future additions, but that would break API compatibility.
30 * @TODO For now, we just use a function to compare the values specially, but
31 * at the next compatibility break, we should arrange things properly.
32 */
34 action_fail_ignore, // @TODO = 10
35 // @TODO action_fail_demote = 20,
36 action_fail_recover, // @TODO = 30
37 // @TODO action_fail_reset_remote = 40,
38 // @TODO action_fail_restart_container = 50,
39 action_fail_migrate, // @TODO = 60
40 action_fail_block, // @TODO = 70
41 action_fail_stop, // @TODO = 80
42 action_fail_standby, // @TODO = 90
43 action_fail_fence, // @TODO = 100
44
45 // @COMPAT Values below here are out of order for API compatibility
46
48
49 /* This is reserved for internal use for remote node connection resources.
50 * Fence the remote node if stonith is enabled, otherwise attempt to recover
51 * the connection resource. This allows us to specify types of connection
52 * resource failures that should result in fencing the remote node
53 * (for example, recurring monitor failures).
54 */
56
58};
59
60/* the "done" action must be the "pre" action +1 */
76};
77
83};
84
86 rsc_req_nothing, /* Allowed by custom_action() */
87 rsc_req_quorum, /* Enforced by custom_action() */
88 rsc_req_stonith /* Enforced by native_start_constraints() */
89};
90
98
99#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
102
105#endif
106};
107
108# define RSC_ROLE_MAX (RSC_ROLE_PROMOTED + 1)
109
110# define RSC_ROLE_UNKNOWN_S "Unknown"
111# define RSC_ROLE_STOPPED_S "Stopped"
112# define RSC_ROLE_STARTED_S "Started"
113# define RSC_ROLE_UNPROMOTED_S "Unpromoted"
114# define RSC_ROLE_PROMOTED_S "Promoted"
115# define RSC_ROLE_UNPROMOTED_LEGACY_S "Slave"
116# define RSC_ROLE_PROMOTED_LEGACY_S "Master"
117
120 pe_print_log = (1 << 0),
121 pe_print_html = (1 << 1),
123 pe_print_printf = (1 << 3),
124 pe_print_dev = (1 << 4),
125 pe_print_details = (1 << 5),
128 pe_print_ops = (1 << 8),
130 pe_print_xml = (1 << 10),
131 pe_print_brief = (1 << 11),
132 pe_print_pending = (1 << 12),
134 pe_print_clone_active = (1 << 14), // Print clone instances only if active
135 pe_print_implicit = (1 << 15) // Print implicitly created resources
137
138const char *task2text(enum action_tasks task);
139enum action_tasks text2task(const char *task);
140enum rsc_role_e text2role(const char *role);
141const char *role2text(enum rsc_role_e role);
142const char *fail2text(enum action_fail_response fail);
143
144const char *pe_pref(GHashTable * options, const char *name);
145void calculate_active_ops(GList * sorted_op_list, int *start_index, int *stop_index);
146
154static inline const char *
155recovery2text(enum rsc_recovery_type type)
156{
157 switch (type) {
159 return "shutting it down";
161 return "attempting recovery";
162 case recovery_block:
163 return "waiting for an administrator";
165 return "stopping unexpected instances";
166 }
167 return "Unknown";
168}
169
170typedef struct pe_re_match_data {
171 char *string;
172 int nregs;
173 regmatch_t *pmatch;
175
176typedef struct pe_match_data {
178 GHashTable *params;
179 GHashTable *meta;
181
182typedef struct pe_rsc_eval_data {
183 const char *standard;
184 const char *provider;
185 const char *agent;
187
188typedef struct pe_op_eval_data {
189 const char *op_name;
190 guint interval;
192
193typedef struct pe_rule_eval_data {
194 GHashTable *node_hash;
201
202#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
204#endif
205
206#ifdef __cplusplus
207}
208#endif
209
210#endif
const char * name
Definition: cib.c:24
pe_print_options
Deprecated.
Definition: common.h:119
@ pe_print_ncurses
Definition: common.h:122
@ pe_print_printf
Definition: common.h:123
@ pe_print_rsconly
Ignored.
Definition: common.h:127
@ pe_print_implicit
Definition: common.h:135
@ pe_print_log
Definition: common.h:120
@ pe_print_brief
Definition: common.h:131
@ pe_print_xml
Definition: common.h:130
@ pe_print_clone_active
Definition: common.h:134
@ pe_print_max_details
Ignored.
Definition: common.h:126
@ pe_print_details
Ignored.
Definition: common.h:125
@ pe_print_dev
Definition: common.h:124
@ pe_print_pending
Definition: common.h:132
@ pe_print_suppres_nl
Definition: common.h:129
@ pe_print_clone_details
Definition: common.h:133
@ pe_print_html
Definition: common.h:121
@ pe_print_ops
Definition: common.h:128
rsc_start_requirement
Definition: common.h:85
@ rsc_req_quorum
Definition: common.h:87
@ rsc_req_stonith
Definition: common.h:88
@ rsc_req_nothing
Definition: common.h:86
enum action_tasks text2task(const char *task)
Definition: common.c:353
void calculate_active_ops(GList *sorted_op_list, int *start_index, int *stop_index)
Definition: unpack.c:2290
gboolean was_processing_error
Definition: common.c:20
action_fail_response
Definition: common.h:33
@ action_fail_block
Definition: common.h:40
@ action_fail_reset_remote
Definition: common.h:55
@ action_fail_migrate
Definition: common.h:39
@ action_fail_ignore
Definition: common.h:34
@ action_fail_restart_container
Definition: common.h:47
@ action_fail_fence
Definition: common.h:43
@ action_fail_standby
Definition: common.h:42
@ action_fail_demote
Definition: common.h:57
@ action_fail_stop
Definition: common.h:41
@ action_fail_recover
Definition: common.h:36
const char * fail2text(enum action_fail_response fail)
Definition: common.c:313
rsc_recovery_type
Definition: common.h:78
@ recovery_stop_start
Definition: common.h:79
@ recovery_block
Definition: common.h:81
@ recovery_stop_only
Definition: common.h:80
@ recovery_stop_unexpected
Definition: common.h:82
struct pe_rule_eval_data pe_rule_eval_data_t
const char * role2text(enum rsc_role_e role)
Definition: common.c:454
const char * task2text(enum action_tasks task)
Definition: common.c:401
const char * pe_pref(GHashTable *options, const char *name)
Definition: common.c:307
action_tasks
Definition: common.h:61
@ no_action
Definition: common.h:62
@ started_rsc
Definition: common.h:67
@ shutdown_crm
Definition: common.h:74
@ start_rsc
Definition: common.h:66
@ action_demote
Definition: common.h:72
@ stonith_node
Definition: common.h:75
@ action_demoted
Definition: common.h:73
@ action_notified
Definition: common.h:69
@ stop_rsc
Definition: common.h:64
@ action_promote
Definition: common.h:70
@ monitor_rsc
Definition: common.h:63
@ action_promoted
Definition: common.h:71
@ stopped_rsc
Definition: common.h:65
@ action_notify
Definition: common.h:68
rsc_role_e
Possible roles that a resource can be in.
Definition: common.h:92
@ RSC_ROLE_MASTER
Definition: common.h:104
@ RSC_ROLE_STARTED
Definition: common.h:95
@ RSC_ROLE_STOPPED
Definition: common.h:94
@ RSC_ROLE_PROMOTED
Definition: common.h:97
@ RSC_ROLE_UNKNOWN
Definition: common.h:93
@ RSC_ROLE_UNPROMOTED
Definition: common.h:96
@ RSC_ROLE_SLAVE
Definition: common.h:101
struct pe_match_data pe_match_data_t
gboolean was_processing_warning
Definition: common.c:21
struct pe_re_match_data pe_re_match_data_t
struct pe_op_eval_data pe_op_eval_data_t
enum rsc_role_e text2role(const char *role)
Definition: common.c:483
struct pe_rsc_eval_data pe_rsc_eval_data_t
Deprecated Pacemaker scheduler utilities.
enum crm_ais_msg_types type
Definition: cpg.c:3
ISO_8601 Date handling.
struct crm_time_s crm_time_t
Definition: iso8601.h:32
GHashTable * meta
Definition: common.h:179
pe_re_match_data_t * re
Definition: common.h:177
GHashTable * params
Definition: common.h:178
const char * op_name
Definition: common.h:189
guint interval
Definition: common.h:190
regmatch_t * pmatch
Definition: common.h:173
char * string
Definition: common.h:171
const char * agent
Definition: common.h:185
const char * provider
Definition: common.h:184
const char * standard
Definition: common.h:183
pe_rsc_eval_data_t * rsc_data
Definition: common.h:198
GHashTable * node_hash
Definition: common.h:194
enum rsc_role_e role
Definition: common.h:195
crm_time_t * now
Definition: common.h:196
pe_match_data_t * match_data
Definition: common.h:197
pe_op_eval_data_t * op_data
Definition: common.h:199