pacemaker 2.1.4-dc6eb4362e
Scalable High-Availability cluster resource manager
results.h
Go to the documentation of this file.
1/*
2 * Copyright 2012-2021 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 abort(); /* crm_abort() doesn't always abort! */ \
46 } \
47 } while(0)
48
49/*
50 * Function return codes
51 *
52 * Most Pacemaker API functions return an integer return code. There are two
53 * alternative interpretations. The legacy interpration is that the absolute
54 * value of the return code is either a system error number or a custom
55 * pcmk_err_* number. This is less than ideal because system error numbers are
56 * constrained only to the positive int range, so there's the possibility that
57 * system errors and custom errors could collide (which did in fact happen
58 * already on one architecture). The new intepretation is that negative values
59 * are from the pcmk_rc_e enum, and positive values are system error numbers.
60 * Both use 0 for success.
61 *
62 * For system error codes, see:
63 * - /usr/include/asm-generic/errno.h
64 * - /usr/include/asm-generic/errno-base.h
65 */
66
67// Legacy custom return codes for Pacemaker API functions (deprecated)
68# define pcmk_ok 0
69# define PCMK_ERROR_OFFSET 190 /* Replacements on non-linux systems, see include/portability.h */
70# define PCMK_CUSTOM_OFFSET 200 /* Purely custom codes */
71# define pcmk_err_generic 201
72# define pcmk_err_no_quorum 202
73# define pcmk_err_schema_validation 203
74# define pcmk_err_transform_failed 204
75# define pcmk_err_old_data 205
76# define pcmk_err_diff_failed 206
77# define pcmk_err_diff_resync 207
78# define pcmk_err_cib_modified 208
79# define pcmk_err_cib_backup 209
80# define pcmk_err_cib_save 210
81# define pcmk_err_schema_unchanged 211
82# define pcmk_err_cib_corrupt 212
83# define pcmk_err_multiple 213
84# define pcmk_err_node_unknown 214
85# define pcmk_err_already 215
86/* On HPPA 215 is ENOSYM (Unknown error 215), which hopefully never happens. */
87#ifdef __hppa__
88# define pcmk_err_bad_nvpair 250 /* 216 is ENOTSOCK */
89# define pcmk_err_unknown_format 252 /* 217 is EDESTADDRREQ */
90#else
91# define pcmk_err_bad_nvpair 216
92# define pcmk_err_unknown_format 217
93#endif
94
108 /* When adding new values, use consecutively lower numbers, update the array
109 * in lib/common/results.c, and test with crm_error.
110 */
141 // Developers: Use a more specific code than pcmk_rc_error whenever possible
143
144 // Values -1 through -1000 reserved for caller use
145
146 pcmk_rc_ok = 0
147
148 // Positive values reserved for system error numbers
150
151
174
175 /* These two are Pacemaker extensions, not in the OCF standard. The
176 * controller records PCMK_OCF_UNKNOWN for pending actions.
177 * PCMK_OCF_CONNECTION_DIED is used only with older DCs that don't support
178 * PCMK_EXEC_NOT_CONNECTED.
179 *
180 * @TODO PCMK_OCF_UNKNOWN should be deprecated, and an execution status of
181 * PCMK_EXEC_PENDING relied on instead (though it might be worthwhile to
182 * keep PCMK_OCF_UNKNOWN as an invalid value for initializing new action
183 * objects). However, backward compatibility must be considered (processing
184 * old saved CIB files, rolling upgrades with older DCs, older
185 * Pacemaker Remote nodes or connection hosts, and older bundles).
186 */
189
190#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
191 // Former Pacemaker extensions
199
202
205
208#endif
209};
210
237typedef enum crm_exit_e {
238 // Common convention
241
242 // LSB + OCF
249
250 // sysexits.h
266
267 // Custom
282
283 // Other
285
286 /* Anything above 128 overlaps with some shells' use of these values for
287 * "interrupted by signal N", and so may be unreliable when detected by
288 * shell scripts.
289 */
290
291 // OCF Resource Agent API 1.1
294
297
320
321 // Add new values above here then update this one below
323};
324
325const char *pcmk_rc_name(int rc);
326const char *pcmk_rc_str(int rc);
328enum ocf_exitcode pcmk_rc2ocf(int rc);
329int pcmk_rc2legacy(int rc);
330int pcmk_legacy2rc(int legacy_rc);
331const char *pcmk_strerror(int rc);
332const char *pcmk_errorname(int rc);
333const char *bz2_strerror(int rc);
335const char *crm_exit_name(crm_exit_t exit_code);
336const char *crm_exit_str(crm_exit_t exit_code);
338
339static inline const char *
340pcmk_exec_status_str(enum pcmk_exec_status status)
341{
342 switch (status) {
343 case PCMK_EXEC_PENDING: return "pending";
344 case PCMK_EXEC_DONE: return "complete";
345 case PCMK_EXEC_CANCELLED: return "Cancelled";
346 case PCMK_EXEC_TIMEOUT: return "Timed Out";
347 case PCMK_EXEC_NOT_SUPPORTED: return "NOT SUPPORTED";
348 case PCMK_EXEC_ERROR: return "Error";
349 case PCMK_EXEC_ERROR_HARD: return "Hard error";
350 case PCMK_EXEC_ERROR_FATAL: return "Fatal error";
351 case PCMK_EXEC_NOT_INSTALLED: return "Not installed";
352 case PCMK_EXEC_NOT_CONNECTED: return "Internal communication failure";
353 case PCMK_EXEC_INVALID: return "Cannot execute now";
354 case PCMK_EXEC_NO_FENCE_DEVICE: return "No fence device";
355 case PCMK_EXEC_NO_SECRETS: return "CIB secrets unavailable";
356 default: return "UNKNOWN!";
357 }
358}
359
360#ifdef __cplusplus
361}
362#endif
363
364#endif
const char * pcmk_rc_name(int rc)
Get a return code constant name as a string.
Definition: results.c:210
const char * bz2_strerror(int rc)
Definition: results.c:742
const char * pcmk_strerror(int rc)
Definition: results.c:58
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
Definition: results.c:370
crm_exit_e
Exit status codes for tools and daemons.
Definition: results.h:237
@ CRM_EX_IOERR
File I/O error.
Definition: results.h:261
@ CRM_EX_PANIC
Panic the local host.
Definition: results.h:269
@ CRM_EX_PROTOCOL
Protocol violated.
Definition: results.h:263
@ CRM_EX_NOSUCH
Requested item does not exist.
Definition: results.h:273
@ CRM_EX_DATAERR
User-supplied data incorrect.
Definition: results.h:252
@ CRM_EX_UNSATISFIED
Requested item does not satisfy constraints.
Definition: results.h:281
@ CRM_EX_UNSAFE
Requires –force or new conditions.
Definition: results.h:275
@ CRM_EX_EXISTS
Requested item already exists.
Definition: results.h:276
@ CRM_EX_TIMEOUT
Convention from timeout(1)
Definition: results.h:284
@ CRM_EX_NOT_RUNNING
Service safely stopped.
Definition: results.h:248
@ CRM_EX_MULTIPLE
Requested item has multiple matches.
Definition: results.h:277
@ CRM_EX_UNIMPLEMENT_FEATURE
Requested action not implemented.
Definition: results.h:244
@ CRM_EX_ERROR
Unspecified error.
Definition: results.h:240
@ CRM_EX_NOT_YET_IN_EFFECT
Requested item is not in effect.
Definition: results.h:279
@ CRM_EX_DEGRADED
Service active but more likely to fail soon.
Definition: results.h:292
@ CRM_EX_CANTCREAT
File couldn't be created.
Definition: results.h:260
@ CRM_EX_OLD
Update older than existing config.
Definition: results.h:271
@ CRM_EX_SOFTWARE
Internal software bug.
Definition: results.h:257
@ CRM_EX_OSFILE
System file not usable.
Definition: results.h:259
@ CRM_EX_NOHOST
Host unknown.
Definition: results.h:255
@ CRM_EX_CONFIG
Misconfiguration.
Definition: results.h:265
@ CRM_EX_NOPERM
Non-file permission issue.
Definition: results.h:264
@ CRM_EX_NOT_CONFIGURED
Parameter invalid (inherently)
Definition: results.h:247
@ CRM_EX_NOINPUT
Input file not available.
Definition: results.h:253
@ CRM_EX_UNAVAILABLE
Needed service unavailable.
Definition: results.h:256
@ CRM_EX_OSERR
External (OS/environmental) problem.
Definition: results.h:258
@ CRM_EX_DISCONNECT
Lost connection to something.
Definition: results.h:270
@ CRM_EX_FATAL
Do not respawn.
Definition: results.h:268
@ CRM_EX_DIGEST
Digest comparison failed.
Definition: results.h:272
@ CRM_EX_EXPIRED
Requested item has expired.
Definition: results.h:278
@ CRM_EX_NOUSER
User does not exist.
Definition: results.h:254
@ CRM_EX_OK
Success.
Definition: results.h:239
@ CRM_EX_DEGRADED_PROMOTED
Service promoted but more likely to fail soon.
Definition: results.h:293
@ CRM_EX_USAGE
Command line usage error.
Definition: results.h:251
@ CRM_EX_MAX
Ensure crm_exit_t can hold this.
Definition: results.h:295
@ CRM_EX_QUORUM
Local partition does not have quorum.
Definition: results.h:274
@ CRM_EX_NOT_INSTALLED
Dependencies not available locally.
Definition: results.h:246
@ CRM_EX_INVALID_PARAM
Parameter invalid (in local context)
Definition: results.h:243
@ CRM_EX_INSUFFICIENT_PRIV
Insufficient privileges.
Definition: results.h:245
@ CRM_EX_TEMPFAIL
Try again.
Definition: results.h:262
@ CRM_EX_INDETERMINATE
Could not determine status.
Definition: results.h:280
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
Definition: results.c:775
enum ocf_exitcode pcmk_rc2ocf(int rc)
Map a function return code to the most similar OCF exit code.
Definition: results.c:715
ocf_exitcode
Exit status codes for resource agents.
Definition: results.h:161
@ PCMK_OCF_INSUFFICIENT_PRIV
Insufficient privileges.
Definition: results.h:166
@ PCMK_OCF_FAILED_PROMOTED
Service failed and possibly in promoted role.
Definition: results.h:171
@ PCMK_OCF_RUNNING_PROMOTED
Service active and promoted.
Definition: results.h:170
@ PCMK_OCF_DEGRADED_MASTER
Definition: results.h:207
@ PCMK_OCF_DEGRADED_PROMOTED
Service promoted but more likely to fail soon.
Definition: results.h:173
@ PCMK_OCF_UNIMPLEMENT_FEATURE
Requested action not implemented.
Definition: results.h:165
@ PCMK_OCF_FAILED_MASTER
Definition: results.h:204
@ PCMK_OCF_NOT_CONFIGURED
Parameter invalid (inherently)
Definition: results.h:168
@ PCMK_OCF_SIGNAL
Definition: results.h:193
@ PCMK_OCF_DEGRADED
Service active but more likely to fail soon.
Definition: results.h:172
@ PCMK_OCF_NOT_INSTALLED
Dependencies not available locally.
Definition: results.h:167
@ PCMK_OCF_UNKNOWN_ERROR
Unspecified error.
Definition: results.h:163
@ PCMK_OCF_RUNNING_MASTER
Definition: results.h:201
@ PCMK_OCF_PENDING
Definition: results.h:195
@ PCMK_OCF_CANCELLED
Definition: results.h:196
@ PCMK_OCF_EXEC_ERROR
Definition: results.h:192
@ PCMK_OCF_INVALID_PARAM
Parameter invalid (in local context)
Definition: results.h:164
@ PCMK_OCF_NOT_RUNNING
Service safely stopped.
Definition: results.h:169
@ PCMK_OCF_OK
Success.
Definition: results.h:162
@ PCMK_OCF_TIMEOUT
Definition: results.h:197
@ PCMK_OCF_UNKNOWN
Action is pending.
Definition: results.h:188
@ PCMK_OCF_NOT_SUPPORTED
Definition: results.h:194
@ PCMK_OCF_CONNECTION_DIED
Definition: results.h:187
@ PCMK_OCF_OTHER_ERROR
Definition: results.h:198
pcmk_rc_e
Return codes for Pacemaker API functions.
Definition: results.h:107
@ pcmk_rc_no_input
Definition: results.h:115
@ pcmk_rc_before_range
Definition: results.h:119
@ pcmk_rc_cib_backup
Definition: results.h:133
@ pcmk_rc_ipc_pid_only
Definition: results.h:122
@ pcmk_rc_op_unsatisfied
Definition: results.h:121
@ pcmk_rc_node_unknown
Definition: results.h:137
@ pcmk_rc_transform_failed
Definition: results.h:128
@ pcmk_rc_no_output
Definition: results.h:116
@ pcmk_rc_multiple
Definition: results.h:136
@ pcmk_rc_bad_nvpair
Definition: results.h:139
@ pcmk_rc_old_data
Definition: results.h:129
@ pcmk_rc_ok
Definition: results.h:146
@ pcmk_rc_no_quorum
Definition: results.h:125
@ pcmk_rc_schema_validation
Definition: results.h:126
@ pcmk_rc_undetermined
Definition: results.h:120
@ pcmk_rc_cib_save
Definition: results.h:134
@ pcmk_rc_ipc_unauthorized
Definition: results.h:124
@ pcmk_rc_unknown_format
Definition: results.h:140
@ pcmk_rc_within_range
Definition: results.h:118
@ pcmk_rc_after_range
Definition: results.h:117
@ pcmk_rc_schema_unchanged
Definition: results.h:127
@ pcmk_rc_error
Definition: results.h:142
@ pcmk_rc_already
Definition: results.h:138
@ pcmk_rc_dot_error
Definition: results.h:113
@ pcmk_rc_diff_resync
Definition: results.h:131
@ pcmk_rc_ipc_unresponsive
Definition: results.h:123
@ pcmk_rc_invalid_transition
Definition: results.h:111
@ pcmk_rc_underflow
Definition: results.h:114
@ pcmk_rc_diff_failed
Definition: results.h:130
@ pcmk_rc_graph_error
Definition: results.h:112
@ pcmk_rc_cib_modified
Definition: results.h:132
@ pcmk_rc_cib_corrupt
Definition: results.h:135
crm_exit_t crm_errno2exit(int rc)
Definition: results.c:559
const char * crm_exit_name(crm_exit_t exit_code)
Definition: results.c:457
int pcmk_rc2legacy(int rc)
Definition: results.c:415
const char * pcmk_errorname(int rc)
Definition: results.c:32
const char * crm_exit_str(crm_exit_t exit_code)
Definition: results.c:506
pcmk_exec_status
Execution status.
Definition: results.h:305
@ PCMK_EXEC_CANCELLED
Action was cancelled.
Definition: results.h:309
@ PCMK_EXEC_NO_SECRETS
Necessary CIB secrets are unavailable.
Definition: results.h:319
@ PCMK_EXEC_ERROR_FATAL
Execution failed, do not retry anywhere.
Definition: results.h:314
@ PCMK_EXEC_NOT_INSTALLED
Agent or dependency not available locally.
Definition: results.h:315
@ PCMK_EXEC_INVALID
Action cannot be attempted (e.g. shutdown)
Definition: results.h:317
@ PCMK_EXEC_DONE
Action completed, result is known.
Definition: results.h:308
@ PCMK_EXEC_ERROR
Execution failed, may be retried.
Definition: results.h:312
@ PCMK_EXEC_NOT_SUPPORTED
Agent does not implement requested action.
Definition: results.h:311
@ PCMK_EXEC_TIMEOUT
Action did not complete in time.
Definition: results.h:310
@ PCMK_EXEC_PENDING
Action is in progress.
Definition: results.h:307
@ PCMK_EXEC_UNKNOWN
Used only to initialize variables.
Definition: results.h:306
@ PCMK_EXEC_ERROR_HARD
Execution failed, do not retry on node.
Definition: results.h:313
@ PCMK_EXEC_MAX
Maximum value for this enum.
Definition: results.h:322
@ PCMK_EXEC_NO_FENCE_DEVICE
No fence device is configured for target.
Definition: results.h:318
@ PCMK_EXEC_NOT_CONNECTED
No connection to executor.
Definition: results.h:316
int pcmk_legacy2rc(int legacy_rc)
Definition: results.c:428
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:602
#define _Noreturn
Definition: results.h:38