diff --git a/include/crm/cluster/internal.h b/include/crm/cluster/internal.h index d81994dd05..fe49e701d0 100644 --- a/include/crm/cluster/internal.h +++ b/include/crm/cluster/internal.h @@ -1,285 +1,285 @@ /* * Copyright 2004-2024 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_CLUSTER_INTERNAL__H #define PCMK__CRM_CLUSTER_INTERNAL__H #include #include // uint32_t, uint64_t #include // gboolean #include #ifdef __cplusplus extern "C" { #endif enum crm_proc_flag { /* @COMPAT When pcmk__node_status_t:processes is made internal, we can merge * this into node flags or turn it into a boolean. Until then, in theory * something could depend on these particular numeric values. */ crm_proc_none = 0x00000001, // Cluster layers crm_proc_cpg = 0x04000000, }; /*! * \internal * \enum pcmk__node_status_flags * \brief Boolean flags for a \c pcmk__node_status_t object * * Some flags may not be related to status specifically. However, we keep these * separate from enum pcmk__node_flags because they're used with * different object types. */ enum pcmk__node_status_flags { /*! * Node is a Pacemaker Remote node and should not be considered for cluster * membership */ pcmk__node_status_remote = (UINT32_C(1) << 0), //! Node's cache entry is dirty pcmk__node_status_dirty = (UINT32_C(1) << 1), }; // Used with node cache search functions enum pcmk__node_search_flags { //! Does not affect search pcmk__node_search_none = 0, //! Search for cluster nodes from membership cache pcmk__node_search_cluster_member = (1 << 0), //! Search for remote nodes pcmk__node_search_remote = (1 << 1), //! Search for cluster member nodes and remote nodes pcmk__node_search_any = pcmk__node_search_cluster_member |pcmk__node_search_remote, //! Search for cluster nodes from CIB (as of last cache refresh) pcmk__node_search_cluster_cib = (1 << 2), }; //! Node status data (may be a cluster node or a Pacemaker Remote node) typedef struct pcmk__node_status { //! Node name as known to cluster layer, or Pacemaker Remote node name char *name; /* @COMPAT This is less than ideal since the value is not a valid XML ID * (for Corosync, it's the string equivalent of the node's numeric node ID, * but XML IDs can't start with a number) and the three elements should have * different IDs. * * Ideally, we would use something like node-NODEID, node_state-NODEID, and * transient_attributes-NODEID as the element IDs. Unfortunately changing it * would be impractical due to backward compatibility; older nodes in a * rolling upgrade will always write and expect the value in the old format. */ /*! * Value of the PCMK_XA_ID XML attribute to use with the node's * PCMK_XE_NODE, PCMK_XE_NODE_STATE, and PCMK_XE_TRANSIENT_ATTRIBUTES * XML elements in the CIB */ char *xml_id; char *state; // @TODO change to enum //! Group of enum pcmk__node_status_flags uint32_t flags; /*! * Most recent cluster membership in which node was seen (0 for Pacemaker * Remote nodes) */ uint64_t membership_id; uint32_t processes; // @TODO most not needed, merge into flags /* @TODO When we can break public API compatibility, we can make the rest of * these members separate structs and use void *cluster_data and * void *user_data here instead, to abstract the cluster layer further. */ // Only used by controller enum crm_join_phase join; char *expected; time_t peer_lost; char *conn_host; time_t when_member; // Since when node has been a cluster member time_t when_online; // Since when peer has been online in CPG /* @TODO The following are currently needed only by the Corosync stack. * Eventually consider moving them to a cluster-layer-specific data object. */ - uint32_t cluster_layer_id; //! Cluster-layer numeric node ID - time_t when_lost; //! When CPG membership was last lost + uint32_t cluster_layer_id; //!< Cluster-layer numeric node ID + time_t when_lost; //!< When CPG membership was last lost } pcmk__node_status_t; /*! * \internal * \brief Return the process bit corresponding to the current cluster stack * * \return Process flag if detectable, otherwise 0 */ static inline uint32_t crm_get_cluster_proc(void) { switch (pcmk_get_cluster_layer()) { case pcmk_cluster_layer_corosync: return crm_proc_cpg; default: break; } return crm_proc_none; } /*! * \internal * \brief Get log-friendly string description of a Corosync return code * * \param[in] error Corosync return code * * \return Log-friendly string description corresponding to \p error */ static inline const char * pcmk__cs_err_str(int error) { # if SUPPORT_COROSYNC switch (error) { case CS_OK: return "OK"; case CS_ERR_LIBRARY: return "Library error"; case CS_ERR_VERSION: return "Version error"; case CS_ERR_INIT: return "Initialization error"; case CS_ERR_TIMEOUT: return "Timeout"; case CS_ERR_TRY_AGAIN: return "Try again"; case CS_ERR_INVALID_PARAM: return "Invalid parameter"; case CS_ERR_NO_MEMORY: return "No memory"; case CS_ERR_BAD_HANDLE: return "Bad handle"; case CS_ERR_BUSY: return "Busy"; case CS_ERR_ACCESS: return "Access error"; case CS_ERR_NOT_EXIST: return "Doesn't exist"; case CS_ERR_NAME_TOO_LONG: return "Name too long"; case CS_ERR_EXIST: return "Exists"; case CS_ERR_NO_SPACE: return "No space"; case CS_ERR_INTERRUPT: return "Interrupt"; case CS_ERR_NAME_NOT_FOUND: return "Name not found"; case CS_ERR_NO_RESOURCES: return "No resources"; case CS_ERR_NOT_SUPPORTED: return "Not supported"; case CS_ERR_BAD_OPERATION: return "Bad operation"; case CS_ERR_FAILED_OPERATION: return "Failed operation"; case CS_ERR_MESSAGE_ERROR: return "Message error"; case CS_ERR_QUEUE_FULL: return "Queue full"; case CS_ERR_QUEUE_NOT_AVAILABLE: return "Queue not available"; case CS_ERR_BAD_FLAGS: return "Bad flags"; case CS_ERR_TOO_BIG: return "Too big"; case CS_ERR_NO_SECTIONS: return "No sections"; } # endif return "Corosync error"; } # if SUPPORT_COROSYNC #if 0 /* This is the new way to do it, but we still support all Corosync 2 versions, * and this isn't always available. A better alternative here would be to check * for support in the configure script and enable this conditionally. */ #define pcmk__init_cmap(handle) cmap_initialize_map((handle), CMAP_MAP_ICMAP) #else #define pcmk__init_cmap(handle) cmap_initialize(handle) #endif char *pcmk__corosync_cluster_name(void); bool pcmk__corosync_add_nodes(xmlNode *xml_parent); void pcmk__cpg_confchg_cb(cpg_handle_t handle, const struct cpg_name *group_name, const struct cpg_address *member_list, size_t member_list_entries, const struct cpg_address *left_list, size_t left_list_entries, const struct cpg_address *joined_list, size_t joined_list_entries); char *pcmk__cpg_message_data(cpg_handle_t handle, uint32_t sender_id, uint32_t pid, void *content, uint32_t *kind, const char **from); # endif const char *pcmk__cluster_node_uuid(pcmk__node_status_t *node); char *pcmk__cluster_node_name(uint32_t nodeid); const char *pcmk__cluster_local_node_name(void); const char *pcmk__node_name_from_uuid(const char *uuid); pcmk__node_status_t *crm_update_peer_proc(const char *source, pcmk__node_status_t *peer, uint32_t flag, const char *status); pcmk__node_status_t *pcmk__update_peer_state(const char *source, pcmk__node_status_t *node, const char *state, uint64_t membership); void pcmk__update_peer_expected(const char *source, pcmk__node_status_t *node, const char *expected); void pcmk__reap_unseen_nodes(uint64_t ring_id); void pcmk__corosync_quorum_connect(gboolean (*dispatch)(unsigned long long, gboolean), void (*destroy) (gpointer)); enum crm_ais_msg_types pcmk__cluster_parse_msg_type(const char *text); bool pcmk__cluster_send_message(const pcmk__node_status_t *node, enum crm_ais_msg_types service, const xmlNode *data); // Membership bool pcmk__cluster_has_quorum(void); void pcmk__cluster_init_node_caches(void); void pcmk__cluster_destroy_node_caches(void); void pcmk__cluster_set_autoreap(bool enable); void pcmk__cluster_set_status_callback(void (*dispatch)(enum crm_status_type, pcmk__node_status_t *, const void *)); bool pcmk__cluster_is_node_active(const pcmk__node_status_t *node); unsigned int pcmk__cluster_num_active_nodes(void); unsigned int pcmk__cluster_num_remote_nodes(void); pcmk__node_status_t *pcmk__cluster_lookup_remote_node(const char *node_name); void pcmk__cluster_forget_cluster_node(uint32_t id, const char *node_name); void pcmk__cluster_forget_remote_node(const char *node_name); pcmk__node_status_t *pcmk__search_node_caches(unsigned int id, const char *uname, uint32_t flags); void pcmk__purge_node_from_cache(const char *node_name, uint32_t node_id); void pcmk__refresh_node_caches_from_cib(xmlNode *cib); pcmk__node_status_t *pcmk__get_node(unsigned int id, const char *uname, const char *uuid, uint32_t flags); #ifdef __cplusplus } #endif #endif // PCMK__CRM_CLUSTER_INTERNAL__H diff --git a/include/crm/common/ipc_controld.h b/include/crm/common/ipc_controld.h index cb4baacd13..95d1ce86b2 100644 --- a/include/crm/common/ipc_controld.h +++ b/include/crm/common/ipc_controld.h @@ -1,111 +1,111 @@ /* * Copyright 2020-2024 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_IPC_CONTROLD__H #define PCMK__CRM_COMMON_IPC_CONTROLD__H #include // bool #include // GList #include // xmlNode #include // pcmk_ipc_api_t #ifdef __cplusplus extern "C" { #endif /** * \file * \brief IPC commands for Pacemaker controller * * \ingroup core */ //! Possible types of controller replies enum pcmk_controld_api_reply { pcmk_controld_reply_unknown, pcmk_controld_reply_reprobe, pcmk_controld_reply_info, pcmk_controld_reply_resource, pcmk_controld_reply_ping, pcmk_controld_reply_nodes, }; // Node information passed with pcmk_controld_reply_nodes typedef struct { uint32_t id; const char *uname; const char *state; } pcmk_controld_api_node_t; /*! * Controller reply passed to event callback * * \note Shutdown and election calls have no reply. Reprobe calls are * acknowledged but contain no data (reply_type will be the only item * set). Node info and ping calls have their own reply data. Fail and * refresh calls use the resource reply type and reply data. * \note The pointers in the reply are only guaranteed to be meaningful for the * execution of the callback; if the values are needed for later, the * callback should copy them. */ typedef struct { enum pcmk_controld_api_reply reply_type; const char *feature_set; //!< CRM feature set advertised by controller const char *host_from; //!< Name of node that sent reply union { // pcmk_controld_reply_info struct { bool have_quorum; bool is_remote; int id; const char *uuid; const char *uname; const char *state; } node_info; // pcmk_controld_reply_resource struct { - xmlNode *node_state; // // guint, GHashTable #include // regmatch_t #include // xmlNode #include // crm_time_t #ifdef __cplusplus extern "C" { #endif /*! * \file * \brief Scheduler API for rules * \ingroup core */ /* Allowed subexpressions of a rule * @COMPAT This should be made internal at an API compatibility break */ //!@{ //! \deprecated For Pacemaker use only enum expression_type { pcmk__condition_unknown = 0, // Unknown or invalid condition pcmk__condition_rule = 1, // Nested rule pcmk__condition_attribute = 2, // Node attribute expression pcmk__condition_location = 3, // Node location expression pcmk__condition_datetime = 5, // Date/time expression pcmk__condition_resource = 7, // Resource agent expression pcmk__condition_operation = 8, // Operation expression #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) not_expr = pcmk__condition_unknown, nested_rule = pcmk__condition_rule, attr_expr = pcmk__condition_attribute, loc_expr = pcmk__condition_location, role_expr = 4, time_expr = pcmk__condition_datetime, version_expr = 6, rsc_expr = pcmk__condition_resource, op_expr = pcmk__condition_operation, #endif }; //!@} //! Data used to evaluate a rule (any NULL items are ignored) typedef struct pcmk_rule_input { // Used to evaluate date expressions const crm_time_t *now; //!< Current time for rule evaluation purposes // Used to evaluate resource type expressions const char *rsc_standard; //!< Resource standard that rule applies to const char *rsc_provider; //!< Resource provider that rule applies to const char *rsc_agent; //!< Resource agent that rule applies to // Used to evaluate operation type expressions - const char *op_name; //! Operation name that rule applies to - guint op_interval_ms; //! Operation interval that rule applies to + const char *op_name; //!< Operation name that rule applies to + guint op_interval_ms; //!< Operation interval that rule applies to // Remaining members are used to evaluate node attribute expressions /*! * Node attributes for rule evaluation purposes * * \note Though not const, this is used only with g_hash_table_lookup(). */ GHashTable *node_attrs; // Remaining members are used only within location constraint rules /*! * Resource parameters that can be used as the reference value source * * \note Though not const, this is used only with g_hash_table_lookup(). */ GHashTable *rsc_params; /*! * Resource meta-attributes that can be used as the reference value source * * \note Though not const, this is used only with g_hash_table_lookup(). */ GHashTable *rsc_meta; //! Resource ID to compare against a location constraint's resource pattern const char *rsc_id; //! Resource pattern submatches (as set by regexec()) for rsc_id const regmatch_t *rsc_id_submatches; //! Number of entries in rsc_id_submatches int rsc_id_nmatches; } pcmk_rule_input_t; int pcmk_evaluate_rule(xmlNode *rule, const pcmk_rule_input_t *rule_input, crm_time_t *next_change); #ifdef __cplusplus } #endif #endif // PCMK__CRM_COMMON_RULES__H diff --git a/include/crm/common/scheduler.h b/include/crm/common/scheduler.h index da2d6c50e8..c7564e70b4 100644 --- a/include/crm/common/scheduler.h +++ b/include/crm/common/scheduler.h @@ -1,169 +1,169 @@ /* * Copyright 2004-2024 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 #ifdef __cplusplus extern "C" { #endif /*! * \file * \brief Scheduler API * \ingroup core */ // NOTE: sbd (as of at least 1.5.2) uses this enum //! Possible responses to loss of quorum enum pe_quorum_policy { - pcmk_no_quorum_freeze, // pcmk__idref_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__scheduler_private_t *priv; // For Pacemaker use only guint node_pending_timeout; // Pending join times out after this (ms) }; //!@} pcmk_node_t *pcmk_get_dc(const pcmk_scheduler_t *scheduler); enum pe_quorum_policy pcmk_get_no_quorum_policy(const pcmk_scheduler_t *scheduler); int pcmk_set_scheduler_cib(pcmk_scheduler_t *scheduler, xmlNode *cib); bool pcmk_has_quorum(const pcmk_scheduler_t *scheduler); pcmk_node_t *pcmk_find_node(const pcmk_scheduler_t *scheduler, const char *node_name); #ifdef __cplusplus } #endif #endif // PCMK__CRM_COMMON_SCHEDULER__H diff --git a/include/pcmki/pcmki_transition.h b/include/pcmki/pcmki_transition.h index 89f50c487d..d10fe83393 100644 --- a/include/pcmki/pcmki_transition.h +++ b/include/pcmki/pcmki_transition.h @@ -1,182 +1,184 @@ /* * Copyright 2004-2024 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__PCMKI_PCMKI_TRANSITION__H #define PCMK__PCMKI_PCMKI_TRANSITION__H #include // bool #include // uint32_t #include // time_t #include // guint, GList, GHashTable #include // xmlNode #include // pcmk_scheduler_t #include // lrmd_event_data_t #ifdef __cplusplus extern "C" { #endif enum pcmk__graph_action_type { pcmk__pseudo_graph_action, pcmk__rsc_graph_action, pcmk__cluster_graph_action, }; enum pcmk__synapse_flags { pcmk__synapse_ready = (1 << 0), pcmk__synapse_failed = (1 << 1), pcmk__synapse_executed = (1 << 2), pcmk__synapse_confirmed = (1 << 3), }; typedef struct { int id; int priority; uint32_t flags; // Group of pcmk__synapse_flags GList *actions; /* pcmk__graph_action_t* */ GList *inputs; /* pcmk__graph_action_t* */ } pcmk__graph_synapse_t; #define pcmk__set_synapse_flags(synapse, flags_to_set) do { \ (synapse)->flags = pcmk__set_flags_as(__func__, __LINE__, \ LOG_TRACE, \ "Synapse", "synapse", \ (synapse)->flags, (flags_to_set), #flags_to_set); \ } while (0) #define pcmk__clear_synapse_flags(synapse, flags_to_clear) do { \ (synapse)->flags = pcmk__clear_flags_as(__func__, __LINE__, \ LOG_TRACE, \ "Synapse", "synapse", \ (synapse)->flags, (flags_to_clear), #flags_to_clear); \ } while (0) enum pcmk__graph_action_flags { pcmk__graph_action_sent_update = (1 << 0), /* sent to the CIB */ pcmk__graph_action_executed = (1 << 1), /* sent to the CRM */ pcmk__graph_action_confirmed = (1 << 2), pcmk__graph_action_failed = (1 << 3), - pcmk__graph_action_can_fail = (1 << 4), //! \deprecated Will be removed in a future release + + //! \deprecated Will be removed in a future release + pcmk__graph_action_can_fail = (1 << 4), }; typedef struct { int id; int timeout; int timer; guint interval_ms; GHashTable *params; enum pcmk__graph_action_type type; pcmk__graph_synapse_t *synapse; uint32_t flags; // Group of pcmk__graph_action_flags xmlNode *xml; } pcmk__graph_action_t; #define pcmk__set_graph_action_flags(action, flags_to_set) do { \ (action)->flags = pcmk__set_flags_as(__func__, __LINE__, \ LOG_TRACE, \ "Action", "action", \ (action)->flags, (flags_to_set), #flags_to_set); \ } while (0) #define pcmk__clear_graph_action_flags(action, flags_to_clear) do { \ (action)->flags = pcmk__clear_flags_as(__func__, __LINE__, \ LOG_TRACE, \ "Action", "action", \ (action)->flags, (flags_to_clear), #flags_to_clear); \ } while (0) // What to do after finished processing a transition graph enum pcmk__graph_next { // Order matters: lowest priority to highest pcmk__graph_done, // Transition complete, nothing further needed pcmk__graph_wait, // Transition interrupted, wait for further changes pcmk__graph_restart, // Transition interrupted, start a new one pcmk__graph_shutdown, // Transition interrupted, local shutdown needed }; typedef struct { int id; char *source; int abort_priority; bool complete; const char *abort_reason; enum pcmk__graph_next completion_action; int num_actions; int num_synapses; int batch_limit; guint network_delay; guint stonith_timeout; int fired; int pending; int skipped; int completed; int incomplete; GList *synapses; /* pcmk__graph_synapse_t* */ int migration_limit; //! Failcount after one failed stop action char *failed_stop_offset; //! Failcount after one failed start action char *failed_start_offset; //! Time (from epoch) by which the controller should re-run the scheduler time_t recheck_by; } pcmk__graph_t; typedef struct { int (*pseudo) (pcmk__graph_t *graph, pcmk__graph_action_t *action); int (*rsc) (pcmk__graph_t *graph, pcmk__graph_action_t *action); int (*cluster) (pcmk__graph_t *graph, pcmk__graph_action_t *action); int (*fence) (pcmk__graph_t *graph, pcmk__graph_action_t *action); bool (*allowed) (pcmk__graph_t *graph, pcmk__graph_action_t *action); } pcmk__graph_functions_t; enum pcmk__graph_status { pcmk__graph_active, // Some actions have been performed pcmk__graph_pending, // No actions performed yet pcmk__graph_complete, pcmk__graph_terminated, }; void pcmk__set_graph_functions(pcmk__graph_functions_t *fns); pcmk__graph_t *pcmk__unpack_graph(const xmlNode *xml_graph, const char *reference); enum pcmk__graph_status pcmk__execute_graph(pcmk__graph_t *graph); void pcmk__update_graph(pcmk__graph_t *graph, const pcmk__graph_action_t *action); void pcmk__free_graph(pcmk__graph_t *graph); const char *pcmk__graph_status2text(enum pcmk__graph_status state); void pcmk__log_graph(unsigned int log_level, pcmk__graph_t *graph); void pcmk__log_graph_action(int log_level, pcmk__graph_action_t *action); void pcmk__log_transition_summary(const pcmk_scheduler_t *scheduler, const char *filename); lrmd_event_data_t *pcmk__event_from_graph_action(const xmlNode *resource, const pcmk__graph_action_t *action, int status, int rc, const char *exit_reason); #ifdef __cplusplus } #endif #endif // PCMK__PCMKI_PCMKI_TRANSITION__H