pacemaker  2.1.9-49aab99839
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 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
202  // Former Pacemaker extensions
210 
213 
216 
219 #endif
220 };
221 
222 // NOTE: sbd (as of at least 1.5.2) uses this
249 typedef enum crm_exit_e {
250  // Common convention
251  CRM_EX_OK = 0,
253 
254  // LSB + OCF
263 
264  // sysexits.h
280 
281  // Custom
282  CRM_EX_FATAL = 100,
283  CRM_EX_PANIC = 101,
285  CRM_EX_OLD = 103,
296 
297  // Other
299 
300  /* Anything above 128 overlaps with some shells' use of these values for
301  * "interrupted by signal N", and so may be unreliable when detected by
302  * shell scripts.
303  */
304 
305  // OCF Resource Agent API 1.1
308 
309  /* Custom
310  *
311  * This can be used to initialize exit status variables or to indicate that
312  * a command is pending (which is what the controller uses it for).
313  */
314  CRM_EX_NONE = 193,
315 
316  CRM_EX_MAX = 255,
317 } crm_exit_t;
318 
341 
342  // Add new values above here then update this one below
344 };
345 
365 };
366 
368  const char **name, const char **desc);
369 const char *pcmk_rc_name(int rc);
370 
371 // NOTE: sbd (as of at least 1.5.2) uses this
372 const char *pcmk_rc_str(int rc);
373 
374 crm_exit_t pcmk_rc2exitc(int rc);
375 enum ocf_exitcode pcmk_rc2ocf(int rc);
376 int pcmk_rc2legacy(int rc);
377 int pcmk_legacy2rc(int legacy_rc);
378 
379 // NOTE: sbd (as of at least 1.5.2) uses this
380 const char *pcmk_strerror(int rc);
381 
382 const char *pcmk_errorname(int rc);
383 const char *crm_exit_name(crm_exit_t exit_code);
384 
385 // NOTE: sbd (as of at least 1.5.2) uses this
386 const char *crm_exit_str(crm_exit_t exit_code);
387 
389 
390 /* coverity[+kill] */
391 void crm_abort(const char *file, const char *function, int line,
392  const char *condition, gboolean do_core, gboolean do_fork);
393 
394 static inline const char *
395 pcmk_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 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
421 #endif
422 
423 #endif
User does not exist.
Definition: results.h:268
const char * pcmk_errorname(int rc)
Definition: results.c:125
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:271
const char * pcmk_strerror(int rc)
Definition: results.c:151
No connection to executor.
Definition: results.h:337
Service active and promoted.
Definition: results.h:188
Requested item does not exist.
Definition: results.h:287
int pcmk_rc2legacy(int rc)
Definition: results.c:548
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
Definition: results.c:938
Dependencies not available locally.
Definition: results.h:258
const char * name
Definition: cib.c:26
Update older than existing config.
Definition: results.h:285
Could not determine status.
Definition: results.h:294
void crm_abort(const char *file, const char *function, int line, const char *condition, gboolean do_core, gboolean do_fork)
Definition: results.c:1199
Service active and promoted.
Definition: results.h:261
Service promoted but more likely to fail soon.
Definition: results.h:307
crm_exit_t pcmk_rc2exitc(int rc)
Map a function return code to the most similar exit code.
Definition: results.c:704
Service safely stopped.
Definition: results.h:186
Unspecified error.
Definition: results.h:252
Panic the local host.
Definition: results.h:283
Necessary CIB secrets are unavailable.
Definition: results.h:340
Requested item does not satisfy constraints.
Definition: results.h:295
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:265
enum crm_ais_msg_types type
Definition: cpg.c:51
Ensure crm_exit_t can hold this.
Definition: results.h:316
Action did not complete in time.
Definition: results.h:331
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
Definition: results.c:503
Execution failed, do not retry on node.
Definition: results.h:334
Non-file permission issue.
Definition: results.h:278
Action was cancelled.
Definition: results.h:330
No fence device is configured for target.
Definition: results.h:339
File I/O error.
Definition: results.h:275
pcmk_rc_e
Return codes for Pacemaker API functions.
Definition: results.h:110
Try again.
Definition: results.h:276
Maximum value for this enum.
Definition: results.h:343
const char * crm_exit_str(crm_exit_t exit_code)
Definition: results.c:642
Protocol violated.
Definition: results.h:277
User-supplied data incorrect.
Definition: results.h:266
Host unknown.
Definition: results.h:269
Requested item has multiple matches.
Definition: results.h:291
Used only to initialize variables.
Definition: results.h:327
Requested action not implemented.
Definition: results.h:256
Parameter invalid (in local context)
Definition: results.h:179
Input file not available.
Definition: results.h:267
External (OS/environmental) problem.
Definition: results.h:272
Parameter invalid (inherently)
Definition: results.h:183
Insufficient privileges.
Definition: results.h:181
Execution status.
Definition: results.h:364
Action completed, result is known.
Definition: results.h:329
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:46
Service failed and possibly promoted.
Definition: results.h:262
Success.
Definition: results.h:251
int pcmk_legacy2rc(int legacy_rc)
Definition: results.c:561
Execution failed, do not retry anywhere.
Definition: results.h:335
Dependencies not available locally.
Definition: results.h:182
System file not usable.
Definition: results.h:273
Service active but more likely to fail soon.
Definition: results.h:306
Service safely stopped.
Definition: results.h:260
Requested item has expired.
Definition: results.h:292
Unspecified error.
Definition: results.h:177
Misconfiguration.
Definition: results.h:279
Requested action not implemented.
Definition: results.h:180
Legacy API function return code.
Definition: results.h:361
Exit status code.
Definition: results.h:363
Requires –force or new conditions.
Definition: results.h:289
Service active but more likely to fail soon.
Definition: results.h:190
Agent does not implement requested action.
Definition: results.h:332
Insufficient privileges.
Definition: results.h:257
const char * pcmk_rc_name(int rc)
Get a return code constant name as a string.
Definition: results.c:343
#define _Noreturn
Definition: results.h:40
Success.
Definition: results.h:174
Needed service unavailable.
Definition: results.h:270
File couldn&#39;t be created.
Definition: results.h:274
Action is pending.
Definition: results.h:199
Local partition does not have quorum.
Definition: results.h:288
Lost connection to something.
Definition: results.h:284
Requested item is not in effect.
Definition: results.h:293
Standard Pacemaker return code.
Definition: results.h:362
No exit status available.
Definition: results.h:314
Agent or dependency not available locally.
Definition: results.h:336
Deprecated Pacemaker results API.
Action is in progress.
Definition: results.h:328
Digest comparison failed.
Definition: results.h:286
crm_exit_e
Exit status codes for tools and daemons.
Definition: results.h:249
pcmk_exec_status
Execution status.
Definition: results.h:326
Parameter invalid (in local context)
Definition: results.h:255
Convention from timeout(1)
Definition: results.h:298
Action cannot be attempted (e.g. shutdown)
Definition: results.h:338
enum ocf_exitcode pcmk_rc2ocf(int rc)
Map a function return code to the most similar OCF exit code.
Definition: results.c:832
Requested item already exists.
Definition: results.h:290
Execution failed, may be retried.
Definition: results.h:333
Do not respawn.
Definition: results.h:282
Parameter invalid (inherently)
Definition: results.h:259
const char * crm_exit_name(crm_exit_t exit_code)
Definition: results.c:590
pcmk_result_type
Types of Pacemaker result codes.
Definition: results.h:360