pacemaker 2.1.8-2.1.8
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
results.h
Go to the documentation of this file.
1/*
2 * Copyright 2012-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#ifndef PCMK__CRM_COMMON_RESULTS__H
10#define PCMK__CRM_COMMON_RESULTS__H
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
22// Lifted from config.h
23/* The _Noreturn keyword of C11. */
24#ifndef _Noreturn
25# if (defined __cplusplus \
26 && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
27 || (defined _MSC_VER && 1900 <= _MSC_VER)))
28# define _Noreturn [[noreturn]]
29# elif ((!defined __cplusplus || defined __clang__) \
30 && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
31 || 4 < __GNUC__ + (7 <= __GNUC_MINOR__)))
32 /* _Noreturn works as-is. */
33# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
34# define _Noreturn __attribute__ ((__noreturn__))
35# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
36# define _Noreturn __declspec (noreturn)
37# else
38# define _Noreturn
39# endif
40#endif
41
42#define CRM_ASSERT(expr) do { \
43 if (!(expr)) { \
44 crm_abort(__FILE__, __func__, __LINE__, #expr, TRUE, FALSE); \
45 } \
46 } while(0)
47
48/*
49 * Function return codes
50 *
51 * Most Pacemaker API functions return an integer return code. There are two
52 * alternative interpretations. The legacy interpration is that the absolute
53 * value of the return code is either a system error number or a custom
54 * pcmk_err_* number. This is less than ideal because system error numbers are
55 * constrained only to the positive int range, so there's the possibility that
56 * system errors and custom errors could collide (which did in fact happen
57 * already on one architecture). The new intepretation is that negative values
58 * are from the pcmk_rc_e enum, and positive values are system error numbers.
59 * Both use 0 for success.
60 *
61 * For system error codes, see:
62 * - /usr/include/asm-generic/errno.h
63 * - /usr/include/asm-generic/errno-base.h
64 */
65
66// Legacy custom return codes for Pacemaker API functions (deprecated)
67
68// NOTE: sbd (as of at least 1.5.2) uses this
69#define pcmk_ok 0
70
71#define PCMK_ERROR_OFFSET 190 /* Replacements on non-linux systems, see include/portability.h */
72#define PCMK_CUSTOM_OFFSET 200 /* Purely custom codes */
73#define pcmk_err_generic 201
74#define pcmk_err_no_quorum 202
75#define pcmk_err_schema_validation 203
76#define pcmk_err_transform_failed 204
77#define pcmk_err_old_data 205
78
79// NOTE: sbd (as of at least 1.5.2) uses this
80#define pcmk_err_diff_failed 206
81
82// NOTE: sbd (as of at least 1.5.2) uses this
83#define pcmk_err_diff_resync 207
84
85#define pcmk_err_cib_modified 208
86#define pcmk_err_cib_backup 209
87#define pcmk_err_cib_save 210
88#define pcmk_err_schema_unchanged 211
89#define pcmk_err_cib_corrupt 212
90#define pcmk_err_multiple 213
91#define pcmk_err_node_unknown 214
92#define pcmk_err_already 215
93/* On HPPA 215 is ENOSYM (Unknown error 215), which hopefully never happens. */
94#ifdef __hppa__
95#define pcmk_err_bad_nvpair 250 /* 216 is ENOTSOCK */
96#define pcmk_err_unknown_format 252 /* 217 is EDESTADDRREQ */
97#else
98#define pcmk_err_bad_nvpair 216
99#define pcmk_err_unknown_format 217
100#endif
101
115 /* When adding new values, use consecutively lower numbers, update the array
116 * in lib/common/results.c, and test with crm_error.
117 */
156 // Developers: Use a more specific code than pcmk_rc_error whenever possible
158
159 // Values -1 through -1000 reserved for caller use
160
161 // NOTE: sbd (as of at least 1.5.2) uses this
162 pcmk_rc_ok = 0
163
164 // Positive values reserved for system error numbers
166
167
179
180 // NOTE: booth (as of at least 1.1) uses this value
182
188
189 // NOTE: booth (as of at least 1.1) uses this value
191
196
197 /* These two are Pacemaker extensions, not in the OCF standard. The
198 * controller records PCMK_OCF_UNKNOWN for pending actions.
199 * PCMK_OCF_CONNECTION_DIED is used only with older DCs that don't support
200 * PCMK_EXEC_NOT_CONNECTED.
201 */
204
205#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
206 // Former Pacemaker extensions
214
217
220
223#endif
224};
225
226// NOTE: sbd (as of at least 1.5.2) uses this
253typedef enum crm_exit_e {
254 // Common convention
257
258 // LSB + OCF
267
268 // sysexits.h
284
285 // Custom
300
301 // Other
303
304 /* Anything above 128 overlaps with some shells' use of these values for
305 * "interrupted by signal N", and so may be unreliable when detected by
306 * shell scripts.
307 */
308
309 // OCF Resource Agent API 1.1
312
313 /* Custom
314 *
315 * This can be used to initialize exit status variables or to indicate that
316 * a command is pending (which is what the controller uses it for).
317 */
319
322
349
370
372 const char **name, const char **desc);
373const char *pcmk_rc_name(int rc);
374
375// NOTE: sbd (as of at least 1.5.2) uses this
376const char *pcmk_rc_str(int rc);
377
379enum ocf_exitcode pcmk_rc2ocf(int rc);
380int pcmk_rc2legacy(int rc);
381int pcmk_legacy2rc(int legacy_rc);
382
383// NOTE: sbd (as of at least 1.5.2) uses this
384const char *pcmk_strerror(int rc);
385
386const char *pcmk_errorname(int rc);
387const char *crm_exit_name(crm_exit_t exit_code);
388
389// NOTE: sbd (as of at least 1.5.2) uses this
390const char *crm_exit_str(crm_exit_t exit_code);
391
393
394static inline const char *
395pcmk_exec_status_str(enum pcmk_exec_status status)
396{
397 switch (status) {
398 case PCMK_EXEC_PENDING: return "pending";
399 case PCMK_EXEC_DONE: return "complete";
400 case PCMK_EXEC_CANCELLED: return "Cancelled";
401 case PCMK_EXEC_TIMEOUT: return "Timed Out";
402 case PCMK_EXEC_NOT_SUPPORTED: return "NOT SUPPORTED";
403 case PCMK_EXEC_ERROR: return "Error";
404 case PCMK_EXEC_ERROR_HARD: return "Hard error";
405 case PCMK_EXEC_ERROR_FATAL: return "Fatal error";
406 case PCMK_EXEC_NOT_INSTALLED: return "Not installed";
407 case PCMK_EXEC_NOT_CONNECTED: return "Internal communication failure";
408 case PCMK_EXEC_INVALID: return "Cannot execute now";
409 case PCMK_EXEC_NO_FENCE_DEVICE: return "No fence device";
410 case PCMK_EXEC_NO_SECRETS: return "CIB secrets unavailable";
411 default: return "UNKNOWN!";
412 }
413}
414
415#ifdef __cplusplus
416}
417#endif
418
419#endif
const char * name
Definition cib.c:26
enum crm_ais_msg_types type
Definition cpg.c:3
const char * pcmk_rc_name(int rc)
Get a return code constant name as a string.
Definition results.c:341
const char * pcmk_strerror(int rc)
Definition results.c:149
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
Definition results.c:501
crm_exit_e
Exit status codes for tools and daemons.
Definition results.h:253
@ CRM_EX_IOERR
File I/O error.
Definition results.h:279
@ CRM_EX_PANIC
Panic the local host.
Definition results.h:287
@ CRM_EX_PROTOCOL
Protocol violated.
Definition results.h:281
@ CRM_EX_NOSUCH
Requested item does not exist.
Definition results.h:291
@ CRM_EX_DATAERR
User-supplied data incorrect.
Definition results.h:270
@ CRM_EX_UNSATISFIED
Requested item does not satisfy constraints.
Definition results.h:299
@ CRM_EX_UNSAFE
Requires –force or new conditions.
Definition results.h:293
@ CRM_EX_EXISTS
Requested item already exists.
Definition results.h:294
@ CRM_EX_TIMEOUT
Convention from timeout(1)
Definition results.h:302
@ CRM_EX_NOT_RUNNING
Service safely stopped.
Definition results.h:264
@ CRM_EX_MULTIPLE
Requested item has multiple matches.
Definition results.h:295
@ CRM_EX_UNIMPLEMENT_FEATURE
Requested action not implemented.
Definition results.h:260
@ CRM_EX_ERROR
Unspecified error.
Definition results.h:256
@ CRM_EX_NOT_YET_IN_EFFECT
Requested item is not in effect.
Definition results.h:297
@ CRM_EX_DEGRADED
Service active but more likely to fail soon.
Definition results.h:310
@ CRM_EX_FAILED_PROMOTED
Service failed and possibly promoted.
Definition results.h:266
@ CRM_EX_CANTCREAT
File couldn't be created.
Definition results.h:278
@ CRM_EX_NONE
No exit status available.
Definition results.h:318
@ CRM_EX_OLD
Update older than existing config.
Definition results.h:289
@ CRM_EX_SOFTWARE
Internal software bug.
Definition results.h:275
@ CRM_EX_OSFILE
System file not usable.
Definition results.h:277
@ CRM_EX_NOHOST
Host unknown.
Definition results.h:273
@ CRM_EX_CONFIG
Misconfiguration.
Definition results.h:283
@ CRM_EX_NOPERM
Non-file permission issue.
Definition results.h:282
@ CRM_EX_NOT_CONFIGURED
Parameter invalid (inherently)
Definition results.h:263
@ CRM_EX_NOINPUT
Input file not available.
Definition results.h:271
@ CRM_EX_UNAVAILABLE
Needed service unavailable.
Definition results.h:274
@ CRM_EX_OSERR
External (OS/environmental) problem.
Definition results.h:276
@ CRM_EX_DISCONNECT
Lost connection to something.
Definition results.h:288
@ CRM_EX_FATAL
Do not respawn.
Definition results.h:286
@ CRM_EX_DIGEST
Digest comparison failed.
Definition results.h:290
@ CRM_EX_PROMOTED
Service active and promoted.
Definition results.h:265
@ CRM_EX_EXPIRED
Requested item has expired.
Definition results.h:296
@ CRM_EX_NOUSER
User does not exist.
Definition results.h:272
@ CRM_EX_OK
Success.
Definition results.h:255
@ CRM_EX_DEGRADED_PROMOTED
Service promoted but more likely to fail soon.
Definition results.h:311
@ CRM_EX_USAGE
Command line usage error.
Definition results.h:269
@ CRM_EX_MAX
Ensure crm_exit_t can hold this.
Definition results.h:320
@ CRM_EX_QUORUM
Local partition does not have quorum.
Definition results.h:292
@ CRM_EX_NOT_INSTALLED
Dependencies not available locally.
Definition results.h:262
@ CRM_EX_INVALID_PARAM
Parameter invalid (in local context)
Definition results.h:259
@ CRM_EX_INSUFFICIENT_PRIV
Insufficient privileges.
Definition results.h:261
@ CRM_EX_TEMPFAIL
Try again.
Definition results.h:280
@ CRM_EX_INDETERMINATE
Could not determine status.
Definition results.h:298
int pcmk_result_get_strings(int code, enum pcmk_result_type type, const char **name, const char **desc)
Get the name and description of a given result code.
Definition results.c:44
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
Definition results.c:936
enum ocf_exitcode pcmk_rc2ocf(int rc)
Map a function return code to the most similar OCF exit code.
Definition results.c:830
ocf_exitcode
Exit status codes for resource agents.
Definition results.h:177
@ PCMK_OCF_INSUFFICIENT_PRIV
Insufficient privileges.
Definition results.h:185
@ PCMK_OCF_FAILED_PROMOTED
Service failed and possibly in promoted role.
Definition results.h:193
@ PCMK_OCF_RUNNING_PROMOTED
Service active and promoted.
Definition results.h:192
@ PCMK_OCF_DEGRADED_MASTER
Definition results.h:222
@ PCMK_OCF_DEGRADED_PROMOTED
Service promoted but more likely to fail soon.
Definition results.h:195
@ PCMK_OCF_UNIMPLEMENT_FEATURE
Requested action not implemented.
Definition results.h:184
@ PCMK_OCF_FAILED_MASTER
Definition results.h:219
@ PCMK_OCF_NOT_CONFIGURED
Parameter invalid (inherently)
Definition results.h:187
@ PCMK_OCF_SIGNAL
Definition results.h:208
@ PCMK_OCF_DEGRADED
Service active but more likely to fail soon.
Definition results.h:194
@ PCMK_OCF_NOT_INSTALLED
Dependencies not available locally.
Definition results.h:186
@ PCMK_OCF_UNKNOWN_ERROR
Unspecified error.
Definition results.h:181
@ PCMK_OCF_RUNNING_MASTER
Definition results.h:216
@ PCMK_OCF_PENDING
Definition results.h:210
@ PCMK_OCF_CANCELLED
Definition results.h:211
@ PCMK_OCF_EXEC_ERROR
Definition results.h:207
@ PCMK_OCF_INVALID_PARAM
Parameter invalid (in local context)
Definition results.h:183
@ PCMK_OCF_NOT_RUNNING
Service safely stopped.
Definition results.h:190
@ PCMK_OCF_OK
Success.
Definition results.h:178
@ PCMK_OCF_TIMEOUT
Definition results.h:212
@ PCMK_OCF_UNKNOWN
Action is pending.
Definition results.h:203
@ PCMK_OCF_NOT_SUPPORTED
Definition results.h:209
@ PCMK_OCF_CONNECTION_DIED
Definition results.h:202
@ PCMK_OCF_OTHER_ERROR
Definition results.h:213
pcmk_rc_e
Return codes for Pacemaker API functions.
Definition results.h:114
@ pcmk_rc_compression
Definition results.h:118
@ pcmk_rc_no_input
Definition results.h:130
@ pcmk_rc_disabled
Definition results.h:123
@ pcmk_rc_before_range
Definition results.h:134
@ pcmk_rc_ns_resolution
Definition results.h:119
@ pcmk_rc_cib_backup
Definition results.h:148
@ pcmk_rc_ipc_pid_only
Definition results.h:137
@ pcmk_rc_no_transaction
Definition results.h:120
@ pcmk_rc_op_unsatisfied
Definition results.h:136
@ pcmk_rc_node_unknown
Definition results.h:152
@ pcmk_rc_transform_failed
Definition results.h:143
@ pcmk_rc_no_output
Definition results.h:131
@ pcmk_rc_multiple
Definition results.h:151
@ pcmk_rc_bad_nvpair
Definition results.h:154
@ pcmk_rc_old_data
Definition results.h:144
@ pcmk_rc_ok
Definition results.h:162
@ pcmk_rc_no_quorum
Definition results.h:140
@ pcmk_rc_schema_validation
Definition results.h:141
@ pcmk_rc_undetermined
Definition results.h:135
@ pcmk_rc_cib_save
Definition results.h:149
@ pcmk_rc_ipc_unauthorized
Definition results.h:139
@ pcmk_rc_unknown_format
Definition results.h:155
@ pcmk_rc_within_range
Definition results.h:133
@ pcmk_rc_after_range
Definition results.h:132
@ pcmk_rc_schema_unchanged
Definition results.h:142
@ pcmk_rc_unpack_error
Definition results.h:125
@ pcmk_rc_error
Definition results.h:157
@ pcmk_rc_already
Definition results.h:153
@ pcmk_rc_dot_error
Definition results.h:128
@ pcmk_rc_duplicate_id
Definition results.h:124
@ pcmk_rc_diff_resync
Definition results.h:146
@ pcmk_rc_ipc_unresponsive
Definition results.h:138
@ pcmk_rc_invalid_transition
Definition results.h:126
@ pcmk_rc_underflow
Definition results.h:129
@ pcmk_rc_diff_failed
Definition results.h:145
@ pcmk_rc_bad_input
Definition results.h:122
@ pcmk_rc_graph_error
Definition results.h:127
@ pcmk_rc_cib_modified
Definition results.h:147
@ pcmk_rc_bad_xml_patch
Definition results.h:121
@ pcmk_rc_cib_corrupt
Definition results.h:150
const char * crm_exit_name(crm_exit_t exit_code)
Definition results.c:588
int pcmk_rc2legacy(int rc)
Definition results.c:546
const char * pcmk_errorname(int rc)
Definition results.c:123
pcmk_result_type
Types of Pacemaker result codes.
Definition results.h:364
@ pcmk_result_exitcode
Exit status code.
Definition results.h:367
@ pcmk_result_legacy
Legacy API function return code.
Definition results.h:365
@ pcmk_result_rc
Standard Pacemaker return code.
Definition results.h:366
@ pcmk_result_exec_status
Execution status.
Definition results.h:368
const char * crm_exit_str(crm_exit_t exit_code)
Definition results.c:640
pcmk_exec_status
Execution status.
Definition results.h:330
@ PCMK_EXEC_CANCELLED
Action was cancelled.
Definition results.h:334
@ PCMK_EXEC_NO_SECRETS
Necessary CIB secrets are unavailable.
Definition results.h:344
@ PCMK_EXEC_ERROR_FATAL
Execution failed, do not retry anywhere.
Definition results.h:339
@ PCMK_EXEC_NOT_INSTALLED
Agent or dependency not available locally.
Definition results.h:340
@ PCMK_EXEC_INVALID
Action cannot be attempted (e.g. shutdown)
Definition results.h:342
@ PCMK_EXEC_DONE
Action completed, result is known.
Definition results.h:333
@ PCMK_EXEC_ERROR
Execution failed, may be retried.
Definition results.h:337
@ PCMK_EXEC_NOT_SUPPORTED
Agent does not implement requested action.
Definition results.h:336
@ PCMK_EXEC_TIMEOUT
Action did not complete in time.
Definition results.h:335
@ PCMK_EXEC_PENDING
Action is in progress.
Definition results.h:332
@ PCMK_EXEC_UNKNOWN
Used only to initialize variables.
Definition results.h:331
@ PCMK_EXEC_ERROR_HARD
Execution failed, do not retry on node.
Definition results.h:338
@ PCMK_EXEC_MAX
Maximum value for this enum.
Definition results.h:347
@ PCMK_EXEC_NO_FENCE_DEVICE
No fence device is configured for target.
Definition results.h:343
@ PCMK_EXEC_NOT_CONNECTED
No connection to executor.
Definition results.h:341
int pcmk_legacy2rc(int legacy_rc)
Definition results.c:559
enum crm_exit_e crm_exit_t
crm_exit_t pcmk_rc2exitc(int rc)
Map a function return code to the most similar exit code.
Definition results.c:702
#define _Noreturn
Definition results.h:38