21 #include <sys/types.h> 23 #include <qb/qbdefs.h> 28 G_DEFINE_QUARK(pcmk-rc-error-quark, pcmk__rc_error)
29 G_DEFINE_QUARK(pcmk-exitc-error-quark, pcmk__exitc_error)
49 const char *code_name = NULL;
50 const char *code_desc = NULL;
162 static const struct pcmk__rc_info {
171 {
"pcmk_rc_unknown_format",
172 "Unknown output format",
175 {
"pcmk_rc_bad_nvpair",
176 "Bad name/value pair given",
180 "Already in requested state",
183 {
"pcmk_rc_node_unknown",
187 {
"pcmk_rc_multiple",
188 "Resource active on multiple nodes",
191 {
"pcmk_rc_cib_corrupt",
192 "Could not parse on-disk configuration",
195 {
"pcmk_rc_cib_save",
196 "Could not save new configuration to disk",
199 {
"pcmk_rc_cib_backup",
200 "Could not archive previous configuration",
203 {
"pcmk_rc_cib_modified",
204 "On-disk configuration was manually modified",
207 {
"pcmk_rc_diff_resync",
208 "Application of update diff failed, requesting full refresh",
211 {
"pcmk_rc_diff_failed",
212 "Application of update diff failed",
215 {
"pcmk_rc_old_data",
216 "Update was older than existing configuration",
219 {
"pcmk_rc_transform_failed",
220 "Schema transform failed",
223 {
"pcmk_rc_schema_unchanged",
224 "Schema is already the latest available",
227 {
"pcmk_rc_schema_validation",
228 "Update does not conform to the configured schema",
231 {
"pcmk_rc_no_quorum",
232 "Operation requires quorum",
235 {
"pcmk_rc_ipc_unauthorized",
236 "IPC server is blocked by unauthorized process",
239 {
"pcmk_rc_ipc_unresponsive",
240 "IPC server is unresponsive",
243 {
"pcmk_rc_ipc_pid_only",
244 "IPC server process is active but not accepting connections",
247 {
"pcmk_rc_op_unsatisfied",
248 "Not applicable under current conditions",
251 {
"pcmk_rc_undetermined",
252 "Result undetermined",
255 {
"pcmk_rc_before_range",
256 "Result occurs before given range",
259 {
"pcmk_rc_within_range",
260 "Result occurs within given range",
263 {
"pcmk_rc_after_range",
264 "Result occurs after given range",
267 {
"pcmk_rc_no_output",
268 "Output message produced no output",
271 {
"pcmk_rc_no_input",
272 "Input file not available",
275 {
"pcmk_rc_underflow",
276 "Value too small to be stored in data type",
279 {
"pcmk_rc_dot_error",
280 "Error writing dot(1) file",
283 {
"pcmk_rc_graph_error",
284 "Error writing graph file",
287 {
"pcmk_rc_invalid_transition",
288 "Cluster simulation produced invalid transition",
291 {
"pcmk_rc_unpack_error",
292 "Unable to parse CIB XML",
295 {
"pcmk_rc_duplicate_id",
296 "Two or more XML elements have the same ID",
299 {
"pcmk_rc_disabled",
303 {
"pcmk_rc_bad_input",
304 "Bad input value provided",
307 {
"pcmk_rc_bad_xml_patch",
308 "Bad XML patch format",
311 {
"pcmk_rc_no_transaction",
312 "No active transaction found",
315 {
"pcmk_rc_ns_resolution",
316 "Nameserver resolution error",
319 {
"pcmk_rc_compression",
320 "Compression/decompression error",
350 case E2BIG:
return "E2BIG";
351 case EACCES:
return "EACCES";
352 case EADDRINUSE:
return "EADDRINUSE";
353 case EADDRNOTAVAIL:
return "EADDRNOTAVAIL";
354 case EAFNOSUPPORT:
return "EAFNOSUPPORT";
355 case EAGAIN:
return "EAGAIN";
356 case EALREADY:
return "EALREADY";
357 case EBADF:
return "EBADF";
358 case EBADMSG:
return "EBADMSG";
359 case EBUSY:
return "EBUSY";
360 case ECANCELED:
return "ECANCELED";
361 case ECHILD:
return "ECHILD";
362 case ECOMM:
return "ECOMM";
363 case ECONNABORTED:
return "ECONNABORTED";
364 case ECONNREFUSED:
return "ECONNREFUSED";
365 case ECONNRESET:
return "ECONNRESET";
367 case EDESTADDRREQ:
return "EDESTADDRREQ";
368 case EDOM:
return "EDOM";
369 case EDQUOT:
return "EDQUOT";
370 case EEXIST:
return "EEXIST";
371 case EFAULT:
return "EFAULT";
372 case EFBIG:
return "EFBIG";
373 case EHOSTDOWN:
return "EHOSTDOWN";
374 case EHOSTUNREACH:
return "EHOSTUNREACH";
375 case EIDRM:
return "EIDRM";
376 case EILSEQ:
return "EILSEQ";
377 case EINPROGRESS:
return "EINPROGRESS";
378 case EINTR:
return "EINTR";
379 case EINVAL:
return "EINVAL";
380 case EIO:
return "EIO";
381 case EISCONN:
return "EISCONN";
382 case EISDIR:
return "EISDIR";
383 case ELIBACC:
return "ELIBACC";
384 case ELOOP:
return "ELOOP";
385 case EMFILE:
return "EMFILE";
386 case EMLINK:
return "EMLINK";
387 case EMSGSIZE:
return "EMSGSIZE";
388 #ifdef EMULTIHOP // Not available on OpenBSD 389 case EMULTIHOP:
return "EMULTIHOP";
391 case ENAMETOOLONG:
return "ENAMETOOLONG";
392 case ENETDOWN:
return "ENETDOWN";
393 case ENETRESET:
return "ENETRESET";
394 case ENETUNREACH:
return "ENETUNREACH";
395 case ENFILE:
return "ENFILE";
396 case ENOBUFS:
return "ENOBUFS";
397 case ENODATA:
return "ENODATA";
398 case ENODEV:
return "ENODEV";
399 case ENOENT:
return "ENOENT";
400 case ENOEXEC:
return "ENOEXEC";
401 case ENOKEY:
return "ENOKEY";
402 case ENOLCK:
return "ENOLCK";
403 #ifdef ENOLINK // Not available on OpenBSD 404 case ENOLINK:
return "ENOLINK";
406 case ENOMEM:
return "ENOMEM";
407 case ENOMSG:
return "ENOMSG";
408 case ENOPROTOOPT:
return "ENOPROTOOPT";
409 case ENOSPC:
return "ENOSPC";
411 case ENOSR:
return "ENOSR";
414 case ENOSTR:
return "ENOSTR";
416 case ENOSYS:
return "ENOSYS";
417 case ENOTBLK:
return "ENOTBLK";
418 case ENOTCONN:
return "ENOTCONN";
419 case ENOTDIR:
return "ENOTDIR";
420 case ENOTEMPTY:
return "ENOTEMPTY";
421 case ENOTSOCK:
return "ENOTSOCK";
422 #if ENOTSUP != EOPNOTSUPP 423 case ENOTSUP:
return "ENOTSUP";
425 case ENOTTY:
return "ENOTTY";
427 case ENXIO:
return "ENXIO";
428 case EOPNOTSUPP:
return "EOPNOTSUPP";
429 case EOVERFLOW:
return "EOVERFLOW";
430 case EPERM:
return "EPERM";
431 case EPFNOSUPPORT:
return "EPFNOSUPPORT";
432 case EPIPE:
return "EPIPE";
433 case EPROTO:
return "EPROTO";
434 case EPROTONOSUPPORT:
return "EPROTONOSUPPORT";
435 case EPROTOTYPE:
return "EPROTOTYPE";
436 case ERANGE:
return "ERANGE";
437 case EREMOTE:
return "EREMOTE";
439 case EROFS:
return "EROFS";
440 case ESHUTDOWN:
return "ESHUTDOWN";
441 case ESPIPE:
return "ESPIPE";
442 case ESOCKTNOSUPPORT:
return "ESOCKTNOSUPPORT";
443 case ESRCH:
return "ESRCH";
444 case ESTALE:
return "ESTALE";
445 case ETIME:
return "ETIME";
446 case ETIMEDOUT:
return "ETIMEDOUT";
447 case ETXTBSY:
return "ETXTBSY";
449 case EUNATCH:
return "EUNATCH";
451 case EUSERS:
return "EUSERS";
453 case EXDEV:
return "EXDEV";
455 #ifdef EBADE // Not available on OS X 456 case EBADE:
return "EBADE";
457 case EBADFD:
return "EBADFD";
458 case EBADSLT:
return "EBADSLT";
459 case EDEADLOCK:
return "EDEADLOCK";
460 case EBADR:
return "EBADR";
461 case EBADRQC:
return "EBADRQC";
462 case ECHRNG:
return "ECHRNG";
463 #ifdef EISNAM // Not available on OS X, Illumos, Solaris 464 case EISNAM:
return "EISNAM";
465 case EKEYEXPIRED:
return "EKEYEXPIRED";
466 case EKEYREVOKED:
return "EKEYREVOKED";
469 case EL2HLT:
return "EL2HLT";
470 case EL2NSYNC:
return "EL2NSYNC";
471 case EL3HLT:
return "EL3HLT";
472 case EL3RST:
return "EL3RST";
473 case ELIBBAD:
return "ELIBBAD";
474 case ELIBMAX:
return "ELIBMAX";
475 case ELIBSCN:
return "ELIBSCN";
476 case ELIBEXEC:
return "ELIBEXEC";
477 #ifdef ENOMEDIUM // Not available on OS X, Illumos, Solaris 478 case ENOMEDIUM:
return "ENOMEDIUM";
479 case EMEDIUMTYPE:
return "EMEDIUMTYPE";
481 case ENONET:
return "ENONET";
482 case ENOPKG:
return "ENOPKG";
483 case EREMCHG:
return "EREMCHG";
484 case ERESTART:
return "ERESTART";
485 case ESTRPIPE:
return "ESTRPIPE";
486 #ifdef EUCLEAN // Not available on OS X, Illumos, Solaris 487 case EUCLEAN:
return "EUCLEAN";
489 case EXFULL:
return "EXFULL";
491 default:
return "Unknown";
517 #ifdef PCMK__ENOTUNIQ 518 case ENOTUNIQ:
return "Name not unique on network";
521 case ECOMM:
return "Communication error on send";
524 case ELIBACC:
return "Can not access a needed shared library";
526 #ifdef PCMK__EREMOTEIO 527 case EREMOTEIO:
return "Remote I/O error";
530 case ENOKEY:
return "Required key not available";
533 case ENODATA:
return "No data available";
536 case ETIME:
return "Timer expired";
538 #ifdef PCMK__EKEYREJECTED 539 case EKEYREJECTED:
return "Key was rejected by service";
541 default:
return strerror(rc);
563 legacy_rc = abs(legacy_rc);
583 default:
return legacy_rc;
638 return "CRM_EX_UNKNOWN";
662 case CRM_EX_OSERR:
return "Operating system error occurred";
670 case CRM_EX_FATAL:
return "Fatal error occurred, will not respawn";
683 case CRM_EX_OLD:
return "Update was older than existing configuration";
687 case CRM_EX_NONE:
return "No exit status available";
690 if ((exit_code > 128) && (exit_code <
CRM_EX_MAX)) {
691 return "Interrupted by signal";
693 return "Unknown exit status";
742 case EPROTONOSUPPORT:
766 #if EOPNOTSUPP != ENOTSUP 845 #if EOPNOTSUPP != ENOTSUP 890 return ESOCKTNOSUPPORT;
922 case BZ_DATA_ERROR_MAGIC:
923 case BZ_UNEXPECTED_EOF:
929 case BZ_OUTBUFF_FULL:
943 if ((((
int) rc) < 0) || (((
int) rc) >
CRM_EX_MAX)) {
1010 const
char *format, ...)
1014 char *reason = NULL;
1023 if (format != NULL) {
1024 va_start(ap, format);
1025 len = vasprintf(&reason, format, ap);
1093 CRM_CHECK((src != NULL) && (dst != NULL),
return);
1111 log_assertion_as(
const char *file,
const char *
function,
int line,
1112 const char *assert_condition)
1117 crm_err(
"%s: Triggered fatal assertion at %s:%d : %s",
1118 function, file, line, assert_condition);
1135 const char *assert_condition)
1137 log_assertion_as(file,
function, line, assert_condition);
1155 fail_assert_as(
const char *file,
const char *
function,
int line,
1156 const char *assert_condition)
1168 crm_warn(
"%s: Cannot dump core for non-fatal assertion at %s:%d " 1169 ": %s",
function, file, line, assert_condition);
1177 crm_err(
"%s: Forked child [%d] to record non-fatal assertion at " 1178 "%s:%d : %s",
function,
pid, file, line, assert_condition);
1181 if (waitpid(
pid, &status, 0) ==
pid) {
1184 }
while (errno == EINTR);
1185 if (errno == ECHILD) {
1187 crm_trace(
"Cannot wait on forked child [%d] " 1188 "(SIGCHLD is probably ignored)",
pid);
1190 crm_err(
"Cannot wait on forked child [%d]: %s",
1200 const char *assert_condition, gboolean do_core, gboolean do_fork)
1204 }
else if (do_core) {
1205 fail_assert_as(file,
function, line, assert_condition);
1207 log_assertion_as(file,
function, line, assert_condition);
1227 case BZ_CONFIG_ERROR:
1228 return "libbz2 has been improperly compiled on your platform";
1229 case BZ_SEQUENCE_ERROR:
1230 return "library functions called in the wrong order";
1231 case BZ_PARAM_ERROR:
1232 return "parameter is out of range or otherwise incorrect";
1234 return "memory allocation failed";
1236 return "data integrity error is detected during decompression";
1237 case BZ_DATA_ERROR_MAGIC:
1238 return "the compressed stream does not start with the correct magic bytes";
1240 return "error reading or writing in the compressed file";
1241 case BZ_UNEXPECTED_EOF:
1242 return "compressed file finishes before the logical end of stream is detected";
1243 case BZ_OUTBUFF_FULL:
1244 return "output data will not fit into the buffer provided";
1246 return "Data compression error";
#define pcmk_err_old_data
const char * bz2_strerror(int rc)
#define CRM_CHECK(expr, failure_action)
#define pcmk_err_schema_validation
ocf_exitcode
Exit status codes for resource agents.
crm_exit_t pcmk_rc2exitc(int rc)
Map a function return code to the most similar exit code.
void crm_enable_stderr(int enable)
#define pcmk_err_no_quorum
#define pcmk_err_schema_unchanged
Requested item does not exist.
crm_exit_t crm_errno2exit(int rc)
Dependencies not available locally.
int pcmk__result_bounds(enum pcmk_result_type type, int *lower, int *upper)
const char * crm_exit_name(crm_exit_t exit_code)
int pcmk_rc2legacy(int rc)
Update older than existing config.
Could not determine status.
Service active and promoted.
void crm_xml_cleanup(void)
Service promoted but more likely to fail soon.
#define pcmk_err_transform_failed
enum pcmk_exec_status execution_status
#define pcmk_err_node_unknown
void mainloop_cleanup(void)
Requested item does not satisfy constraints.
enum crm_exit_e crm_exit_t
Command line usage error.
enum crm_ais_msg_types type
int pcmk__gaierror2rc(int gai)
Map a getaddrinfo() return code to the most similar Pacemaker return code.
Ensure crm_exit_t can hold this.
#define pcmk_err_cib_backup
void pcmk__free_common_logger(void)
Non-file permission issue.
Wrappers for and extensions to glib mainloop.
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
enum ocf_exitcode pcmk_rc2ocf(int rc)
Map a function return code to the most similar OCF exit code.
void pcmk__set_result_output(pcmk__action_result_t *result, char *out, char *err)
#define crm_warn(fmt, args...)
#define pcmk_err_cib_save
#define pcmk_err_diff_failed
User-supplied data incorrect.
Requested item has multiple matches.
int pcmk_legacy2rc(int legacy_rc)
void pcmk__copy_result(const pcmk__action_result_t *src, pcmk__action_result_t *dst)
#define pcmk_err_multiple
Requested action not implemented.
Parameter invalid (in local context)
const char * crm_exit_str(crm_exit_t exit_code)
Input file not available.
crm_exit_t crm_exit(crm_exit_t rc)
External (OS/environmental) problem.
#define crm_trace(fmt, args...)
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.
Wrappers for and extensions to libxml2.
Service failed and possibly promoted.
#define pcmk_err_cib_modified
void crm_abort(const char *file, const char *function, int line, const char *assert_condition, gboolean do_core, gboolean do_fork)
Service active but more likely to fail soon.
#define pcmk__str_copy(str)
void crm_write_blackbox(int nsig, const struct qb_log_callsite *callsite)
Requested item has expired.
#define pcmk__assert(expr)
void pcmk__reset_result(pcmk__action_result_t *result)
Requested action not implemented.
Legacy API function return code.
void pcmk__format_result(pcmk__action_result_t *result, int exit_status, enum pcmk_exec_status exec_status, const char *format,...)
Requires –force or new conditions.
_Noreturn void pcmk__abort_as(const char *file, const char *function, int line, const char *assert_condition)
#define pcmk_err_diff_resync
pcmk__action_result_t result
#define crm_err(fmt, args...)
char * pcmk__our_nodename
Node name of the local node.
#define pcmk_err_unknown_format
Needed service unavailable.
File couldn't be created.
const char * pcmk_rc_name(int rc)
Get a return code constant name as a string.
Local partition does not have quorum.
Lost connection to something.
Requested item is not in effect.
Standard Pacemaker return code.
No exit status available.
Deprecated Pacemaker results API.
Digest comparison failed.
pcmk_exec_status
Execution status.
Parameter invalid (in local context)
int pcmk__bzlib2rc(int bz2)
Map a bz2 return code to the most similar Pacemaker return code.
Convention from timeout(1)
const char * pcmk_strerror(int rc)
#define pcmk_err_bad_nvpair
#define pcmk_err_cib_corrupt
Requested item already exists.
#define crm_info(fmt, args...)
Parameter invalid (inherently)
const char * pcmk_errorname(int rc)
pcmk_result_type
Types of Pacemaker result codes.
void pcmk__set_result(pcmk__action_result_t *result, int exit_status, enum pcmk_exec_status exec_status, const char *exit_reason)