pacemaker  3.0.0-d8340737c4
Scalable High-Availability cluster resource manager
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 #include <glib.h> // gboolean
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
24 // Lifted from config.h
25 /* The _Noreturn keyword of C11. */
26 #ifndef _Noreturn
27 # if (defined __cplusplus \
28  && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
29  || (defined _MSC_VER && 1900 <= _MSC_VER)))
30 # define _Noreturn [[noreturn]]
31 # elif ((!defined __cplusplus || defined __clang__) \
32  && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
33  || 4 < __GNUC__ + (7 <= __GNUC_MINOR__)))
34  /* _Noreturn works as-is. */
35 # elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
36 # define _Noreturn __attribute__ ((__noreturn__))
37 # elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
38 # define _Noreturn __declspec (noreturn)
39 # else
40 # define _Noreturn
41 # endif
42 #endif
43 
44 /*
45  * Function return codes
46  *
47  * Most Pacemaker API functions return an integer return code. There are two
48  * alternative interpretations. The legacy interpration is that the absolute
49  * value of the return code is either a system error number or a custom
50  * pcmk_err_* number. This is less than ideal because system error numbers are
51  * constrained only to the positive int range, so there's the possibility that
52  * system errors and custom errors could collide (which did in fact happen
53  * already on one architecture). The new intepretation is that negative values
54  * are from the pcmk_rc_e enum, and positive values are system error numbers.
55  * Both use 0 for success.
56  *
57  * For system error codes, see:
58  * - /usr/include/asm-generic/errno.h
59  * - /usr/include/asm-generic/errno-base.h
60  */
61 
62 // Legacy custom return codes for Pacemaker API functions (deprecated)
63 
64 // NOTE: sbd (as of at least 1.5.2) uses this
65 #define pcmk_ok 0
66 
67 #define PCMK_ERROR_OFFSET 190 /* Replacements on non-linux systems, see include/portability.h */
68 #define PCMK_CUSTOM_OFFSET 200 /* Purely custom codes */
69 #define pcmk_err_generic 201
70 #define pcmk_err_no_quorum 202
71 #define pcmk_err_schema_validation 203
72 #define pcmk_err_transform_failed 204
73 #define pcmk_err_old_data 205
74 
75 // NOTE: sbd (as of at least 1.5.2) uses this
76 #define pcmk_err_diff_failed 206
77 
78 // NOTE: sbd (as of at least 1.5.2) uses this
79 #define pcmk_err_diff_resync 207
80 
81 #define pcmk_err_cib_modified 208
82 #define pcmk_err_cib_backup 209
83 #define pcmk_err_cib_save 210
84 #define pcmk_err_schema_unchanged 211
85 #define pcmk_err_cib_corrupt 212
86 #define pcmk_err_multiple 213
87 #define pcmk_err_node_unknown 214
88 #define pcmk_err_already 215
89 /* On HPPA 215 is ENOSYM (Unknown error 215), which hopefully never happens. */
90 #ifdef __hppa__
91 #define pcmk_err_bad_nvpair 250 /* 216 is ENOTSOCK */
92 #define pcmk_err_unknown_format 252 /* 217 is EDESTADDRREQ */
93 #else
94 #define pcmk_err_bad_nvpair 216
95 #define pcmk_err_unknown_format 217
96 #endif
97 
110 enum pcmk_rc_e {
111  /* When adding new values, use consecutively lower numbers, update the array
112  * in lib/common/results.c, and test with crm_error.
113  */
152  // Developers: Use a more specific code than pcmk_rc_error whenever possible
153  pcmk_rc_error = -1001,
154 
155  // Values -1 through -1000 reserved for caller use
156 
157  // NOTE: sbd (as of at least 1.5.2) uses this
159 
160  // Positive values reserved for system error numbers
161 };
162 
163 
175 
176  // NOTE: booth (as of at least 1.1) uses this value
178 
184 
185  // NOTE: booth (as of at least 1.1) uses this value
187 
192 
193  /* These two are Pacemaker extensions, not in the OCF standard. The
194  * controller records PCMK_OCF_UNKNOWN for pending actions.
195  * PCMK_OCF_CONNECTION_DIED is used only with older DCs that don't support
196  * PCMK_EXEC_NOT_CONNECTED.
197  */
200 };
201 
202 // NOTE: sbd (as of at least 1.5.2) uses this
229 typedef enum crm_exit_e {
230  // Common convention
231  CRM_EX_OK = 0,
233 
234  // LSB + OCF
243 
244  // sysexits.h
260 
261  // Custom
262  CRM_EX_FATAL = 100,
263  CRM_EX_PANIC = 101,
265  CRM_EX_OLD = 103,
276 
277  // Other
279 
280  /* Anything above 128 overlaps with some shells' use of these values for
281  * "interrupted by signal N", and so may be unreliable when detected by
282  * shell scripts.
283  */
284 
285  // OCF Resource Agent API 1.1
288 
289  /* Custom
290  *
291  * This can be used to initialize exit status variables or to indicate that
292  * a command is pending (which is what the controller uses it for).
293  */
294  CRM_EX_NONE = 193,
295 
296  CRM_EX_MAX = 255,
297 } crm_exit_t;
298 
321 
322  // Add new values above here then update this one below
324 };
325 
345 };
346 
348  const char **name, const char **desc);
349 const char *pcmk_rc_name(int rc);
350 
351 // NOTE: sbd (as of at least 1.5.2) uses this
352 const char *pcmk_rc_str(int rc);
353 
354 crm_exit_t pcmk_rc2exitc(int rc);
355 enum ocf_exitcode pcmk_rc2ocf(int rc);
356 int pcmk_rc2legacy(int rc);
357 int pcmk_legacy2rc(int legacy_rc);
358 
359 // NOTE: sbd (as of at least 1.5.2) uses this
360 const char *pcmk_strerror(int rc);
361 
362 const char *pcmk_errorname(int rc);
363 const char *crm_exit_name(crm_exit_t exit_code);
364 
365 // NOTE: sbd (as of at least 1.5.2) uses this
366 const char *crm_exit_str(crm_exit_t exit_code);
367 
369 
370 /* coverity[+kill] */
371 void crm_abort(const char *file, const char *function, int line,
372  const char *condition, gboolean do_core, gboolean do_fork);
373 
374 static inline const char *
375 pcmk_exec_status_str(enum pcmk_exec_status status)
376 {
377  switch (status) {
378  case PCMK_EXEC_PENDING: return "Pending";
379  case PCMK_EXEC_DONE: return "Done";
380  case PCMK_EXEC_CANCELLED: return "Cancelled";
381  case PCMK_EXEC_TIMEOUT: return "Timed out";
382  case PCMK_EXEC_NOT_SUPPORTED: return "Unsupported";
383  case PCMK_EXEC_ERROR: return "Error";
384  case PCMK_EXEC_ERROR_HARD: return "Hard error";
385  case PCMK_EXEC_ERROR_FATAL: return "Fatal error";
386  case PCMK_EXEC_NOT_INSTALLED: return "Not installed";
387  case PCMK_EXEC_NOT_CONNECTED: return "Internal communication failure";
388  case PCMK_EXEC_INVALID: return "Cannot execute now";
389  case PCMK_EXEC_NO_FENCE_DEVICE: return "No fence device";
390  case PCMK_EXEC_NO_SECRETS: return "CIB secrets unavailable";
391  default: return "Unrecognized status (bug?)";
392  }
393 }
394 
395 #ifdef __cplusplus
396 }
397 #endif
398 
399 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
401 #endif
402 
403 #endif
User does not exist.
Definition: results.h:248
const char * pcmk_errorname(int rc)
Definition: results.c:231
ocf_exitcode
Exit status codes for resource agents.
Definition: results.h:173
Service failed and possibly in promoted role.
Definition: results.h:189
Internal software bug.
Definition: results.h:251
const char * pcmk_strerror(int rc)
Definition: results.c:257
No connection to executor.
Definition: results.h:317
Service active and promoted.
Definition: results.h:188
Requested item does not exist.
Definition: results.h:267
int pcmk_rc2legacy(int rc)
Definition: results.c:654
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
Definition: results.c:1044
Dependencies not available locally.
Definition: results.h:238
const char * name
Definition: cib.c:26
enum pcmk_ipc_server type
Definition: cpg.c:51
Update older than existing config.
Definition: results.h:265
Could not determine status.
Definition: results.h:274
void crm_abort(const char *file, const char *function, int line, const char *condition, gboolean do_core, gboolean do_fork)
Definition: results.c:215
Service active and promoted.
Definition: results.h:241
Service promoted but more likely to fail soon.
Definition: results.h:287
crm_exit_t pcmk_rc2exitc(int rc)
Map a function return code to the most similar exit code.
Definition: results.c:810
Service safely stopped.
Definition: results.h:186
Unspecified error.
Definition: results.h:232
Panic the local host.
Definition: results.h:263
Necessary CIB secrets are unavailable.
Definition: results.h:320
Requested item does not satisfy constraints.
Definition: results.h:275
enum crm_exit_e crm_exit_t
Service promoted but more likely to fail soon.
Definition: results.h:191
Command line usage error.
Definition: results.h:245
Ensure crm_exit_t can hold this.
Definition: results.h:296
Action did not complete in time.
Definition: results.h:311
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
Definition: results.c:609
Execution failed, do not retry on node.
Definition: results.h:314
Non-file permission issue.
Definition: results.h:258
Action was cancelled.
Definition: results.h:310
No fence device is configured for target.
Definition: results.h:319
File I/O error.
Definition: results.h:255
pcmk_rc_e
Return codes for Pacemaker API functions.
Definition: results.h:110
Try again.
Definition: results.h:256
Maximum value for this enum.
Definition: results.h:323
const char * crm_exit_str(crm_exit_t exit_code)
Definition: results.c:748
Protocol violated.
Definition: results.h:257
User-supplied data incorrect.
Definition: results.h:246
Host unknown.
Definition: results.h:249
Requested item has multiple matches.
Definition: results.h:271
Used only to initialize variables.
Definition: results.h:307
Requested action not implemented.
Definition: results.h:236
Parameter invalid (in local context)
Definition: results.h:179
Input file not available.
Definition: results.h:247
External (OS/environmental) problem.
Definition: results.h:252
Parameter invalid (inherently)
Definition: results.h:183
Insufficient privileges.
Definition: results.h:181
Execution status.
Definition: results.h:344
Action completed, result is known.
Definition: results.h:309
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:42
Service failed and possibly promoted.
Definition: results.h:242
Success.
Definition: results.h:231
int pcmk_legacy2rc(int legacy_rc)
Definition: results.c:667
Execution failed, do not retry anywhere.
Definition: results.h:315
Dependencies not available locally.
Definition: results.h:182
System file not usable.
Definition: results.h:253
Service active but more likely to fail soon.
Definition: results.h:286
Service safely stopped.
Definition: results.h:240
Requested item has expired.
Definition: results.h:272
Unspecified error.
Definition: results.h:177
Misconfiguration.
Definition: results.h:259
Requested action not implemented.
Definition: results.h:180
Legacy API function return code.
Definition: results.h:341
Exit status code.
Definition: results.h:343
Requires –force or new conditions.
Definition: results.h:269
Service active but more likely to fail soon.
Definition: results.h:190
Agent does not implement requested action.
Definition: results.h:312
Insufficient privileges.
Definition: results.h:237
const char * pcmk_rc_name(int rc)
Get a return code constant name as a string.
Definition: results.c:449
#define _Noreturn
Definition: results.h:40
Success.
Definition: results.h:174
Needed service unavailable.
Definition: results.h:250
File couldn&#39;t be created.
Definition: results.h:254
Action is pending.
Definition: results.h:199
Local partition does not have quorum.
Definition: results.h:268
Lost connection to something.
Definition: results.h:264
Requested item is not in effect.
Definition: results.h:273
Standard Pacemaker return code.
Definition: results.h:342
No exit status available.
Definition: results.h:294
Agent or dependency not available locally.
Definition: results.h:316
Deprecated Pacemaker results API.
Action is in progress.
Definition: results.h:308
Digest comparison failed.
Definition: results.h:266
crm_exit_e
Exit status codes for tools and daemons.
Definition: results.h:229
pcmk_exec_status
Execution status.
Definition: results.h:306
Parameter invalid (in local context)
Definition: results.h:235
Convention from timeout(1)
Definition: results.h:278
Action cannot be attempted (e.g. shutdown)
Definition: results.h:318
enum ocf_exitcode pcmk_rc2ocf(int rc)
Map a function return code to the most similar OCF exit code.
Definition: results.c:938
Requested item already exists.
Definition: results.h:270
Execution failed, may be retried.
Definition: results.h:313
Do not respawn.
Definition: results.h:262
Parameter invalid (inherently)
Definition: results.h:239
const char * crm_exit_name(crm_exit_t exit_code)
Definition: results.c:696
pcmk_result_type
Types of Pacemaker result codes.
Definition: results.h:340