pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
results.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012-2023 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
13 extern "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 
107 enum pcmk_rc_e {
108  /* When adding new values, use consecutively lower numbers, update the array
109  * in lib/common/results.c, and test with crm_error.
110  */
149  // Developers: Use a more specific code than pcmk_rc_error whenever possible
150  pcmk_rc_error = -1001,
151 
152  // Values -1 through -1000 reserved for caller use
153 
155 
156  // Positive values reserved for system error numbers
157 };
158 
159 
182 
183  /* These two are Pacemaker extensions, not in the OCF standard. The
184  * controller records PCMK_OCF_UNKNOWN for pending actions.
185  * PCMK_OCF_CONNECTION_DIED is used only with older DCs that don't support
186  * PCMK_EXEC_NOT_CONNECTED.
187  */
190 
191 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
192  // Former Pacemaker extensions
200 
203 
206 
209 #endif
210 };
211 
238 typedef enum crm_exit_e {
239  // Common convention
240  CRM_EX_OK = 0,
242 
243  // LSB + OCF
252 
253  // sysexits.h
269 
270  // Custom
271  CRM_EX_FATAL = 100,
272  CRM_EX_PANIC = 101,
274  CRM_EX_OLD = 103,
285 
286  // Other
288 
289  /* Anything above 128 overlaps with some shells' use of these values for
290  * "interrupted by signal N", and so may be unreliable when detected by
291  * shell scripts.
292  */
293 
294  // OCF Resource Agent API 1.1
297 
298  /* Custom
299  *
300  * This can be used to initialize exit status variables or to indicate that
301  * a command is pending (which is what the controller uses it for).
302  */
303  CRM_EX_NONE = 193,
304 
305  CRM_EX_MAX = 255,
306 } crm_exit_t;
307 
330 
331  // Add new values above here then update this one below
333 };
334 
354 };
355 
357  const char **name, const char **desc);
358 const char *pcmk_rc_name(int rc);
359 const char *pcmk_rc_str(int rc);
360 crm_exit_t pcmk_rc2exitc(int rc);
361 enum ocf_exitcode pcmk_rc2ocf(int rc);
362 int pcmk_rc2legacy(int rc);
363 int pcmk_legacy2rc(int legacy_rc);
364 const char *pcmk_strerror(int rc);
365 const char *pcmk_errorname(int rc);
366 const char *crm_exit_name(crm_exit_t exit_code);
367 const char *crm_exit_str(crm_exit_t exit_code);
369 
370 static inline const char *
371 pcmk_exec_status_str(enum pcmk_exec_status status)
372 {
373  switch (status) {
374  case PCMK_EXEC_PENDING: return "pending";
375  case PCMK_EXEC_DONE: return "complete";
376  case PCMK_EXEC_CANCELLED: return "Cancelled";
377  case PCMK_EXEC_TIMEOUT: return "Timed Out";
378  case PCMK_EXEC_NOT_SUPPORTED: return "NOT SUPPORTED";
379  case PCMK_EXEC_ERROR: return "Error";
380  case PCMK_EXEC_ERROR_HARD: return "Hard error";
381  case PCMK_EXEC_ERROR_FATAL: return "Fatal error";
382  case PCMK_EXEC_NOT_INSTALLED: return "Not installed";
383  case PCMK_EXEC_NOT_CONNECTED: return "Internal communication failure";
384  case PCMK_EXEC_INVALID: return "Cannot execute now";
385  case PCMK_EXEC_NO_FENCE_DEVICE: return "No fence device";
386  case PCMK_EXEC_NO_SECRETS: return "CIB secrets unavailable";
387  default: return "UNKNOWN!";
388  }
389 }
390 
391 #ifdef __cplusplus
392 }
393 #endif
394 
395 #endif
User does not exist.
Definition: results.h:257
const char * pcmk_errorname(int rc)
Definition: results.c:123
ocf_exitcode
Exit status codes for resource agents.
Definition: results.h:169
Service failed and possibly in promoted role.
Definition: results.h:179
Internal software bug.
Definition: results.h:260
const char * pcmk_strerror(int rc)
Definition: results.c:149
No connection to executor.
Definition: results.h:326
Service active and promoted.
Definition: results.h:178
Requested item does not exist.
Definition: results.h:276
int pcmk_rc2legacy(int rc)
Definition: results.c:546
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
Definition: results.c:936
Dependencies not available locally.
Definition: results.h:247
const char * name
Definition: cib.c:26
Update older than existing config.
Definition: results.h:274
Could not determine status.
Definition: results.h:283
Service active and promoted.
Definition: results.h:250
Service promoted but more likely to fail soon.
Definition: results.h:296
crm_exit_t pcmk_rc2exitc(int rc)
Map a function return code to the most similar exit code.
Definition: results.c:702
Service safely stopped.
Definition: results.h:177
Unspecified error.
Definition: results.h:241
Panic the local host.
Definition: results.h:272
Necessary CIB secrets are unavailable.
Definition: results.h:329
Requested item does not satisfy constraints.
Definition: results.h:284
enum crm_exit_e crm_exit_t
Service promoted but more likely to fail soon.
Definition: results.h:181
Command line usage error.
Definition: results.h:254
enum crm_ais_msg_types type
Definition: cpg.c:48
Ensure crm_exit_t can hold this.
Definition: results.h:305
Action did not complete in time.
Definition: results.h:320
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
Definition: results.c:501
Execution failed, do not retry on node.
Definition: results.h:323
Non-file permission issue.
Definition: results.h:267
Action was cancelled.
Definition: results.h:319
No fence device is configured for target.
Definition: results.h:328
File I/O error.
Definition: results.h:264
pcmk_rc_e
Return codes for Pacemaker API functions.
Definition: results.h:107
Try again.
Definition: results.h:265
Maximum value for this enum.
Definition: results.h:332
const char * crm_exit_str(crm_exit_t exit_code)
Definition: results.c:640
Protocol violated.
Definition: results.h:266
User-supplied data incorrect.
Definition: results.h:255
Host unknown.
Definition: results.h:258
Requested item has multiple matches.
Definition: results.h:280
Used only to initialize variables.
Definition: results.h:316
Requested action not implemented.
Definition: results.h:245
Parameter invalid (in local context)
Definition: results.h:172
Input file not available.
Definition: results.h:256
External (OS/environmental) problem.
Definition: results.h:261
Parameter invalid (inherently)
Definition: results.h:176
Insufficient privileges.
Definition: results.h:174
Execution status.
Definition: results.h:353
Action completed, result is known.
Definition: results.h:318
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
Service failed and possibly promoted.
Definition: results.h:251
Success.
Definition: results.h:240
int pcmk_legacy2rc(int legacy_rc)
Definition: results.c:559
Execution failed, do not retry anywhere.
Definition: results.h:324
Dependencies not available locally.
Definition: results.h:175
System file not usable.
Definition: results.h:262
Service active but more likely to fail soon.
Definition: results.h:295
Service safely stopped.
Definition: results.h:249
Requested item has expired.
Definition: results.h:281
Unspecified error.
Definition: results.h:171
Misconfiguration.
Definition: results.h:268
Requested action not implemented.
Definition: results.h:173
Legacy API function return code.
Definition: results.h:350
Exit status code.
Definition: results.h:352
Requires –force or new conditions.
Definition: results.h:278
Service active but more likely to fail soon.
Definition: results.h:180
Agent does not implement requested action.
Definition: results.h:321
Insufficient privileges.
Definition: results.h:246
const char * pcmk_rc_name(int rc)
Get a return code constant name as a string.
Definition: results.c:341
#define _Noreturn
Definition: results.h:38
Success.
Definition: results.h:170
Needed service unavailable.
Definition: results.h:259
File couldn&#39;t be created.
Definition: results.h:263
Action is pending.
Definition: results.h:189
Local partition does not have quorum.
Definition: results.h:277
Lost connection to something.
Definition: results.h:273
Requested item is not in effect.
Definition: results.h:282
Standard Pacemaker return code.
Definition: results.h:351
No exit status available.
Definition: results.h:303
Agent or dependency not available locally.
Definition: results.h:325
Action is in progress.
Definition: results.h:317
Digest comparison failed.
Definition: results.h:275
crm_exit_e
Exit status codes for tools and daemons.
Definition: results.h:238
pcmk_exec_status
Execution status.
Definition: results.h:315
Parameter invalid (in local context)
Definition: results.h:244
Convention from timeout(1)
Definition: results.h:287
Action cannot be attempted (e.g. shutdown)
Definition: results.h:327
enum ocf_exitcode pcmk_rc2ocf(int rc)
Map a function return code to the most similar OCF exit code.
Definition: results.c:830
Requested item already exists.
Definition: results.h:279
Execution failed, may be retried.
Definition: results.h:322
Do not respawn.
Definition: results.h:271
Parameter invalid (inherently)
Definition: results.h:248
const char * crm_exit_name(crm_exit_t exit_code)
Definition: results.c:588
pcmk_result_type
Types of Pacemaker result codes.
Definition: results.h:349