diff --git a/include/crm/common/actions.h b/include/crm/common/actions.h index 38307c7292..69881f591d 100644 --- a/include/crm/common/actions.h +++ b/include/crm/common/actions.h @@ -1,168 +1,207 @@ /* * Copyright 2004-2023 the Pacemaker project contributors * * The version control history for this file may have further details. * * This source code is licensed under the GNU Lesser General Public License * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY. */ #ifndef PCMK__CRM_COMMON_ACTIONS__H #define PCMK__CRM_COMMON_ACTIONS__H #include // bool #include // strcasecmp() #include // gboolean, guint #include // xmlNode #include // lrmd_event_data_t #ifdef __cplusplus extern "C" { #endif /*! * \file * \brief APIs related to actions * \ingroup core */ //! Default timeout (in milliseconds) for non-metadata actions #define PCMK_DEFAULT_ACTION_TIMEOUT_MS 20000 // @COMPAT We don't need a separate timeout for metadata, much less a longer one //! \deprecated Default timeout (in milliseconds) for metadata actions #define PCMK_DEFAULT_METADATA_TIMEOUT_MS 30000 // Action names as strings #define PCMK_ACTION_CANCEL "cancel" #define PCMK_ACTION_CLEAR_FAILCOUNT "clear_failcount" #define PCMK_ACTION_CLONE_ONE_OR_MORE "clone-one-or-more" #define PCMK_ACTION_DELETE "delete" #define PCMK_ACTION_DEMOTE "demote" #define PCMK_ACTION_DEMOTED "demoted" #define PCMK_ACTION_DO_SHUTDOWN "do_shutdown" #define PCMK_ACTION_LIST "list" #define PCMK_ACTION_LRM_DELETE "lrm_delete" #define PCMK_ACTION_LOAD_STOPPED "load_stopped" #define PCMK_ACTION_MAINTENANCE_NODES "maintenance_nodes" #define PCMK_ACTION_META_DATA "meta-data" #define PCMK_ACTION_MIGRATE_FROM "migrate_from" #define PCMK_ACTION_MIGRATE_TO "migrate_to" #define PCMK_ACTION_MONITOR "monitor" #define PCMK_ACTION_NOTIFIED "notified" #define PCMK_ACTION_NOTIFY "notify" #define PCMK_ACTION_OFF "off" #define PCMK_ACTION_ON "on" #define PCMK_ACTION_ONE_OR_MORE "one-or-more" #define PCMK_ACTION_PROMOTE "promote" #define PCMK_ACTION_PROMOTED "promoted" #define PCMK_ACTION_REBOOT "reboot" #define PCMK_ACTION_RELOAD "reload" #define PCMK_ACTION_RELOAD_AGENT "reload-agent" #define PCMK_ACTION_RUNNING "running" #define PCMK_ACTION_START "start" #define PCMK_ACTION_STATUS "status" #define PCMK_ACTION_STONITH "stonith" #define PCMK_ACTION_STOP "stop" #define PCMK_ACTION_STOPPED "stopped" #define PCMK_ACTION_VALIDATE_ALL "validate-all" //! Possible actions (including some pseudo-actions) enum action_tasks { pcmk_action_unspecified = 0, //!< Unspecified or unknown action pcmk_action_monitor, //!< Monitor // Each "completed" action must be the regular action plus 1 pcmk_action_stop, //!< Stop pcmk_action_stopped, //!< Stop completed pcmk_action_start, //!< Start pcmk_action_started, //!< Start completed pcmk_action_notify, //!< Notify pcmk_action_notified, //!< Notify completed pcmk_action_promote, //!< Promote pcmk_action_promoted, //!< Promoted pcmk_action_demote, //!< Demote pcmk_action_demoted, //!< Demoted pcmk_action_shutdown, //!< Shut down node pcmk_action_fence, //!< Fence node #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) //! \deprecated Use pcmk_action_unspecified instead no_action = pcmk_action_unspecified, //! \deprecated Use pcmk_action_monitor instead monitor_rsc = pcmk_action_monitor, //! \deprecated Use pcmk_action_stop instead stop_rsc = pcmk_action_stop, //! \deprecated Use pcmk_action_stopped instead stopped_rsc = pcmk_action_stopped, //! \deprecated Use pcmk_action_start instead start_rsc = pcmk_action_start, //! \deprecated Use pcmk_action_started instead started_rsc = pcmk_action_started, //! \deprecated Use pcmk_action_notify instead action_notify = pcmk_action_notify, //! \deprecated Use pcmk_action_notified instead action_notified = pcmk_action_notified, //! \deprecated Use pcmk_action_promote instead action_promote = pcmk_action_promote, //! \deprecated Use pcmk_action_promoted instead action_promoted = pcmk_action_promoted, //! \deprecated Use pcmk_action_demote instead action_demote = pcmk_action_demote, //! \deprecated Use pcmk_action_demoted instead action_demoted = pcmk_action_demoted, //! \deprecated Use pcmk_action_shutdown instead shutdown_crm = pcmk_action_shutdown, //! \deprecated Use pcmk_action_fence instead stonith_node = pcmk_action_fence, #endif }; +//! Possible responses to a resource action failure +enum action_fail_response { + /* The order is (partially) significant here; the values from + * action_fail_ignore through action_fail_fence are in order of increasing + * severity. + * + * @COMPAT The values should be ordered and numbered per the "TODO" comments + * below, so all values are in order of severity and there is room for + * future additions, but that would break API compatibility. + * @TODO For now, we just use a function to compare the values specially, but + * at the next compatibility break, we should arrange things properly. + */ + + action_fail_ignore, // @TODO = 10 + // @TODO action_fail_demote = 20, + action_fail_recover, // @TODO = 30 + // @TODO action_fail_reset_remote = 40, + // @TODO action_fail_restart_container = 50, + action_fail_migrate, // @TODO = 60 + action_fail_block, // @TODO = 70 + action_fail_stop, // @TODO = 80 + action_fail_standby, // @TODO = 90 + action_fail_fence, // @TODO = 100 + + // @COMPAT Values below here are out of order for API compatibility + + action_fail_restart_container, + + /* This is reserved for internal use for remote node connection resources. + * Fence the remote node if stonith is enabled, otherwise attempt to recover + * the connection resource. This allows us to specify types of connection + * resource failures that should result in fencing the remote node + * (for example, recurring monitor failures). + */ + action_fail_reset_remote, + + action_fail_demote, +}; + // For parsing various action-related string specifications gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, guint *interval_ms); gboolean decode_transition_key(const char *key, char **uuid, int *transition_id, int *action_id, int *target_rc); gboolean decode_transition_magic(const char *magic, char **uuid, int *transition_id, int *action_id, int *op_status, int *op_rc, int *target_rc); // @COMPAT Either these shouldn't be in libcrmcommon or lrmd_event_data_t should int rsc_op_expected_rc(const lrmd_event_data_t *event); gboolean did_rsc_op_fail(lrmd_event_data_t *event, int target_rc); bool crm_op_needs_metadata(const char *rsc_class, const char *op); xmlNode *crm_create_op_xml(xmlNode *parent, const char *prefix, const char *task, const char *interval_spec, const char *timeout); bool pcmk_is_probe(const char *task, guint interval); bool pcmk_xe_is_probe(const xmlNode *xml_op); bool pcmk_xe_mask_probe_failure(const xmlNode *xml_op); #ifdef __cplusplus } #endif #endif // PCMK__CRM_COMMON_ACTIONS__H diff --git a/include/crm/pengine/common.h b/include/crm/pengine/common.h index 90fc7286d1..af65e57792 100644 --- a/include/crm/pengine/common.h +++ b/include/crm/pengine/common.h @@ -1,152 +1,116 @@ /* * Copyright 2004-2023 the Pacemaker project contributors * * The version control history for this file may have further details. * * This source code is licensed under the GNU Lesser General Public License * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY. */ #ifndef PCMK__CRM_PENGINE_COMMON__H # define PCMK__CRM_PENGINE_COMMON__H # include # include # include # include #ifdef __cplusplus extern "C" { #endif extern gboolean was_processing_error; extern gboolean was_processing_warning; -/* The order is (partially) significant here; the values from action_fail_ignore - * through action_fail_fence are in order of increasing severity. - * - * @COMPAT The values should be ordered and numbered per the "TODO" comments - * below, so all values are in order of severity and there is room for - * future additions, but that would break API compatibility. - * @TODO For now, we just use a function to compare the values specially, but - * at the next compatibility break, we should arrange things properly. - */ -enum action_fail_response { - action_fail_ignore, // @TODO = 10 - // @TODO action_fail_demote = 20, - action_fail_recover, // @TODO = 30 - // @TODO action_fail_reset_remote = 40, - // @TODO action_fail_restart_container = 50, - action_fail_migrate, // @TODO = 60 - action_fail_block, // @TODO = 70 - action_fail_stop, // @TODO = 80 - action_fail_standby, // @TODO = 90 - action_fail_fence, // @TODO = 100 - - // @COMPAT Values below here are out of order for API compatibility - - action_fail_restart_container, - - /* This is reserved for internal use for remote node connection resources. - * Fence the remote node if stonith is enabled, otherwise attempt to recover - * the connection resource. This allows us to specify types of connection - * resource failures that should result in fencing the remote node - * (for example, recurring monitor failures). - */ - action_fail_reset_remote, - - action_fail_demote, -}; - //! Deprecated enum pe_print_options { pe_print_log = (1 << 0), pe_print_html = (1 << 1), pe_print_ncurses = (1 << 2), pe_print_printf = (1 << 3), pe_print_dev = (1 << 4), //! Ignored pe_print_details = (1 << 5), //! Ignored pe_print_max_details = (1 << 6), //! Ignored pe_print_rsconly = (1 << 7), pe_print_ops = (1 << 8), pe_print_suppres_nl = (1 << 9), pe_print_xml = (1 << 10), pe_print_brief = (1 << 11), pe_print_pending = (1 << 12), pe_print_clone_details = (1 << 13), pe_print_clone_active = (1 << 14), // Print clone instances only if active pe_print_implicit = (1 << 15) // Print implicitly created resources }; const char *task2text(enum action_tasks task); enum action_tasks text2task(const char *task); enum rsc_role_e text2role(const char *role); const char *role2text(enum rsc_role_e role); const char *fail2text(enum action_fail_response fail); const char *pe_pref(GHashTable * options, const char *name); /*! * \brief Get readable description of a recovery type * * \param[in] type Recovery type * * \return Static string describing \p type */ static inline const char * recovery2text(enum rsc_recovery_type type) { switch (type) { case pcmk_multiply_active_stop: return "shutting it down"; case pcmk_multiply_active_restart: return "attempting recovery"; case pcmk_multiply_active_block: return "waiting for an administrator"; case pcmk_multiply_active_unexpected: return "stopping unexpected instances"; } return "Unknown"; } typedef struct pe_re_match_data { char *string; int nregs; regmatch_t *pmatch; } pe_re_match_data_t; typedef struct pe_match_data { pe_re_match_data_t *re; GHashTable *params; GHashTable *meta; } pe_match_data_t; typedef struct pe_rsc_eval_data { const char *standard; const char *provider; const char *agent; } pe_rsc_eval_data_t; typedef struct pe_op_eval_data { const char *op_name; guint interval; } pe_op_eval_data_t; typedef struct pe_rule_eval_data { GHashTable *node_hash; // Only used with g_hash_table_lookup() enum rsc_role_e role; crm_time_t *now; // @COMPAT could be const pe_match_data_t *match_data; // @COMPAT could be const pe_rsc_eval_data_t *rsc_data; // @COMPAT could be const pe_op_eval_data_t *op_data; // @COMPAT could be const } pe_rule_eval_data_t; #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) #include #endif #ifdef __cplusplus } #endif #endif