diff options
Diffstat (limited to 'include/crm/pengine')
-rw-r--r-- | include/crm/pengine/Makefile.am | 5 | ||||
-rw-r--r-- | include/crm/pengine/common.h | 38 | ||||
-rw-r--r-- | include/crm/pengine/common_compat.h | 57 | ||||
-rw-r--r-- | include/crm/pengine/complex.h | 2 | ||||
-rw-r--r-- | include/crm/pengine/internal.h | 294 | ||||
-rw-r--r-- | include/crm/pengine/pe_types_compat.h | 116 | ||||
-rw-r--r-- | include/crm/pengine/remote_internal.h | 7 | ||||
-rw-r--r-- | include/crm/pengine/rules.h | 42 | ||||
-rw-r--r-- | include/crm/pengine/rules_compat.h | 50 | ||||
-rw-r--r-- | include/crm/pengine/rules_internal.h | 16 | ||||
-rw-r--r-- | include/crm/pengine/status.h | 73 | ||||
-rw-r--r-- | include/crm/pengine/status_compat.h | 72 |
12 files changed, 263 insertions, 509 deletions
diff --git a/include/crm/pengine/Makefile.am b/include/crm/pengine/Makefile.am index 3560d24..77bc28e 100644 --- a/include/crm/pengine/Makefile.am +++ b/include/crm/pengine/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2006-2023 the Pacemaker project contributors +# Copyright 2006-2024 the Pacemaker project contributors # # The version control history for this file may have further details. # @@ -19,4 +19,5 @@ header_HEADERS = common.h \ status.h \ common_compat.h \ pe_types_compat.h \ - rules_compat.h + rules_compat.h \ + status_compat.h diff --git a/include/crm/pengine/common.h b/include/crm/pengine/common.h index 2feac8a..57005e1 100644 --- a/include/crm/pengine/common.h +++ b/include/crm/pengine/common.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2023 the Pacemaker project contributors + * Copyright 2004-2024 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -19,40 +19,6 @@ extern "C" { #endif -extern gboolean was_processing_error; -extern gboolean was_processing_warning; - -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; @@ -78,7 +44,7 @@ typedef struct pe_op_eval_data { typedef struct pe_rule_eval_data { GHashTable *node_hash; // Only used with g_hash_table_lookup() - enum rsc_role_e role; + enum rsc_role_e role; //!< \deprecated Ignored 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 diff --git a/include/crm/pengine/common_compat.h b/include/crm/pengine/common_compat.h index 4330ccf..621df4b 100644 --- a/include/crm/pengine/common_compat.h +++ b/include/crm/pengine/common_compat.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2023 the Pacemaker project contributors + * Copyright 2004-2024 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -28,20 +28,20 @@ extern "C" { //! \deprecated Use (pcmk_role_promoted + 1) instead #define RSC_ROLE_MAX (pcmk_role_promoted + 1) -//! \deprecated Use role2text(pcmk_role_unknown) instead -#define RSC_ROLE_UNKNOWN_S role2text(pcmk_role_unknown) +//! \deprecated Use pcmk_role_text(pcmk_role_unknown) instead +#define RSC_ROLE_UNKNOWN_S pcmk_role_text(pcmk_role_unknown) -//! \deprecated Use role2text(pcmk_role_stopped) instead -#define RSC_ROLE_STOPPED_S role2text(pcmk_role_stopped) +//! \deprecated Use pcmk_role_text(pcmk_role_stopped) instead +#define RSC_ROLE_STOPPED_S pcmk_role_text(pcmk_role_stopped) -//! \deprecated Use role2text(pcmk_role_started) instead -#define RSC_ROLE_STARTED_S role2text(pcmk_role_started) +//! \deprecated Use pcmk_role_text(pcmk_role_started) instead +#define RSC_ROLE_STARTED_S pcmk_role_text(pcmk_role_started) -//! \deprecated Use role2text(pcmk_role_unpromoted) instead -#define RSC_ROLE_UNPROMOTED_S role2text(pcmk_role_unpromoted) +//! \deprecated Use pcmk_role_text(pcmk_role_unpromoted) instead +#define RSC_ROLE_UNPROMOTED_S pcmk_role_text(pcmk_role_unpromoted) -//! \deprecated Use role2text(pcmk_role_promoted) instead -#define RSC_ROLE_PROMOTED_S role2text(pcmk_role_promoted) +//! \deprecated Use pcmk_role_text(pcmk_role_promoted) instead +#define RSC_ROLE_PROMOTED_S pcmk_role_text(pcmk_role_promoted) //! \deprecated Do not use #define RSC_ROLE_UNPROMOTED_LEGACY_S "Slave" @@ -55,6 +55,41 @@ extern "C" { //! \deprecated Do not use #define RSC_ROLE_MASTER_S RSC_ROLE_PROMOTED_LEGACY_S +//! \deprecated Use pcmk_role_text() instead +const char *role2text(enum rsc_role_e role); + +//! \deprecated Use pcmk_parse_role() instead +enum rsc_role_e text2role(const char *role); + +//! \deprecated Use pcmk_action_text() instead +const char *task2text(enum action_tasks task); + +//! \deprecated Use pcmk_parse_action() instead +enum action_tasks text2task(const char *task); + +//! \deprecated Use pcmk_on_fail_text() instead +const char *fail2text(enum action_fail_response fail); + +//! \deprecated Do not use +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"; +} + +//! \deprecated Do not use +const char *pe_pref(GHashTable * options, const char *name); + #ifdef __cplusplus } #endif diff --git a/include/crm/pengine/complex.h b/include/crm/pengine/complex.h index 9b6ad1b..e194e5e 100644 --- a/include/crm/pengine/complex.h +++ b/include/crm/pengine/complex.h @@ -18,6 +18,8 @@ extern "C" { #endif +// @COMPAT Make internal when we can break API backward compatibility +//! \deprecated Do not use extern pcmk_rsc_methods_t resource_class_functions[]; GHashTable *pe_rsc_params(pcmk_resource_t *rsc, const pcmk_node_t *node, diff --git a/include/crm/pengine/internal.h b/include/crm/pengine/internal.h index 9c8068f..caf1e21 100644 --- a/include/crm/pengine/internal.h +++ b/include/crm/pengine/internal.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2023 the Pacemaker project contributors + * Copyright 2004-2024 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -13,7 +13,7 @@ # include <stdbool.h> # include <stdint.h> # include <string.h> -# include <crm/msg_xml.h> +# include <crm/common/xml.h> # include <crm/pengine/status.h> # include <crm/pengine/remote_internal.h> # include <crm/common/internal.h> @@ -31,153 +31,6 @@ bool pe__clone_flag_is_set(const pcmk_resource_t *clone, uint32_t flags); bool pe__group_flag_is_set(const pcmk_resource_t *group, uint32_t flags); pcmk_resource_t *pe__last_group_member(const pcmk_resource_t *group); - -# define pe_rsc_info(rsc, fmt, args...) crm_log_tag(LOG_INFO, rsc ? rsc->id : "<NULL>", fmt, ##args) -# define pe_rsc_debug(rsc, fmt, args...) crm_log_tag(LOG_DEBUG, rsc ? rsc->id : "<NULL>", fmt, ##args) -# define pe_rsc_trace(rsc, fmt, args...) crm_log_tag(LOG_TRACE, rsc ? rsc->id : "<NULL>", fmt, ##args) - -# define pe_err(fmt...) do { \ - was_processing_error = TRUE; \ - pcmk__config_err(fmt); \ - } while (0) - -# define pe_warn(fmt...) do { \ - was_processing_warning = TRUE; \ - pcmk__config_warn(fmt); \ - } while (0) - -# define pe_proc_err(fmt...) { was_processing_error = TRUE; crm_err(fmt); } -# define pe_proc_warn(fmt...) { was_processing_warning = TRUE; crm_warn(fmt); } - -#define pe__set_working_set_flags(scheduler, flags_to_set) do { \ - (scheduler)->flags = pcmk__set_flags_as(__func__, __LINE__, \ - LOG_TRACE, "Scheduler", crm_system_name, \ - (scheduler)->flags, (flags_to_set), #flags_to_set); \ - } while (0) - -#define pe__clear_working_set_flags(scheduler, flags_to_clear) do { \ - (scheduler)->flags = pcmk__clear_flags_as(__func__, __LINE__, \ - LOG_TRACE, "Scheduler", crm_system_name, \ - (scheduler)->flags, (flags_to_clear), #flags_to_clear); \ - } while (0) - -#define pe__set_resource_flags(resource, flags_to_set) do { \ - (resource)->flags = pcmk__set_flags_as(__func__, __LINE__, \ - LOG_TRACE, "Resource", (resource)->id, (resource)->flags, \ - (flags_to_set), #flags_to_set); \ - } while (0) - -#define pe__clear_resource_flags(resource, flags_to_clear) do { \ - (resource)->flags = pcmk__clear_flags_as(__func__, __LINE__, \ - LOG_TRACE, "Resource", (resource)->id, (resource)->flags, \ - (flags_to_clear), #flags_to_clear); \ - } while (0) - -#define pe__set_action_flags(action, flags_to_set) do { \ - (action)->flags = pcmk__set_flags_as(__func__, __LINE__, \ - LOG_TRACE, \ - "Action", (action)->uuid, \ - (action)->flags, \ - (flags_to_set), \ - #flags_to_set); \ - } while (0) - -#define pe__clear_action_flags(action, flags_to_clear) do { \ - (action)->flags = pcmk__clear_flags_as(__func__, __LINE__, \ - LOG_TRACE, \ - "Action", (action)->uuid, \ - (action)->flags, \ - (flags_to_clear), \ - #flags_to_clear); \ - } while (0) - -#define pe__set_raw_action_flags(action_flags, action_name, flags_to_set) do { \ - action_flags = pcmk__set_flags_as(__func__, __LINE__, \ - LOG_TRACE, "Action", action_name, \ - (action_flags), \ - (flags_to_set), #flags_to_set); \ - } while (0) - -#define pe__clear_raw_action_flags(action_flags, action_name, flags_to_clear) do { \ - action_flags = pcmk__clear_flags_as(__func__, __LINE__, \ - LOG_TRACE, \ - "Action", action_name, \ - (action_flags), \ - (flags_to_clear), \ - #flags_to_clear); \ - } while (0) - -#define pe__set_action_flags_as(function, line, action, flags_to_set) do { \ - (action)->flags = pcmk__set_flags_as((function), (line), \ - LOG_TRACE, \ - "Action", (action)->uuid, \ - (action)->flags, \ - (flags_to_set), \ - #flags_to_set); \ - } while (0) - -#define pe__clear_action_flags_as(function, line, action, flags_to_clear) do { \ - (action)->flags = pcmk__clear_flags_as((function), (line), \ - LOG_TRACE, \ - "Action", (action)->uuid, \ - (action)->flags, \ - (flags_to_clear), \ - #flags_to_clear); \ - } while (0) - -#define pe__set_order_flags(order_flags, flags_to_set) do { \ - order_flags = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE, \ - "Ordering", "constraint", \ - order_flags, (flags_to_set), \ - #flags_to_set); \ - } while (0) - -#define pe__clear_order_flags(order_flags, flags_to_clear) do { \ - order_flags = pcmk__clear_flags_as(__func__, __LINE__, LOG_TRACE, \ - "Ordering", "constraint", \ - order_flags, (flags_to_clear), \ - #flags_to_clear); \ - } while (0) - -#define pe_warn_once(pe_wo_bit, fmt...) do { \ - if (!pcmk_is_set(pcmk__warnings, pe_wo_bit)) { \ - if (pe_wo_bit == pcmk__wo_blind) { \ - crm_warn(fmt); \ - } else { \ - pe_warn(fmt); \ - } \ - pcmk__warnings = pcmk__set_flags_as(__func__, __LINE__, \ - LOG_TRACE, \ - "Warn-once", "logging", \ - pcmk__warnings, \ - (pe_wo_bit), #pe_wo_bit); \ - } \ - } while (0); - - -typedef struct pe__location_constraint_s { - char *id; // Constraint XML ID - pcmk_resource_t *rsc_lh; // Resource being located - enum rsc_role_e role_filter; // Role to locate - enum pe_discover_e discover_mode; // Resource discovery - GList *node_list_rh; // List of pcmk_node_t* -} pe__location_t; - -typedef struct pe__order_constraint_s { - int id; - uint32_t flags; // Group of enum pcmk__action_relation_flags - - void *lh_opaque; - pcmk_resource_t *lh_rsc; - pcmk_action_t *lh_action; - char *lh_action_task; - - void *rh_opaque; - pcmk_resource_t *rh_rsc; - pcmk_action_t *rh_action; - char *rh_action_task; -} pe__ordering_t; - const pcmk_resource_t *pe__const_top_resource(const pcmk_resource_t *rsc, bool include_bundle); @@ -201,16 +54,10 @@ void pe__create_promotable_pseudo_ops(pcmk_resource_t *clone, bool pe_can_fence(const pcmk_scheduler_t *scheduler, const pcmk_node_t *node); -void add_hash_param(GHashTable * hash, const char *name, const char *value); - char *native_parameter(pcmk_resource_t *rsc, pcmk_node_t *node, gboolean create, const char *name, pcmk_scheduler_t *scheduler); pcmk_node_t *native_location(const pcmk_resource_t *rsc, GList **list, int current); - -void pe_metadata(pcmk__output_t *out); -void verify_pe_options(GHashTable * options); - void native_add_running(pcmk_resource_t *rsc, pcmk_node_t *node, pcmk_scheduler_t *scheduler, gboolean failed); @@ -247,8 +94,8 @@ gchar *pcmk__native_output_string(const pcmk_resource_t *rsc, const char *name, const pcmk_node_t *node, uint32_t show_opts, const char *target_role, bool show_nodes); -int pe__name_and_nvpairs_xml(pcmk__output_t *out, bool is_list, const char *tag_name - , size_t pairs_count, ...); +int pe__name_and_nvpairs_xml(pcmk__output_t *out, bool is_list, const char *tag_name, + ...) G_GNUC_NULL_TERMINATED; char *pe__node_display_name(pcmk_node_t *node, bool print_detail); @@ -258,12 +105,7 @@ void pe__order_notifs_after_fencing(const pcmk_action_t *action, pcmk_action_t *stonith_op); -static inline const char * -pe__rsc_bool_str(const pcmk_resource_t *rsc, uint64_t rsc_flag) -{ - return pcmk__btoa(pcmk_is_set(rsc->flags, rsc_flag)); -} - +// Resource output methods int pe__clone_xml(pcmk__output_t *out, va_list args); int pe__clone_default(pcmk__output_t *out, va_list args); int pe__group_xml(pcmk__output_t *out, va_list args); @@ -319,13 +161,6 @@ bool pe__count_active_node(const pcmk_resource_t *rsc, pcmk_node_t *node, pcmk_node_t *pe__find_active_requires(const pcmk_resource_t *rsc, unsigned int *count); -static inline pcmk_node_t * -pe__current_node(const pcmk_resource_t *rsc) -{ - return (rsc == NULL)? NULL : rsc->fns->active_node(rsc, NULL, NULL); -} - - /* Binary like operators for lists of nodes */ GHashTable *pe__node_list2table(const GList *list); @@ -396,9 +231,6 @@ pcmk_action_t *custom_action(pcmk_resource_t *rsc, char *key, const char *task, rsc, demote_key(rsc), PCMK_ACTION_DEMOTE, node, \ optional, rsc->cluster) -extern int pe_get_configured_timeout(pcmk_resource_t *rsc, const char *action, - pcmk_scheduler_t *scheduler); - pcmk_action_t *find_first_action(const GList *input, const char *uuid, const char *task, const pcmk_node_t *on_node); @@ -451,17 +283,7 @@ int pe__target_rc_from_xml(const xmlNode *xml_op); gint pe__cmp_node_name(gconstpointer a, gconstpointer b); bool is_set_recursive(const pcmk_resource_t *rsc, long long flag, bool any); -typedef struct op_digest_cache_s { - enum pcmk__digest_result rc; - xmlNode *params_all; - xmlNode *params_secure; - xmlNode *params_restart; - char *digest_all_calc; - char *digest_secure_calc; - char *digest_restart_calc; -} op_digest_cache_t; - -op_digest_cache_t *pe__calculate_digests(pcmk_resource_t *rsc, const char *task, +pcmk__op_digest_t *pe__calculate_digests(pcmk_resource_t *rsc, const char *task, guint *interval_ms, const pcmk_node_t *node, const xmlNode *xml_op, @@ -471,7 +293,7 @@ op_digest_cache_t *pe__calculate_digests(pcmk_resource_t *rsc, const char *task, void pe__free_digests(gpointer ptr); -op_digest_cache_t *rsc_action_digest_cmp(pcmk_resource_t *rsc, +pcmk__op_digest_t *rsc_action_digest_cmp(pcmk_resource_t *rsc, const xmlNode *xml_op, pcmk_node_t *node, pcmk_scheduler_t *scheduler); @@ -515,17 +337,6 @@ int pe__common_output_html(pcmk__output_t *out, const pcmk_resource_t *rsc, const char *name, const pcmk_node_t *node, unsigned int options); -//! A single instance of a bundle -typedef struct { - int offset; //!< 0-origin index of this instance in bundle - char *ipaddr; //!< IP address associated with this instance - pcmk_node_t *node; //!< Node created for this instance - pcmk_resource_t *ip; //!< IP address resource for ipaddr - pcmk_resource_t *child; //!< Instance of bundled resource - pcmk_resource_t *container; //!< Container associated with this instance - pcmk_resource_t *remote; //!< Pacemaker Remote connection into container -} pe__bundle_replica_t; - GList *pe__bundle_containers(const pcmk_resource_t *bundle); int pe__bundle_max(const pcmk_resource_t *rsc); @@ -535,25 +346,17 @@ pcmk_resource_t *pe__bundled_resource(const pcmk_resource_t *rsc); const pcmk_resource_t *pe__get_rsc_in_container(const pcmk_resource_t *instance); pcmk_resource_t *pe__first_container(const pcmk_resource_t *bundle); void pe__foreach_bundle_replica(pcmk_resource_t *bundle, - bool (*fn)(pe__bundle_replica_t *, void *), + bool (*fn)(pcmk__bundle_replica_t *, void *), void *user_data); void pe__foreach_const_bundle_replica(const pcmk_resource_t *bundle, - bool (*fn)(const pe__bundle_replica_t *, + bool (*fn)(const pcmk__bundle_replica_t *, void *), void *user_data); pcmk_resource_t *pe__find_bundle_replica(const pcmk_resource_t *bundle, const pcmk_node_t *node); bool pe__bundle_needs_remote_name(pcmk_resource_t *rsc); -const char *pe__add_bundle_remote_name(pcmk_resource_t *rsc, - pcmk_scheduler_t *scheduler, - xmlNode *xml, const char *field); - -const char *pe__node_attribute_calculated(const pcmk_node_t *node, - const char *name, - const pcmk_resource_t *rsc, - enum pcmk__rsc_node node_type, - bool force_host); -const char *pe_node_attribute_raw(const pcmk_node_t *node, const char *name); +const char *pe__add_bundle_remote_name(pcmk_resource_t *rsc, xmlNode *xml, + const char *field); bool pe__is_universal_clone(const pcmk_resource_t *rsc, const pcmk_scheduler_t *scheduler); void pe__add_param_check(const xmlNode *rsc_op, pcmk_resource_t *rsc, @@ -621,81 +424,18 @@ int pe__node_health(pcmk_node_t *node); static inline enum pcmk__health_strategy pe__health_strategy(pcmk_scheduler_t *scheduler) { - return pcmk__parse_health_strategy(pe_pref(scheduler->config_hash, - PCMK__OPT_NODE_HEALTH_STRATEGY)); + const char *strategy = pcmk__cluster_option(scheduler->config_hash, + PCMK_OPT_NODE_HEALTH_STRATEGY); + + return pcmk__parse_health_strategy(strategy); } static inline int pe__health_score(const char *option, pcmk_scheduler_t *scheduler) { - return char2score(pe_pref(scheduler->config_hash, option)); -} - -/*! - * \internal - * \brief Return a string suitable for logging as a node name - * - * \param[in] node Node to return a node name string for - * - * \return Node name if available, otherwise node ID if available, - * otherwise "unspecified node" if node is NULL or "unidentified node" - * if node has neither a name nor ID. - */ -static inline const char * -pe__node_name(const pcmk_node_t *node) -{ - if (node == NULL) { - return "unspecified node"; - - } else if (node->details->uname != NULL) { - return node->details->uname; - - } else if (node->details->id != NULL) { - return node->details->id; - - } else { - return "unidentified node"; - } -} - -/*! - * \internal - * \brief Check whether two node objects refer to the same node - * - * \param[in] node1 First node object to compare - * \param[in] node2 Second node object to compare - * - * \return true if \p node1 and \p node2 refer to the same node - */ -static inline bool -pe__same_node(const pcmk_node_t *node1, const pcmk_node_t *node2) -{ - return (node1 != NULL) && (node2 != NULL) - && (node1->details == node2->details); -} + const char *value = pcmk__cluster_option(scheduler->config_hash, option); -/*! - * \internal - * \brief Get the operation key from an action history entry - * - * \param[in] xml Action history entry - * - * \return Entry's operation key - */ -static inline const char * -pe__xe_history_key(const xmlNode *xml) -{ - if (xml == NULL) { - return NULL; - } else { - /* @COMPAT Pacemaker <= 1.1.5 did not add the key, and used the ID - * instead. Checking for that allows us to process old saved CIBs, - * including some regression tests. - */ - const char *key = crm_element_value(xml, XML_LRM_ATTR_TASK_KEY); - - return pcmk__str_empty(key)? ID(xml) : key; - } + return char2score(value); } #endif diff --git a/include/crm/pengine/pe_types_compat.h b/include/crm/pengine/pe_types_compat.h index 1becd12..ccd0a5f 100644 --- a/include/crm/pengine/pe_types_compat.h +++ b/include/crm/pengine/pe_types_compat.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2023 the Pacemaker project contributors + * Copyright 2004-2024 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -25,64 +25,65 @@ extern "C" { * release. */ -//! \deprecated Use pcmk_rsc_removed instead +//! \deprecated Do not use #define pe_rsc_orphan pcmk_rsc_removed -//! \deprecated Use pcmk_rsc_managed instead +// NOTE: sbd (as of at least 1.5.2) uses this +//! \deprecated Do not use #define pe_rsc_managed pcmk_rsc_managed -//! \deprecated Use pcmk_rsc_blocked instead +//! \deprecated Do not use #define pe_rsc_block pcmk_rsc_blocked -//! \deprecated Use pcmk_rsc_removed_filler instead +//! \deprecated Do not use #define pe_rsc_orphan_container_filler pcmk_rsc_removed_filler -//! \deprecated Use pcmk_rsc_notify instead +//! \deprecated Do not use #define pe_rsc_notify pcmk_rsc_notify -//! \deprecated Use pcmk_rsc_unique instead +//! \deprecated Do not use #define pe_rsc_unique pcmk_rsc_unique -//! \deprecated Use pcmk_rsc_fence_device instead +//! \deprecated Do not use #define pe_rsc_fence_device pcmk_rsc_fence_device -//! \deprecated Use pcmk_rsc_promotable instead +//! \deprecated Do not use #define pe_rsc_promotable pcmk_rsc_promotable -//! \deprecated Use pcmk_rsc_unassigned instead +//! \deprecated Do not use #define pe_rsc_provisional pcmk_rsc_unassigned -//! \deprecated Use pcmk_rsc_assigning instead +//! \deprecated Do not use #define pe_rsc_allocating pcmk_rsc_assigning -//! \deprecated Use pcmk_rsc_updating_nodes instead +//! \deprecated Do not use #define pe_rsc_merging pcmk_rsc_updating_nodes -//! \deprecated Use pcmk_rsc_restarting instead +//! \deprecated Do not use #define pe_rsc_restarting pcmk_rsc_restarting -//! \deprecated Use pcmk_rsc_stop_if_failed instead +//! \deprecated Do not use #define pe_rsc_stop pcmk_rsc_stop_if_failed -//! \deprecated Use pcmk_rsc_reload instead +//! \deprecated Do not use #define pe_rsc_reload pcmk_rsc_reload -//! \deprecated Use pcmk_rsc_remote_nesting_allowed instead +//! \deprecated Do not use #define pe_rsc_allow_remote_remotes pcmk_rsc_remote_nesting_allowed -//! \deprecated Use pcmk_rsc_critical instead +//! \deprecated Do not use #define pe_rsc_critical pcmk_rsc_critical -//! \deprecated Use pcmk_rsc_failed instead +//! \deprecated Do not use #define pe_rsc_failed pcmk_rsc_failed -//! \deprecated Use pcmk_rsc_detect_loop instead +//! \deprecated Do not use #define pe_rsc_detect_loop pcmk_rsc_detect_loop //! \deprecated Do not use #define pe_rsc_runnable pcmk_rsc_runnable -//! \deprecated Use pcmk_rsc_start_pending instead +//! \deprecated Do not use #define pe_rsc_start_pending pcmk_rsc_start_pending //!< \deprecated Do not use @@ -91,106 +92,108 @@ extern "C" { //!< \deprecated Do not use #define pe_rsc_stopping pcmk_rsc_stopping -//! \deprecated Use pcmk_rsc_stop_unexpected instead +//! \deprecated Do not use #define pe_rsc_stop_unexpected pcmk_rsc_stop_unexpected -//! \deprecated Use pcmk_rsc_migratable instead +//! \deprecated Do not use #define pe_rsc_allow_migrate pcmk_rsc_migratable -//! \deprecated Use pcmk_rsc_ignore_failure instead +//! \deprecated Do not use #define pe_rsc_failure_ignored pcmk_rsc_ignore_failure -//! \deprecated Use pcmk_rsc_replica_container instead +//! \deprecated Do not use #define pe_rsc_replica_container pcmk_rsc_replica_container -//! \deprecated Use pcmk_rsc_maintenance instead +//! \deprecated Do not use #define pe_rsc_maintenance pcmk_rsc_maintenance //! \deprecated Do not use #define pe_rsc_is_container pcmk_rsc_has_filler -//! \deprecated Use pcmk_rsc_needs_quorum instead +//! \deprecated Do not use #define pe_rsc_needs_quorum pcmk_rsc_needs_quorum -//! \deprecated Use pcmk_rsc_needs_fencing instead +//! \deprecated Do not use #define pe_rsc_needs_fencing pcmk_rsc_needs_fencing -//! \deprecated Use pcmk_rsc_needs_unfencing instead +//! \deprecated Do not use #define pe_rsc_needs_unfencing pcmk_rsc_needs_unfencing -//! \deprecated Use pcmk_sched_quorate instead +// NOTE: sbd (as of at least 1.5.2) uses this +//! \deprecated Do not use #define pe_flag_have_quorum pcmk_sched_quorate -//! \deprecated Use pcmk_sched_symmetric_cluster instead +//! \deprecated Do not use #define pe_flag_symmetric_cluster pcmk_sched_symmetric_cluster -//! \deprecated Use pcmk_sched_in_maintenance instead +//! \deprecated Do not use #define pe_flag_maintenance_mode pcmk_sched_in_maintenance -//! \deprecated Use pcmk_sched_fencing_enabled instead +//! \deprecated Do not use #define pe_flag_stonith_enabled pcmk_sched_fencing_enabled -//! \deprecated Use pcmk_sched_have_fencing instead +// NOTE: sbd (as of at least 1.5.2) uses this +//! \deprecated Do not use #define pe_flag_have_stonith_resource pcmk_sched_have_fencing -//! \deprecated Use pcmk_sched_enable_unfencing instead +//! \deprecated Do not use #define pe_flag_enable_unfencing pcmk_sched_enable_unfencing -//! \deprecated Use pcmk_sched_concurrent_fencing instead +//! \deprecated Do not use #define pe_flag_concurrent_fencing pcmk_sched_concurrent_fencing -//! \deprecated Use pcmk_sched_stop_removed_resources instead +//! \deprecated Do not use #define pe_flag_stop_rsc_orphans pcmk_sched_stop_removed_resources -//! \deprecated Use pcmk_sched_cancel_removed_actions instead +//! \deprecated Do not use #define pe_flag_stop_action_orphans pcmk_sched_cancel_removed_actions -//! \deprecated Use pcmk_sched_stop_all instead +//! \deprecated Do not use #define pe_flag_stop_everything pcmk_sched_stop_all -//! \deprecated Use pcmk_sched_start_failure_fatal instead +//! \deprecated Do not use #define pe_flag_start_failure_fatal pcmk_sched_start_failure_fatal //! \deprecated Do not use #define pe_flag_remove_after_stop pcmk_sched_remove_after_stop -//! \deprecated Use pcmk_sched_startup_fencing instead +//! \deprecated Do not use #define pe_flag_startup_fencing pcmk_sched_startup_fencing -//! \deprecated Use pcmk_sched_shutdown_lock instead +//! \deprecated Do not use #define pe_flag_shutdown_lock pcmk_sched_shutdown_lock -//! \deprecated Use pcmk_sched_probe_resources instead +//! \deprecated Do not use #define pe_flag_startup_probes pcmk_sched_probe_resources -//! \deprecated Use pcmk_sched_have_status instead +//! \deprecated Do not use #define pe_flag_have_status pcmk_sched_have_status -//! \deprecated Use pcmk_sched_have_remote_nodes instead +//! \deprecated Do not use #define pe_flag_have_remote_nodes pcmk_sched_have_remote_nodes -//! \deprecated Use pcmk_sched_location_only instead +//! \deprecated Do not use #define pe_flag_quick_location pcmk_sched_location_only -//! \deprecated Use pcmk_sched_sanitized instead +//! \deprecated Do not use #define pe_flag_sanitized pcmk_sched_sanitized //! \deprecated Do not use #define pe_flag_stdout (1ULL << 22) -//! \deprecated Use pcmk_sched_no_counts instead +//! \deprecated Do not use #define pe_flag_no_counts pcmk_sched_no_counts -//! \deprecated Use pcmk_sched_no_compat instead +//! \deprecated Do not use #define pe_flag_no_compat pcmk_sched_no_compat -//! \deprecated Use pcmk_sched_output_scores instead +//! \deprecated Do not use #define pe_flag_show_scores pcmk_sched_output_scores -//! \deprecated Use pcmk_sched_show_utilization instead +//! \deprecated Do not use #define pe_flag_show_utilization pcmk_sched_show_utilization -//! \deprecated Use pcmk_sched_validate_only instead +//! \deprecated Do not use #define pe_flag_check_config pcmk_sched_validate_only //!@{ @@ -223,6 +226,7 @@ typedef struct pe_action_wrapper_s action_wrapper_t; //! \deprecated Do not use typedef struct pe_action_wrapper_s pe_action_wrapper_t; +// NOTE: sbd (as of at least 1.5.2) uses this //! \deprecated Use pcmk_node_t instead typedef struct pe_node_s node_t; @@ -232,24 +236,26 @@ typedef struct pe_node_s pe_node_t; //! \deprecated Use enum pe_quorum_policy instead typedef enum pe_quorum_policy no_quorum_policy_t; +// NOTE: sbd (as of at least 1.5.2) uses this //! \deprecated use pcmk_resource_t instead typedef struct pe_resource_s resource_t; //! \deprecated use pcmk_resource_t instead typedef struct pe_resource_s pe_resource_t; -//! \deprecated Use pcmk_tag_t instead +//! \deprecated Do not use typedef struct pe_tag_s tag_t; -//! \deprecated Use pcmk_tag_t instead +//! \deprecated Do not use typedef struct pe_tag_s pe_tag_t; -//! \deprecated Use pcmk_ticket_t instead +//! \deprecated Do not use typedef struct pe_ticket_s ticket_t; -//! \deprecated Use pcmk_ticket_t instead +//! \deprecated Do not use typedef struct pe_ticket_s pe_ticket_t; +// NOTE: sbd (as of at least 1.5.2) uses this //! \deprecated Use pcmk_scheduler_t instead typedef struct pe_working_set_s pe_working_set_t; diff --git a/include/crm/pengine/remote_internal.h b/include/crm/pengine/remote_internal.h index 0e7c044..138574c 100644 --- a/include/crm/pengine/remote_internal.h +++ b/include/crm/pengine/remote_internal.h @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the Pacemaker project contributors + * Copyright 2013-2024 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -19,11 +19,6 @@ extern "C" { #include <crm/pengine/status.h> bool xml_contains_remote_node(xmlNode *xml); -bool pe__is_remote_node(const pcmk_node_t *node); -bool pe__is_guest_node(const pcmk_node_t *node); -bool pe__is_guest_or_remote_node(const pcmk_node_t *node); -bool pe__is_bundle_node(const pcmk_node_t *node); -bool pe__resource_is_remote_conn(const pcmk_resource_t *rsc); pcmk_resource_t *pe__resource_contains_guest_node(const pcmk_scheduler_t *scheduler, const pcmk_resource_t *rsc); void pe_foreach_guest_node(const pcmk_scheduler_t *scheduler, diff --git a/include/crm/pengine/rules.h b/include/crm/pengine/rules.h index 264bd69..27b9a2d 100644 --- a/include/crm/pengine/rules.h +++ b/include/crm/pengine/rules.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the Pacemaker project contributors + * Copyright 2004-2024 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -13,41 +13,13 @@ # include <glib.h> # include <crm/crm.h> # include <crm/common/iso8601.h> +# include <crm/common/scheduler.h> # include <crm/pengine/common.h> #ifdef __cplusplus extern "C" { #endif -enum expression_type { - not_expr = 0, - nested_rule = 1, - attr_expr = 2, - loc_expr = 3, - role_expr = 4, - time_expr = 5, -#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) - //! \deprecated Do not use (will be removed in a future release) - version_expr = 6, -#endif - rsc_expr = 7, - op_expr = 8, -}; - -enum expression_type find_expression_type(xmlNode * expr); - -gboolean pe_evaluate_rules(xmlNode *ruleset, GHashTable *node_hash, - crm_time_t *now, crm_time_t *next_change); - -gboolean pe_test_rule(xmlNode *rule, GHashTable *node_hash, - enum rsc_role_e role, crm_time_t *now, - crm_time_t *next_change, pe_match_data_t *match_data); - -gboolean pe_test_expression(xmlNode *expr, GHashTable *node_hash, - enum rsc_role_e role, crm_time_t *now, - crm_time_t *next_change, - pe_match_data_t *match_data); - void pe_eval_nvpairs(xmlNode *top, const xmlNode *xml_obj, const char *set_name, const pe_rule_eval_data_t *rule_data, GHashTable *hash, const char *always_first, gboolean overwrite, @@ -59,16 +31,6 @@ void pe_unpack_nvpairs(xmlNode *top, const xmlNode *xml_obj, gboolean overwrite, crm_time_t *now, crm_time_t *next_change); -char *pe_expand_re_matches(const char *string, - const pe_re_match_data_t *match_data); - -gboolean pe_eval_rules(xmlNode *ruleset, const pe_rule_eval_data_t *rule_data, - crm_time_t *next_change); -gboolean pe_eval_expr(xmlNode *rule, const pe_rule_eval_data_t *rule_data, - crm_time_t *next_change); -gboolean pe_eval_subexpr(xmlNode *expr, const pe_rule_eval_data_t *rule_data, - crm_time_t *next_change); - #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) #include <crm/pengine/rules_compat.h> #endif diff --git a/include/crm/pengine/rules_compat.h b/include/crm/pengine/rules_compat.h index 95fc9ac..8dcaabb 100644 --- a/include/crm/pengine/rules_compat.h +++ b/include/crm/pengine/rules_compat.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2021 the Pacemaker project contributors + * Copyright 2004-2024 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -28,43 +28,77 @@ extern "C" { * release. */ -//! \deprecated Use pe_evaluate_rules() instead +//! \deprecated Use pcmk_evaluate_rule() on each rule instead +gboolean pe_evaluate_rules(xmlNode *ruleset, GHashTable *node_hash, + crm_time_t *now, crm_time_t *next_change); + +//! \deprecated Use pcmk_evaluate_rule() on each rule instead +gboolean pe_eval_rules(xmlNode *ruleset, const pe_rule_eval_data_t *rule_data, + crm_time_t *next_change); + +//! \deprecated Use pcmk_evaluate_rule() on each rule instead gboolean test_ruleset(xmlNode *ruleset, GHashTable *node_hash, crm_time_t *now); -//! \deprecated Use pe_test_rule() instead +//! \deprecated Use pcmk_evaluate_rule() instead gboolean test_rule(xmlNode *rule, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now); -//! \deprecated Use pe_test_rule() instead +//! \deprecated Use pcmk_evaluate_rule() instead +gboolean pe_test_rule(xmlNode *rule, GHashTable *node_hash, + enum rsc_role_e role, crm_time_t *now, + crm_time_t *next_change, pe_match_data_t *match_data); + +//! \deprecated Use pcmk_evaluate_rule() instead gboolean pe_test_rule_re(xmlNode *rule, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now, pe_re_match_data_t *re_match_data); -//! \deprecated Use pe_test_rule() instead +//! \deprecated Use pcmk_evaluate_rule() instead gboolean pe_test_rule_full(xmlNode *rule, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now, pe_match_data_t *match_data); -//! \deprecated Use pe_test_expression() instead +//! \deprecated Use pcmk_evaluate_rule() on parent rule instead +gboolean pe_test_expression(xmlNode *expr, GHashTable *node_hash, + enum rsc_role_e role, crm_time_t *now, + crm_time_t *next_change, + pe_match_data_t *match_data); + +//! \deprecated Use pcmk_evaluate_rule() on parent rule instead gboolean test_expression(xmlNode *expr, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now); -//! \deprecated Use pe_test_expression() instead +//! \deprecated Use pcmk_evaluate_rule() on parent rule instead gboolean pe_test_expression_re(xmlNode *expr, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now, pe_re_match_data_t *re_match_data); -//! \deprecated Use pe_test_expression() instead +//! \deprecated Use pcmk_evaluate_rule() on parent rule instead gboolean pe_test_expression_full(xmlNode *expr, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now, pe_match_data_t *match_data); +//! \deprecated Use pcmk_evaluate_rule() on parent rule instead +gboolean pe_eval_expr(xmlNode *rule, const pe_rule_eval_data_t *rule_data, + crm_time_t *next_change); + +//! \deprecated Use pcmk_evaluate_rule() on parent rule instead +gboolean pe_eval_subexpr(xmlNode *expr, const pe_rule_eval_data_t *rule_data, + crm_time_t *next_change); + //! \deprecated Use pe_unpack_nvpairs() instead void unpack_instance_attributes(xmlNode *top, xmlNode *xml_obj, const char *set_name, GHashTable *node_hash, GHashTable *hash, const char *always_first, gboolean overwrite, crm_time_t *now); +//! \deprecated Do not use +enum expression_type find_expression_type(xmlNode *expr); + +//! \deprecated Do not use +char *pe_expand_re_matches(const char *string, + const pe_re_match_data_t *match_data); + #ifdef __cplusplus } #endif diff --git a/include/crm/pengine/rules_internal.h b/include/crm/pengine/rules_internal.h index 9b81963..d659ee0 100644 --- a/include/crm/pengine/rules_internal.h +++ b/include/crm/pengine/rules_internal.h @@ -1,5 +1,5 @@ /* - * Copyright 2015-2022 the Pacemaker project contributors + * Copyright 2015-2024 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -19,18 +19,4 @@ GList *pe_unpack_alerts(const xmlNode *alerts); void pe_free_alert_list(GList *alert_list); -gboolean pe__eval_attr_expr(const xmlNode *expr, - const pe_rule_eval_data_t *rule_data); -int pe__eval_date_expr(const xmlNode *expr, - const pe_rule_eval_data_t *rule_data, - crm_time_t *next_change); -gboolean pe__eval_op_expr(const xmlNode *expr, - const pe_rule_eval_data_t *rule_data); -gboolean pe__eval_role_expr(const xmlNode *expr, - const pe_rule_eval_data_t *rule_data); -gboolean pe__eval_rsc_expr(const xmlNode *expr, - const pe_rule_eval_data_t *rule_data); - -int pe_cron_range_satisfied(const crm_time_t *now, const xmlNode *cron_spec); - #endif diff --git a/include/crm/pengine/status.h b/include/crm/pengine/status.h index 9c85425..037d3fa 100644 --- a/include/crm/pengine/status.h +++ b/include/crm/pengine/status.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2023 the Pacemaker project contributors + * Copyright 2004-2024 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -29,16 +29,25 @@ extern "C" { */ const char *rsc_printable_id(const pcmk_resource_t *rsc); + +// NOTE: sbd (as of at least 1.5.2) uses this gboolean cluster_status(pcmk_scheduler_t *scheduler); + +// NOTE: sbd (as of at least 1.5.2) uses this pcmk_scheduler_t *pe_new_working_set(void); + +// NOTE: sbd (as of at least 1.5.2) uses this void pe_free_working_set(pcmk_scheduler_t *scheduler); + void set_working_set_defaults(pcmk_scheduler_t *scheduler); void cleanup_calculations(pcmk_scheduler_t *scheduler); + +// NOTE: sbd (as of at least 1.5.2) uses this void pe_reset_working_set(pcmk_scheduler_t *scheduler); + pcmk_resource_t *pe_find_resource(GList *rsc_list, const char *id_rh); pcmk_resource_t *pe_find_resource_with_flags(GList *rsc_list, const char *id, enum pe_find flags); -pcmk_node_t *pe_find_node(const GList *node_list, const char *node_name); pcmk_node_t *pe_find_node_id(const GList *node_list, const char *id); pcmk_node_t *pe_find_node_any(const GList *node_list, const char *id, const char *node_name); @@ -48,63 +57,9 @@ void calculate_active_ops(const GList *sorted_op_list, int *start_index, int *stop_index); int pe_bundle_replicas(const pcmk_resource_t *rsc); -/*! - * \brief Check whether a resource is any clone type - * - * \param[in] rsc Resource to check - * - * \return true if resource is clone, false otherwise - */ -static inline bool -pe_rsc_is_clone(const pcmk_resource_t *rsc) -{ - return (rsc != NULL) && (rsc->variant == pcmk_rsc_variant_clone); -} - -/*! - * \brief Check whether a resource is a globally unique clone - * - * \param[in] rsc Resource to check - * - * \return true if resource is unique clone, false otherwise - */ -static inline bool -pe_rsc_is_unique_clone(const pcmk_resource_t *rsc) -{ - return pe_rsc_is_clone(rsc) && pcmk_is_set(rsc->flags, pcmk_rsc_unique); -} - -/*! - * \brief Check whether a resource is an anonymous clone - * - * \param[in] rsc Resource to check - * - * \return true if resource is anonymous clone, false otherwise - */ -static inline bool -pe_rsc_is_anon_clone(const pcmk_resource_t *rsc) -{ - return pe_rsc_is_clone(rsc) && !pcmk_is_set(rsc->flags, pcmk_rsc_unique); -} - -/*! - * \brief Check whether a resource is part of a bundle - * - * \param[in] rsc Resource to check - * - * \return true if resource is part of a bundle, false otherwise - */ -static inline bool -pe_rsc_is_bundled(const pcmk_resource_t *rsc) -{ - if (rsc == NULL) { - return false; - } - while (rsc->parent != NULL) { - rsc = rsc->parent; - } - return rsc->variant == pcmk_rsc_variant_bundle; -} +#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) +#include <crm/pengine/status_compat.h> +#endif #ifdef __cplusplus } diff --git a/include/crm/pengine/status_compat.h b/include/crm/pengine/status_compat.h new file mode 100644 index 0000000..1ff5506 --- /dev/null +++ b/include/crm/pengine/status_compat.h @@ -0,0 +1,72 @@ +/* + * 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_PENGINE_STATUS_COMPAT__H +#define PCMK__CRM_PENGINE_STATUS_COMPAT__H + +#include <stdbool.h> // bool +#include <crm/common/util.h> // pcmk_is_set() +#include <crm/common/scheduler.h> // pcmk_resource_t, pcmk_rsc_unique, etc. + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file + * \brief Deprecated Pacemaker scheduler utilities + * \ingroup pengine + * \deprecated Do not include this header directly. The utilities in this + * header, and the header itself, will be removed in a future + * release. + */ + +// NOTE: sbd (as of at least 1.5.2) uses this +//! \deprecated Use pcmk_find_node() with scheduler object instead +pcmk_node_t *pe_find_node(const GList *node_list, const char *node_name); + +//! \deprecated Compare variant directly instead +static inline bool +pe_rsc_is_clone(const pcmk_resource_t *rsc) +{ + return (rsc != NULL) && (rsc->variant == pcmk_rsc_variant_clone); +} + +//! \deprecated Compare variant and flags directly +static inline bool +pe_rsc_is_unique_clone(const pcmk_resource_t *rsc) +{ + return pe_rsc_is_clone(rsc) && pcmk_is_set(rsc->flags, pcmk_rsc_unique); +} + +//! \deprecated Compare variant and flags directly +static inline bool +pe_rsc_is_anon_clone(const pcmk_resource_t *rsc) +{ + return pe_rsc_is_clone(rsc) && !pcmk_is_set(rsc->flags, pcmk_rsc_unique); +} + +//! \deprecated Compare ancestor variants directly +static inline bool +pe_rsc_is_bundled(const pcmk_resource_t *rsc) +{ + if (rsc == NULL) { + return false; + } + while (rsc->parent != NULL) { + rsc = rsc->parent; + } + return rsc->variant == pcmk_rsc_variant_bundle; +} + +#ifdef __cplusplus +} +#endif + +#endif // PCMK__CRM_PENGINE_STATUS_COMPAT__H |