diff --git a/include/crm/common/actions.h b/include/crm/common/actions.h index 68de0eddd4..5d2784de99 100644 --- a/include/crm/common/actions.h +++ b/include/crm/common/actions.h @@ -1,465 +1,467 @@ /* * 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 #include // GList, GHashTable #include // xmlNode #include #include // enum rsc_start_requirement, etc. #include // pcmk_resource_t, pcmk_node_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 * pcmk_on_fail_ignore through pcmk_on_fail_fence_node 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 so we can compare with less than and greater than. */ // @TODO Define as 10 pcmk_on_fail_ignore = 0, //!< Act as if failure didn't happen // @TODO Define as 30 pcmk_on_fail_restart = 1, //!< Restart resource // @TODO Define as 60 pcmk_on_fail_ban = 2, //!< Ban resource from current node // @TODO Define as 70 pcmk_on_fail_block = 3, //!< Treat resource as unmanaged // @TODO Define as 80 pcmk_on_fail_stop = 4, //!< Stop resource and leave stopped // @TODO Define as 90 pcmk_on_fail_standby_node = 5, //!< Put resource's node in standby // @TODO Define as 100 pcmk_on_fail_fence_node = 6, //!< Fence resource's node // @COMPAT Values below here are out of desired order for API compatibility // @TODO Define as 50 pcmk_on_fail_restart_container = 7, //!< Restart resource's container // @TODO Define as 40 /*! * Fence the remote node created by the resource if fencing is enabled, * otherwise attempt to restart the resource (used internally for some * remote connection failures). */ pcmk_on_fail_reset_remote = 8, // @TODO Define as 20 pcmk_on_fail_demote = 9, //!< Demote if promotable, else stop #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) //! \deprecated Use pcmk_on_fail_ignore instead action_fail_ignore = pcmk_on_fail_ignore, //! \deprecated Use pcmk_on_fail_restart instead action_fail_recover = pcmk_on_fail_restart, //! \deprecated Use pcmk_on_fail_ban instead action_fail_migrate = pcmk_on_fail_ban, //! \deprecated Use pcmk_on_fail_block instead action_fail_block = pcmk_on_fail_block, //! \deprecated Use pcmk_on_fail_stop instead action_fail_stop = pcmk_on_fail_stop, //! \deprecated Use pcmk_on_fail_standby_node instead action_fail_standby = pcmk_on_fail_standby_node, //! \deprecated Use pcmk_on_fail_fence_node instead action_fail_fence = pcmk_on_fail_fence_node, //! \deprecated Use pcmk_on_fail_restart_container instead action_fail_restart_container = pcmk_on_fail_restart_container, //! \deprecated Use pcmk_on_fail_reset_remote instead action_fail_reset_remote = pcmk_on_fail_reset_remote, //! \deprecated Use pcmk_on_fail_demote instead action_fail_demote = pcmk_on_fail_demote, #endif }; //! Action scheduling flags enum pe_action_flags { //! No action flags set (compare with equality rather than bit set) pcmk_no_action_flags = 0, //! Whether action does not require invoking an agent pcmk_action_pseudo = (1 << 0), //! Whether action is runnable pcmk_action_runnable = (1 << 1), //! Whether action should not be executed pcmk_action_optional = (1 << 2), //! Whether action should be added to transition graph even if optional pcmk_action_always_in_graph = (1 << 3), //! Whether operation-specific instance attributes have been unpacked yet pcmk_action_attrs_evaluated = (1 << 4), //! Whether action is allowed to be part of a live migration pcmk_action_migratable = (1 << 7), //! Whether action has been added to transition graph pcmk_action_added_to_graph = (1 << 8), //! Whether action is a stop to abort a dangling migration pcmk_action_migration_abort = (1 << 11), /*! * Whether action is an ordering point for minimum required instances * (used to implement ordering after clones with clone-min configured, * and ordered sets with require-all=false) */ pcmk_action_min_runnable = (1 << 12), //! Whether action is recurring monitor that must be rescheduled if active pcmk_action_reschedule = (1 << 13), //! Whether action has already been processed by a recursive procedure pcmk_action_detect_loop = (1 << 14), //! Whether action's inputs have been de-duplicated yet pcmk_action_inputs_deduplicated = (1 << 15), //! Whether action can be executed on DC rather than own node pcmk_action_on_dc = (1 << 16), #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) //! \deprecated Use pcmk_action_pseudo instead pe_action_pseudo = pcmk_action_pseudo, //! \deprecated Use pcmk_action_runnable instead pe_action_runnable = pcmk_action_runnable, //! \deprecated Use pcmk_action_optional instead pe_action_optional = pcmk_action_optional, //! \deprecated Use pcmk_action_always_in_graph instead pe_action_print_always = pcmk_action_always_in_graph, //! \deprecated Use pcmk_action_attrs_evaluated instead pe_action_have_node_attrs = pcmk_action_attrs_evaluated, //! \deprecated Do not use pe_action_implied_by_stonith = (1 << 6), //! \deprecated Use pcmk_action_migratable instead pe_action_migrate_runnable = pcmk_action_migratable, //! \deprecated Use pcmk_action_added_to_graph instead pe_action_dumped = pcmk_action_added_to_graph, //! \deprecated Do not use pe_action_processed = (1 << 9), //! \deprecated Do not use pe_action_clear = (1 << 10), //! \deprecated Use pcmk_action_migration_abort instead pe_action_dangle = pcmk_action_migration_abort, //! \deprecated Use pcmk_action_min_runnable instead pe_action_requires_any = pcmk_action_min_runnable, //! \deprecated Use pcmk_action_reschedule instead pe_action_reschedule = pcmk_action_reschedule, //! \deprecated Use pcmk_action_detect_loop instead pe_action_tracking = pcmk_action_detect_loop, //! \deprecated Use pcmk_action_inputs_deduplicated instead pe_action_dedup = pcmk_action_inputs_deduplicated, //! \deprecated Use pcmk_action_on_dc instead pe_action_dc = pcmk_action_on_dc, #endif }; /* @COMPAT enum pe_link_state and enum pe_ordering are currently needed for * struct pe_action_wrapper_s (which is public) but should be removed at an * API compatibility break when that can be refactored and made internal */ //!@{ //! \deprecated Do not use enum pe_link_state { pe_link_not_dumped = 0, pe_link_dumped = 1, #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) pe_link_dup = 2, #endif }; enum pe_ordering { pe_order_none = 0x0, #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) pe_order_optional = 0x1, pe_order_apply_first_non_migratable = 0x2, pe_order_implies_first = 0x10, pe_order_implies_then = 0x20, pe_order_promoted_implies_first = 0x40, pe_order_implies_first_migratable = 0x80, pe_order_runnable_left = 0x100, pe_order_pseudo_left = 0x200, pe_order_implies_then_on_node = 0x400, pe_order_probe = 0x800, pe_order_restart = 0x1000, pe_order_stonith_stop = 0x2000, pe_order_serialize_only = 0x4000, pe_order_same_node = 0x8000, pe_order_implies_first_printed = 0x10000, pe_order_implies_then_printed = 0x20000, pe_order_asymmetrical = 0x100000, pe_order_load = 0x200000, pe_order_one_or_more = 0x400000, pe_order_anti_colocation = 0x800000, pe_order_preserve = 0x1000000, pe_order_then_cancels_first = 0x2000000, pe_order_trace = 0x4000000, pe_order_implies_first_master = pe_order_promoted_implies_first, #endif }; // Action sequenced relative to another action // @COMPAT This should be internal struct pe_action_wrapper_s { // @COMPAT This should be uint32_t enum pe_ordering type; // Group of enum pcmk__action_relation_flags // @COMPAT This should be a bool enum pe_link_state state; // Whether action has been added to graph yet pcmk_action_t *action; // Action to be sequenced }; //!@} //! Implementation of pcmk_action_t struct pe_action_s { int id; //!< Counter to identify action /*! * When the controller aborts a transition graph, it sets an abort priority. * If this priority is higher, the action will still be executed anyway. * Pseudo-actions are always allowed, so this is irrelevant for them. */ int priority; pcmk_resource_t *rsc; //!< Resource to apply action to, if any pcmk_node_t *node; //!< Node to execute action on, if any xmlNode *op_entry; //!< Action XML configuration, if any char *task; //!< Action name char *uuid; //!< Action key char *cancel_task; //!< If task is "cancel", the action being cancelled char *reason; //!< Readable description of why action is needed + //@ COMPAT Change to uint32_t at a compatibility break enum pe_action_flags flags; //!< Group of enum pe_action_flags + enum rsc_start_requirement needs; //!< Prerequisite for recovery enum action_fail_response on_fail; //!< Response to failure enum rsc_role_e fail_role; //!< Resource role if action fails GHashTable *meta; //!< Meta-attributes relevant to action GHashTable *extra; //!< Action-specific instance attributes /* Current count of runnable instance actions for "first" action in an * ordering dependency with pcmk__ar_min_runnable set. */ int runnable_before; //!< For Pacemaker use only /*! * Number of instance actions for "first" action in an ordering dependency * with pcmk__ar_min_runnable set that must be runnable before this action * can be runnable. */ int required_runnable_before; // Actions in a relation with this one (as pcmk__related_action_t *) GList *actions_before; //!< For Pacemaker use only GList *actions_after; //!< For Pacemaker use only /* This is intended to hold data that varies by the type of action, but is * not currently used. Some of the above fields could be moved here except * for API backward compatibility. */ void *action_details; //!< For Pacemaker use only }; // 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/common/resources.h b/include/crm/common/resources.h index 5e4f053535..043dc1cf42 100644 --- a/include/crm/common/resources.h +++ b/include/crm/common/resources.h @@ -1,502 +1,502 @@ /* * 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_RESOURCES__H # define PCMK__CRM_COMMON_RESOURCES__H #include // time_t #include // xmlNode #include // gboolean, guint, GList, GHashTable #include // enum rsc_role_e #include // pcmk_resource_t, etc. #ifdef __cplusplus extern "C" { #endif /*! * \file * \brief Scheduler API for resources * \ingroup core */ //! Resource variants supported by Pacemaker enum pe_obj_types { // Order matters: some code compares greater or lesser than pcmk_rsc_variant_unknown = -1, //!< Unknown resource variant pcmk_rsc_variant_primitive = 0, //!< Primitive resource pcmk_rsc_variant_group = 1, //!< Group resource pcmk_rsc_variant_clone = 2, //!< Clone resource pcmk_rsc_variant_bundle = 3, //!< Bundle resource #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) //! \deprecated Use pcmk_rsc_variant_unknown instead pe_unknown = pcmk_rsc_variant_unknown, //! \deprecated Use pcmk_rsc_variant_primitive instead pe_native = pcmk_rsc_variant_primitive, //! \deprecated Use pcmk_rsc_variant_group instead pe_group = pcmk_rsc_variant_group, //! \deprecated Use pcmk_rsc_variant_clone instead pe_clone = pcmk_rsc_variant_clone, //! \deprecated Use pcmk_rsc_variant_bundle instead pe_container = pcmk_rsc_variant_bundle, #endif }; //! What resource needs before it can be recovered from a failed node enum rsc_start_requirement { pcmk_requires_nothing = 0, //!< Resource can be recovered immediately pcmk_requires_quorum = 1, //!< Resource can be recovered if quorate pcmk_requires_fencing = 2, //!< Resource can be recovered after fencing #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) //! \deprecated Use pcmk_requires_nothing instead rsc_req_nothing = pcmk_requires_nothing, //! \deprecated Use pcmk_requires_quorum instead rsc_req_quorum = pcmk_requires_quorum, //! \deprecated Use pcmk_requires_fencing instead rsc_req_stonith = pcmk_requires_fencing, #endif }; //! How to recover a resource that is incorrectly active on multiple nodes enum rsc_recovery_type { pcmk_multiply_active_restart = 0, //!< Stop on all, start on desired pcmk_multiply_active_stop = 1, //!< Stop on all and leave stopped pcmk_multiply_active_block = 2, //!< Do nothing to resource pcmk_multiply_active_unexpected = 3, //!< Stop unexpected instances #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) //! \deprecated Use pcmk_multiply_active_restart instead recovery_stop_start = pcmk_multiply_active_restart, //! \deprecated Use pcmk_multiply_active_stop instead recovery_stop_only = pcmk_multiply_active_stop, //! \deprecated Use pcmk_multiply_active_block instead recovery_block = pcmk_multiply_active_block, //! \deprecated Use pcmk_multiply_active_unexpected instead recovery_stop_unexpected = pcmk_multiply_active_unexpected, #endif }; //! Resource scheduling flags enum pcmk_rsc_flags { //! No resource flags set (compare with equality rather than bit set) pcmk_no_rsc_flags = 0ULL, //! Whether resource has been removed from the configuration pcmk_rsc_removed = (1ULL << 0), //! Whether resource is managed pcmk_rsc_managed = (1ULL << 1), //! Whether resource is blocked from further action pcmk_rsc_blocked = (1ULL << 2), //! Whether resource has been removed but has a container pcmk_rsc_removed_filler = (1ULL << 3), //! Whether resource has clone notifications enabled pcmk_rsc_notify = (1ULL << 4), //! Whether resource is not an anonymous clone instance pcmk_rsc_unique = (1ULL << 5), //! Whether resource's class is "stonith" pcmk_rsc_fence_device = (1ULL << 6), //! Whether resource can be promoted and demoted pcmk_rsc_promotable = (1ULL << 7), //! Whether resource has not yet been assigned to a node pcmk_rsc_unassigned = (1ULL << 8), //! Whether resource is in the process of being assigned to a node pcmk_rsc_assigning = (1ULL << 9), //! Whether resource is in the process of modifying allowed node scores pcmk_rsc_updating_nodes = (1ULL << 10), //! Whether resource is in the process of scheduling actions to restart pcmk_rsc_restarting = (1ULL << 11), //! Whether resource must be stopped (instead of demoted) if it is failed pcmk_rsc_stop_if_failed = (1ULL << 12), //! Whether a reload action has been scheduled for resource pcmk_rsc_reload = (1ULL << 13), //! Whether resource is a remote connection allowed to run on a remote node pcmk_rsc_remote_nesting_allowed = (1ULL << 14), //! Whether resource has "critical" meta-attribute enabled pcmk_rsc_critical = (1ULL << 15), //! Whether resource is considered failed pcmk_rsc_failed = (1ULL << 16), //! Flag for non-scheduler code to use to detect recursion loops pcmk_rsc_detect_loop = (1ULL << 17), //! \deprecated Do not use pcmk_rsc_runnable = (1ULL << 18), //! Whether resource has pending start action in history pcmk_rsc_start_pending = (1ULL << 19), //! \deprecated Do not use pcmk_rsc_starting = (1ULL << 20), //! \deprecated Do not use pcmk_rsc_stopping = (1ULL << 21), //! Whether resource is multiply active with recovery set to stop_unexpected pcmk_rsc_stop_unexpected = (1ULL << 22), //! Whether resource is allowed to live-migrate pcmk_rsc_migratable = (1ULL << 23), //! Whether resource has an ignorable failure pcmk_rsc_ignore_failure = (1ULL << 24), //! Whether resource is an implicit container resource for a bundle replica pcmk_rsc_replica_container = (1ULL << 25), //! Whether resource, its node, or entire cluster is in maintenance mode pcmk_rsc_maintenance = (1ULL << 26), //! \deprecated Do not use pcmk_rsc_has_filler = (1ULL << 27), //! Whether resource can be started or promoted only on quorate nodes pcmk_rsc_needs_quorum = (1ULL << 28), //! Whether resource requires fencing before recovery if on unclean node pcmk_rsc_needs_fencing = (1ULL << 29), //! Whether resource can be started or promoted only on unfenced nodes pcmk_rsc_needs_unfencing = (1ULL << 30), }; //! Search options for resources (exact resource ID always matches) enum pe_find { //! Also match clone instance ID from resource history pcmk_rsc_match_history = (1 << 0), //! Also match anonymous clone instances by base name pcmk_rsc_match_anon_basename = (1 << 1), //! Match only clones and their instances, by either clone or instance ID pcmk_rsc_match_clone_only = (1 << 2), //! If matching by node, compare current node instead of assigned node pcmk_rsc_match_current_node = (1 << 3), //! \deprecated Do not use pe_find_inactive = (1 << 4), //! Match clone instances (even unique) by base name as well as exact ID pcmk_rsc_match_basename = (1 << 5), #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) //! \deprecated Use pcmk_rsc_match_history instead pe_find_renamed = pcmk_rsc_match_history, //! \deprecated Use pcmk_rsc_match_anon_basename instead pe_find_anon = pcmk_rsc_match_anon_basename, //! \deprecated Use pcmk_rsc_match_clone_only instead pe_find_clone = pcmk_rsc_match_clone_only, //! \deprecated Use pcmk_rsc_match_current_node instead pe_find_current = pcmk_rsc_match_current_node, //! \deprecated Use pcmk_rsc_match_basename instead pe_find_any = pcmk_rsc_match_basename, #endif }; //!@{ //! \deprecated Do not use enum pe_restart { pe_restart_restart, pe_restart_ignore, }; 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 }; //!@} // Resource assignment methods (implementation defined by libpacemaker) //! This type should be considered internal to Pacemaker typedef struct resource_alloc_functions_s pcmk_assignment_methods_t; //! Resource object methods typedef struct resource_object_functions_s { /*! * \brief Parse variant-specific resource XML from CIB into struct members * * \param[in,out] rsc Partially unpacked resource * \param[in,out] scheduler Scheduler data * * \return TRUE if resource was unpacked successfully, otherwise FALSE */ gboolean (*unpack)(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler); /*! * \brief Search for a resource ID in a resource and its children * * \param[in] rsc Search this resource and its children * \param[in] id Search for this resource ID * \param[in] on_node If not NULL, limit search to resources on this node * \param[in] flags Group of enum pe_find flags * * \return Resource that matches search criteria if any, otherwise NULL */ pcmk_resource_t *(*find_rsc)(pcmk_resource_t *rsc, const char *search, const pcmk_node_t *node, int flags); /*! * \brief Get value of a resource instance attribute * * \param[in,out] rsc Resource to check * \param[in] node Node to use to evaluate rules * \param[in] create Ignored * \param[in] name Name of instance attribute to check * \param[in,out] scheduler Scheduler data * * \return Value of requested attribute if available, otherwise NULL * \note The caller is responsible for freeing the result using free(). */ char *(*parameter)(pcmk_resource_t *rsc, pcmk_node_t *node, gboolean create, const char *name, pcmk_scheduler_t *scheduler); //! \deprecated Do not use void (*print)(pcmk_resource_t *rsc, const char *pre_text, long options, void *print_data); /*! * \brief Check whether a resource is active * * \param[in] rsc Resource to check * \param[in] all If \p rsc is collective, all instances must be active * * \return TRUE if \p rsc is active, otherwise FALSE */ gboolean (*active)(pcmk_resource_t *rsc, gboolean all); /*! * \brief Get resource's current or assigned role * * \param[in] rsc Resource to check * \param[in] current If TRUE, check current role, otherwise assigned role * * \return Current or assigned role of \p rsc */ enum rsc_role_e (*state)(const pcmk_resource_t *rsc, gboolean current); /*! * \brief List nodes where a resource (or any of its children) is * * \param[in] rsc Resource to check * \param[out] list List to add result to * \param[in] current If 0, list nodes where \p rsc is assigned; * if 1, where active; if 2, where active or pending * * \return If list contains only one node, that node, otherwise NULL */ pcmk_node_t *(*location)(const pcmk_resource_t *rsc, GList **list, int current); /*! * \brief Free all memory used by a resource * * \param[in,out] rsc Resource to free */ void (*free)(pcmk_resource_t *rsc); /*! * \brief Increment cluster's instance counts for a resource * * Given a resource, increment its cluster's ninstances, disabled_resources, * and blocked_resources counts for the resource and its descendants. * * \param[in,out] rsc Resource to count */ void (*count)(pcmk_resource_t *rsc); /*! * \brief Check whether a given resource is in a list of resources * * \param[in] rsc Resource ID to check for * \param[in] only_rsc List of resource IDs to check * \param[in] check_parent If TRUE, check top ancestor as well * * \return TRUE if \p rsc, its top parent if requested, or '*' is in * \p only_rsc, otherwise FALSE */ gboolean (*is_filtered)(const pcmk_resource_t *rsc, GList *only_rsc, gboolean check_parent); /*! * \brief Find a node (and optionally count all) where resource is active * * \param[in] rsc Resource to check * \param[out] count_all If not NULL, set this to count of active nodes * \param[out] count_clean If not NULL, set this to count of clean nodes * * \return A node where the resource is active, preferring the source node * if the resource is involved in a partial migration, or a clean, * online node if the resource's "requires" is "quorum" or * "nothing", otherwise NULL. */ pcmk_node_t *(*active_node)(const pcmk_resource_t *rsc, unsigned int *count_all, unsigned int *count_clean); /*! * \brief Get maximum resource instances per node * * \param[in] rsc Resource to check * * \return Maximum number of \p rsc instances that can be active on one node */ unsigned int (*max_per_node)(const pcmk_resource_t *rsc); } pcmk_rsc_methods_t; //! Implementation of pcmk_resource_t struct pe_resource_s { char *id; //!< Resource ID in configuration char *clone_name; //!< Resource instance ID in history //! Resource configuration (possibly expanded from template) xmlNode *xml; //! Original resource configuration, if using template xmlNode *orig_xml; //! Configuration of resource operations (possibly expanded from template) xmlNode *ops_xml; pcmk_scheduler_t *cluster; //!< Cluster that resource is part of pcmk_resource_t *parent; //!< Resource's parent resource, if any enum pe_obj_types variant; //!< Resource variant void *variant_opaque; //!< Variant-specific (and private) data pcmk_rsc_methods_t *fns; //!< Resource object methods pcmk_assignment_methods_t *cmds; //!< Resource assignment methods enum rsc_recovery_type recovery_type; //!< How to recover if failed enum pe_restart restart_type; //!< \deprecated Do not use int priority; //!< Configured priority int stickiness; //!< Extra preference for current node int sort_index; //!< Promotion score on assigned node int failure_timeout; //!< Failure timeout int migration_threshold; //!< Migration threshold guint remote_reconnect_ms; //!< Retry interval for remote connections char *pending_task; //!< Pending action in history, if any unsigned long long flags; //!< Group of enum pcmk_rsc_flags // @TODO Merge these into flags gboolean is_remote_node; //!< Whether this is a remote connection gboolean exclusive_discover; //!< Whether exclusive probing is enabled /* Pay special attention to whether you want to use rsc_cons_lhs and * rsc_cons directly, which include only colocations explicitly involving * this resource, or call libpacemaker's pcmk__with_this_colocations() and * pcmk__this_with_colocations() functions, which may return relevant * colocations involving the resource's ancestors as well. */ //!@{ //! This field should be treated as internal to Pacemaker GList *rsc_cons_lhs; // Colocations of other resources with this one GList *rsc_cons; // Colocations of this resource with others GList *rsc_location; // Location constraints for resource GList *actions; // Actions scheduled for resource GList *rsc_tickets; // Ticket constraints for resource //!@} pcmk_node_t *allocated_to; //!< Node resource is assigned to //! The destination node, if migrate_to completed but migrate_from has not pcmk_node_t *partial_migration_target; //! The source node, if migrate_to completed but migrate_from has not pcmk_node_t *partial_migration_source; //! Nodes where resource may be active GList *running_on; //! Nodes where resource has been probed (key is node ID, not name) GHashTable *known_on; //! Nodes where resource may run (key is node ID, not name) GHashTable *allowed_nodes; enum rsc_role_e role; //!< Resource's current role enum rsc_role_e next_role; //!< Resource's scheduled next role GHashTable *meta; //!< Resource's meta-attributes - GHashTable *parameters; //! \deprecated Use pe_rsc_params() instead + GHashTable *parameters; //!< \deprecated Use pe_rsc_params() instead GHashTable *utilization; //!< Resource's utilization attributes GList *children; //!< Resource's child resources, if any // Source nodes where stop is needed after migrate_from and migrate_to GList *dangling_migrations; pcmk_resource_t *container; //!< Resource containing this one, if any GList *fillers; //!< Resources contained by this one, if any // @COMPAT These should be made const at next API compatibility break pcmk_node_t *pending_node; //!< Node on which pending_task is happening pcmk_node_t *lock_node; //!< Resource shutdown-locked to this node time_t lock_time; //!< When shutdown lock started /*! * Resource parameters may have node-attribute-based rules, which means the * values can vary by node. This table has node names as keys and parameter * name/value tables as values. Use pe_rsc_params() to get the table for a * given node rather than use this directly. */ GHashTable *parameter_cache; }; #ifdef __cplusplus } #endif #endif // PCMK__CRM_COMMON_RESOURCES__H diff --git a/include/crm/common/scheduler.h b/include/crm/common/scheduler.h index c0ede93412..96f9a62187 100644 --- a/include/crm/common/scheduler.h +++ b/include/crm/common/scheduler.h @@ -1,235 +1,238 @@ /* * 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_SCHEDULER__H # define PCMK__CRM_COMMON_SCHEDULER__H #include // time_t #include // xmlNode #include // guint, GList, GHashTable #include // crm_time_t #include #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif /*! * \file * \brief Scheduler API * \ingroup core */ //! Possible responses to loss of quorum enum pe_quorum_policy { pcmk_no_quorum_freeze, // pcmk_tag_t *) int blocked_resources; //!< Number of blocked resources in cluster int disabled_resources; //!< Number of disabled resources in cluster GList *param_check; //!< History entries that need to be checked GList *stop_needed; //!< Containers that need stop actions time_t recheck_by; //!< Hint to controller when to reschedule int ninstances; //!< Total number of resource instances guint shutdown_lock; //!< How long to lock resources (seconds) int priority_fencing_delay; //!< Priority fencing delay // pcmk__output_t * void *priv; //!< For Pacemaker use only guint node_pending_timeout; //!< Pending join times out after this (ms) }; #ifdef __cplusplus } #endif #endif // PCMK__CRM_COMMON_SCHEDULER__H