17 #include <sys/types.h> 19 #include <qb/qbdefs.h> 24 G_DEFINE_QUARK(pcmk-rc-error-quark, pcmk__rc_error)
25 G_DEFINE_QUARK(pcmk-exitc-error-quark, pcmk__exitc_error)
45 const char *code_name = NULL;
46 const char *code_desc = NULL;
127 log_assertion_as(
const char *file,
const char *
function,
int line,
128 const char *assert_condition)
133 crm_err(
"%s: Triggered fatal assertion at %s:%d : %s",
134 function, file, line, assert_condition);
151 const char *assert_condition)
153 log_assertion_as(file,
function, line, assert_condition);
171 fail_assert_as(
const char *file,
const char *
function,
int line,
172 const char *assert_condition)
184 crm_warn(
"%s: Cannot dump core for non-fatal assertion at %s:%d " 185 ": %s",
function, file, line, assert_condition);
193 crm_err(
"%s: Forked child [%d] to record non-fatal assertion at " 194 "%s:%d : %s",
function,
pid, file, line, assert_condition);
197 if (waitpid(
pid, &status, 0) ==
pid) {
200 }
while (errno == EINTR);
201 if (errno == ECHILD) {
203 crm_trace(
"Cannot wait on forked child [%d] " 204 "(SIGCHLD is probably ignored)",
pid);
206 crm_err(
"Cannot wait on forked child [%d]: %s",
215 crm_abort(
const char *file,
const char *
function,
int line,
216 const char *assert_condition, gboolean do_core, gboolean do_fork)
220 }
else if (do_core) {
221 fail_assert_as(file,
function, line, assert_condition);
223 log_assertion_as(file,
function, line, assert_condition);
268 static const struct pcmk__rc_info {
277 {
"pcmk_rc_unknown_format",
278 "Unknown output format",
281 {
"pcmk_rc_bad_nvpair",
282 "Bad name/value pair given",
286 "Already in requested state",
289 {
"pcmk_rc_node_unknown",
293 {
"pcmk_rc_multiple",
294 "Resource active on multiple nodes",
297 {
"pcmk_rc_cib_corrupt",
298 "Could not parse on-disk configuration",
301 {
"pcmk_rc_cib_save",
302 "Could not save new configuration to disk",
305 {
"pcmk_rc_cib_backup",
306 "Could not archive previous configuration",
309 {
"pcmk_rc_cib_modified",
310 "On-disk configuration was manually modified",
313 {
"pcmk_rc_diff_resync",
314 "Application of update diff failed, requesting full refresh",
317 {
"pcmk_rc_diff_failed",
318 "Application of update diff failed",
321 {
"pcmk_rc_old_data",
322 "Update was older than existing configuration",
325 {
"pcmk_rc_transform_failed",
326 "Schema transform failed",
329 {
"pcmk_rc_schema_unchanged",
330 "Schema is already the latest available",
333 {
"pcmk_rc_schema_validation",
334 "Update does not conform to the configured schema",
337 {
"pcmk_rc_no_quorum",
338 "Operation requires quorum",
341 {
"pcmk_rc_ipc_unauthorized",
342 "IPC server is blocked by unauthorized process",
345 {
"pcmk_rc_ipc_unresponsive",
346 "IPC server is unresponsive",
349 {
"pcmk_rc_ipc_pid_only",
350 "IPC server process is active but not accepting connections",
353 {
"pcmk_rc_op_unsatisfied",
354 "Not applicable under current conditions",
357 {
"pcmk_rc_undetermined",
358 "Result undetermined",
361 {
"pcmk_rc_before_range",
362 "Result occurs before given range",
365 {
"pcmk_rc_within_range",
366 "Result occurs within given range",
369 {
"pcmk_rc_after_range",
370 "Result occurs after given range",
373 {
"pcmk_rc_no_output",
374 "Output message produced no output",
377 {
"pcmk_rc_no_input",
378 "Input file not available",
381 {
"pcmk_rc_underflow",
382 "Value too small to be stored in data type",
385 {
"pcmk_rc_dot_error",
386 "Error writing dot(1) file",
389 {
"pcmk_rc_graph_error",
390 "Error writing graph file",
393 {
"pcmk_rc_invalid_transition",
394 "Cluster simulation produced invalid transition",
397 {
"pcmk_rc_unpack_error",
398 "Unable to parse CIB XML",
401 {
"pcmk_rc_duplicate_id",
402 "Two or more XML elements have the same ID",
405 {
"pcmk_rc_disabled",
409 {
"pcmk_rc_bad_input",
410 "Bad input value provided",
413 {
"pcmk_rc_bad_xml_patch",
414 "Bad XML patch format",
417 {
"pcmk_rc_no_transaction",
418 "No active transaction found",
421 {
"pcmk_rc_ns_resolution",
422 "Nameserver resolution error",
425 {
"pcmk_rc_compression",
426 "Compression/decompression error",
456 case E2BIG:
return "E2BIG";
457 case EACCES:
return "EACCES";
458 case EADDRINUSE:
return "EADDRINUSE";
459 case EADDRNOTAVAIL:
return "EADDRNOTAVAIL";
460 case EAFNOSUPPORT:
return "EAFNOSUPPORT";
461 case EAGAIN:
return "EAGAIN";
462 case EALREADY:
return "EALREADY";
463 case EBADF:
return "EBADF";
464 case EBADMSG:
return "EBADMSG";
465 case EBUSY:
return "EBUSY";
466 case ECANCELED:
return "ECANCELED";
467 case ECHILD:
return "ECHILD";
468 case ECOMM:
return "ECOMM";
469 case ECONNABORTED:
return "ECONNABORTED";
470 case ECONNREFUSED:
return "ECONNREFUSED";
471 case ECONNRESET:
return "ECONNRESET";
473 case EDESTADDRREQ:
return "EDESTADDRREQ";
474 case EDOM:
return "EDOM";
475 case EDQUOT:
return "EDQUOT";
476 case EEXIST:
return "EEXIST";
477 case EFAULT:
return "EFAULT";
478 case EFBIG:
return "EFBIG";
479 case EHOSTDOWN:
return "EHOSTDOWN";
480 case EHOSTUNREACH:
return "EHOSTUNREACH";
481 case EIDRM:
return "EIDRM";
482 case EILSEQ:
return "EILSEQ";
483 case EINPROGRESS:
return "EINPROGRESS";
484 case EINTR:
return "EINTR";
485 case EINVAL:
return "EINVAL";
486 case EIO:
return "EIO";
487 case EISCONN:
return "EISCONN";
488 case EISDIR:
return "EISDIR";
489 case ELIBACC:
return "ELIBACC";
490 case ELOOP:
return "ELOOP";
491 case EMFILE:
return "EMFILE";
492 case EMLINK:
return "EMLINK";
493 case EMSGSIZE:
return "EMSGSIZE";
494 #ifdef EMULTIHOP // Not available on OpenBSD 495 case EMULTIHOP:
return "EMULTIHOP";
497 case ENAMETOOLONG:
return "ENAMETOOLONG";
498 case ENETDOWN:
return "ENETDOWN";
499 case ENETRESET:
return "ENETRESET";
500 case ENETUNREACH:
return "ENETUNREACH";
501 case ENFILE:
return "ENFILE";
502 case ENOBUFS:
return "ENOBUFS";
503 case ENODATA:
return "ENODATA";
504 case ENODEV:
return "ENODEV";
505 case ENOENT:
return "ENOENT";
506 case ENOEXEC:
return "ENOEXEC";
507 case ENOKEY:
return "ENOKEY";
508 case ENOLCK:
return "ENOLCK";
509 #ifdef ENOLINK // Not available on OpenBSD 510 case ENOLINK:
return "ENOLINK";
512 case ENOMEM:
return "ENOMEM";
513 case ENOMSG:
return "ENOMSG";
514 case ENOPROTOOPT:
return "ENOPROTOOPT";
515 case ENOSPC:
return "ENOSPC";
517 case ENOSR:
return "ENOSR";
520 case ENOSTR:
return "ENOSTR";
522 case ENOSYS:
return "ENOSYS";
523 case ENOTBLK:
return "ENOTBLK";
524 case ENOTCONN:
return "ENOTCONN";
525 case ENOTDIR:
return "ENOTDIR";
526 case ENOTEMPTY:
return "ENOTEMPTY";
527 case ENOTSOCK:
return "ENOTSOCK";
528 #if ENOTSUP != EOPNOTSUPP 529 case ENOTSUP:
return "ENOTSUP";
531 case ENOTTY:
return "ENOTTY";
533 case ENXIO:
return "ENXIO";
534 case EOPNOTSUPP:
return "EOPNOTSUPP";
535 case EOVERFLOW:
return "EOVERFLOW";
536 case EPERM:
return "EPERM";
537 case EPFNOSUPPORT:
return "EPFNOSUPPORT";
538 case EPIPE:
return "EPIPE";
539 case EPROTO:
return "EPROTO";
540 case EPROTONOSUPPORT:
return "EPROTONOSUPPORT";
541 case EPROTOTYPE:
return "EPROTOTYPE";
542 case ERANGE:
return "ERANGE";
543 case EREMOTE:
return "EREMOTE";
545 case EROFS:
return "EROFS";
546 case ESHUTDOWN:
return "ESHUTDOWN";
547 case ESPIPE:
return "ESPIPE";
548 case ESOCKTNOSUPPORT:
return "ESOCKTNOSUPPORT";
549 case ESRCH:
return "ESRCH";
550 case ESTALE:
return "ESTALE";
551 case ETIME:
return "ETIME";
552 case ETIMEDOUT:
return "ETIMEDOUT";
553 case ETXTBSY:
return "ETXTBSY";
555 case EUNATCH:
return "EUNATCH";
557 case EUSERS:
return "EUSERS";
559 case EXDEV:
return "EXDEV";
561 #ifdef EBADE // Not available on OS X 562 case EBADE:
return "EBADE";
563 case EBADFD:
return "EBADFD";
564 case EBADSLT:
return "EBADSLT";
565 case EDEADLOCK:
return "EDEADLOCK";
566 case EBADR:
return "EBADR";
567 case EBADRQC:
return "EBADRQC";
568 case ECHRNG:
return "ECHRNG";
569 #ifdef EISNAM // Not available on OS X, Illumos, Solaris 570 case EISNAM:
return "EISNAM";
571 case EKEYEXPIRED:
return "EKEYEXPIRED";
572 case EKEYREVOKED:
return "EKEYREVOKED";
575 case EL2HLT:
return "EL2HLT";
576 case EL2NSYNC:
return "EL2NSYNC";
577 case EL3HLT:
return "EL3HLT";
578 case EL3RST:
return "EL3RST";
579 case ELIBBAD:
return "ELIBBAD";
580 case ELIBMAX:
return "ELIBMAX";
581 case ELIBSCN:
return "ELIBSCN";
582 case ELIBEXEC:
return "ELIBEXEC";
583 #ifdef ENOMEDIUM // Not available on OS X, Illumos, Solaris 584 case ENOMEDIUM:
return "ENOMEDIUM";
585 case EMEDIUMTYPE:
return "EMEDIUMTYPE";
587 case ENONET:
return "ENONET";
588 case ENOPKG:
return "ENOPKG";
589 case EREMCHG:
return "EREMCHG";
590 case ERESTART:
return "ERESTART";
591 case ESTRPIPE:
return "ESTRPIPE";
592 #ifdef EUCLEAN // Not available on OS X, Illumos, Solaris 593 case EUCLEAN:
return "EUCLEAN";
595 case EXFULL:
return "EXFULL";
597 default:
return "Unknown";
623 #ifdef PCMK__ENOTUNIQ 624 case ENOTUNIQ:
return "Name not unique on network";
627 case ECOMM:
return "Communication error on send";
630 case ELIBACC:
return "Can not access a needed shared library";
632 #ifdef PCMK__EREMOTEIO 633 case EREMOTEIO:
return "Remote I/O error";
636 case ENOKEY:
return "Required key not available";
639 case ENODATA:
return "No data available";
642 case ETIME:
return "Timer expired";
644 #ifdef PCMK__EKEYREJECTED 645 case EKEYREJECTED:
return "Key was rejected by service";
647 default:
return strerror(rc);
669 legacy_rc = abs(legacy_rc);
689 default:
return legacy_rc;
744 return "CRM_EX_UNKNOWN";
768 case CRM_EX_OSERR:
return "Operating system error occurred";
776 case CRM_EX_FATAL:
return "Fatal error occurred, will not respawn";
789 case CRM_EX_OLD:
return "Update was older than existing configuration";
793 case CRM_EX_NONE:
return "No exit status available";
796 if ((exit_code > 128) && (exit_code <
CRM_EX_MAX)) {
797 return "Interrupted by signal";
799 return "Unknown exit status";
848 case EPROTONOSUPPORT:
872 #if EOPNOTSUPP != ENOTSUP 951 #if EOPNOTSUPP != ENOTSUP 996 return ESOCKTNOSUPPORT;
1028 case BZ_DATA_ERROR_MAGIC:
1029 case BZ_UNEXPECTED_EOF:
1035 case BZ_OUTBUFF_FULL:
1049 if ((((
int) exit_status) < 0) || (((
int) exit_status) >
CRM_EX_MAX)) {
1053 crm_info(
"Exiting %s " QB_XS
" with status %d (%s: %s)",
1106 const
char *format, ...)
1110 char *reason = NULL;
1119 if (format != NULL) {
1120 va_start(ap, format);
1121 len = vasprintf(&reason, format, ap);
1189 CRM_CHECK((src != NULL) && (dst != NULL),
return);
#define pcmk_err_old_data
#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.
Dependencies not available locally.
int pcmk__result_bounds(enum pcmk_result_type type, int *lower, int *upper)
enum pcmk_ipc_server type
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.
Service promoted but more likely to fail soon.
#define pcmk_err_transform_failed
enum pcmk_exec_status execution_status
#define pcmk_err_node_unknown
Requested item does not satisfy constraints.
enum crm_exit_e crm_exit_t
void pcmk_common_cleanup(void)
Free all memory used by libcrmcommon.
Command line usage error.
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
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.
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...)
#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.
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)
crm_exit_t crm_exit(crm_exit_t exit_status)
#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)