1 /* 2 * Copyright 2004-2023 the Pacemaker project contributors 3 * 4 * The version control history for this file may have further details. 5 * 6 * This source code is licensed under the GNU Lesser General Public License 7 * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY. 8 */ 9 10 #ifndef PCMK__CRM_COMMON_SCHEDULER__H 11 # define PCMK__CRM_COMMON_SCHEDULER__H 12 13 #include <sys/types.h> // time_t 14 #include <libxml/tree.h> // xmlNode 15 #include <glib.h> // guint, GList, GHashTable 16 17 #include <crm/common/iso8601.h> // crm_time_t 18 19 #include <crm/common/actions.h> 20 #include <crm/common/nodes.h> 21 #include <crm/common/resources.h> 22 #include <crm/common/roles.h> 23 #include <crm/common/scheduler_types.h> 24 #include <crm/common/tags.h> 25 #include <crm/common/tickets.h> 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 /*! 32 * \file 33 * \brief Scheduler API 34 * \ingroup core 35 */ 36 37 //! Possible responses to loss of quorum 38 enum pe_quorum_policy { 39 pcmk_no_quorum_freeze, //<! Do not recover resources from outside partition 40 pcmk_no_quorum_stop, //<! Stop all resources in partition 41 pcmk_no_quorum_ignore, //<! Act as if partition still holds quorum 42 pcmk_no_quorum_fence, //<! Fence all nodes in partition 43 pcmk_no_quorum_demote, //<! Demote promotable resources and stop all others 44 45 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) 46 //! \deprecated Use pcmk_no_quorum_freeze instead 47 no_quorum_freeze = pcmk_no_quorum_freeze, 48 49 //! \deprecated Use pcmk_no_quorum_stop instead 50 no_quorum_stop = pcmk_no_quorum_stop, 51 52 //! \deprecated Use pcmk_no_quorum_ignore instead 53 no_quorum_ignore = pcmk_no_quorum_ignore, 54 55 //! \deprecated Use pcmk_no_quorum_fence instead 56 no_quorum_suicide = pcmk_no_quorum_fence, 57 58 //! \deprecated Use pcmk_no_quorum_demote instead 59 no_quorum_demote = pcmk_no_quorum_demote, 60 #endif 61 }; 62 63 //! Scheduling options and conditions 64 enum pcmk_scheduler_flags { 65 //! No scheduler flags set (compare with equality rather than bit set) 66 pcmk_sched_none = 0ULL, 67 68 // These flags are dynamically determined conditions 69 70 //! Whether partition has quorum (via have-quorum property) 71 pcmk_sched_quorate = (1ULL << 0), 72 73 //! Whether cluster is symmetric (via symmetric-cluster property) 74 pcmk_sched_symmetric_cluster = (1ULL << 1), 75 76 //! Whether cluster is in maintenance mode (via maintenance-mode property) 77 pcmk_sched_in_maintenance = (1ULL << 3), 78 79 //! Whether fencing is enabled (via stonith-enabled property) 80 pcmk_sched_fencing_enabled = (1ULL << 4), 81 82 //! Whether cluster has a fencing resource (via CIB resources) 83 pcmk_sched_have_fencing = (1ULL << 5), 84 85 //! Whether any resource provides or requires unfencing (via CIB resources) 86 pcmk_sched_enable_unfencing = (1ULL << 6), 87 88 //! Whether concurrent fencing is allowed (via concurrent-fencing property) 89 pcmk_sched_concurrent_fencing = (1ULL << 7), 90 91 /*! 92 * Whether resources removed from the configuration should be stopped (via 93 * stop-orphan-resources property) 94 */ 95 pcmk_sched_stop_removed_resources = (1ULL << 8), 96 97 /*! 98 * Whether recurring actions removed from the configuration should be 99 * cancelled (via stop-orphan-actions property) 100 */ 101 pcmk_sched_cancel_removed_actions = (1ULL << 9), 102 103 //! Whether to stop all resources (via stop-all-resources property) 104 pcmk_sched_stop_all = (1ULL << 10), 105 106 /*! 107 * Whether start failure should be treated as if migration-threshold is 1 108 * (via start-failure-is-fatal property) 109 */ 110 pcmk_sched_start_failure_fatal = (1ULL << 12), 111 112 //! \deprecated Do not use 113 pcmk_sched_remove_after_stop = (1ULL << 13), 114 115 //! Whether unseen nodes should be fenced (via startup-fencing property) 116 pcmk_sched_startup_fencing = (1ULL << 14), 117 118 /*! 119 * Whether resources should be left stopped when their node shuts down 120 * cleanly (via shutdown-lock property) 121 */ 122 pcmk_sched_shutdown_lock = (1ULL << 15), 123 124 /*! 125 * Whether resources' current state should be probed (when unknown) before 126 * scheduling any other actions (via the enable-startup-probes property) 127 */ 128 pcmk_sched_probe_resources = (1ULL << 16), 129 130 //! Whether the CIB status section has been parsed yet 131 pcmk_sched_have_status = (1ULL << 17), 132 133 //! Whether the cluster includes any Pacemaker Remote nodes (via CIB) 134 pcmk_sched_have_remote_nodes = (1ULL << 18), 135 136 // The remaining flags are scheduling options that must be set explicitly 137 138 /*! 139 * Whether to skip unpacking the CIB status section and stop the scheduling 140 * sequence after applying node-specific location criteria (skipping 141 * assignment, ordering, actions, etc.). 142 */ 143 pcmk_sched_location_only = (1ULL << 20), 144 145 //! Whether sensitive resource attributes have been masked 146 pcmk_sched_sanitized = (1ULL << 21), 147 148 //! Skip counting of total, disabled, and blocked resource instances 149 pcmk_sched_no_counts = (1ULL << 23), 150 151 /*! 152 * Skip deprecated code kept solely for backward API compatibility 153 * (internal code should always set this) 154 */ 155 pcmk_sched_no_compat = (1ULL << 24), 156 157 //! Whether node scores should be output instead of logged 158 pcmk_sched_output_scores = (1ULL << 25), 159 160 //! Whether to show node and resource utilization (in log or output) 161 pcmk_sched_show_utilization = (1ULL << 26), 162 163 /*! 164 * Whether to stop the scheduling sequence after unpacking the CIB, 165 * calculating cluster status, and applying node health (skipping 166 * applying node-specific location criteria, assignment, etc.) 167 */ 168 pcmk_sched_validate_only = (1ULL << 27), 169 }; 170 171 //! Implementation of pcmk_scheduler_t 172 struct pe_working_set_s { 173 // Be careful about when each piece of information is available and final 174 175 xmlNode *input; //!< CIB XML 176 crm_time_t *now; //!< Current time for evaluation purposes 177 char *dc_uuid; //!< Node ID of designated controller 178 pcmk_node_t *dc_node; //!< Node object for DC 179 const char *stonith_action; //!< Default fencing action 180 const char *placement_strategy; //!< Value of placement-strategy property 181 182 // @COMPAT Change to uint64_t at a compatibility break 183 unsigned long long flags; //!< Group of enum pcmk_scheduler_flags 184 185 int stonith_timeout; //!< Value of stonith-timeout property 186 enum pe_quorum_policy no_quorum_policy; //!< Response to loss of quorum 187 GHashTable *config_hash; //!< Cluster properties 188 189 //!< Ticket constraints unpacked from ticket state 190 GHashTable *tickets; 191 192 //! Actions for which there can be only one (such as "fence node X") 193 GHashTable *singletons; 194 195 GList *nodes; //!< Nodes in cluster 196 GList *resources; //!< Resources in cluster 197 GList *placement_constraints; //!< Location constraints 198 GList *ordering_constraints; //!< Ordering constraints 199 GList *colocation_constraints; //!< Colocation constraints 200 201 //!< Ticket constraints unpacked by libpacemaker 202 GList *ticket_constraints; 203 204 GList *actions; //!< Scheduled actions 205 xmlNode *failed; //!< History entries of failed actions 206 xmlNode *op_defaults; //!< Configured operation defaults 207 xmlNode *rsc_defaults; //!< Configured resource defaults 208 int num_synapse; //!< Number of transition graph synapses 209 int max_valid_nodes; //!< \deprecated Do not use 210 int order_id; //!< ID to use for next created ordering 211 int action_id; //!< ID to use for next created action 212 xmlNode *graph; //!< Transition graph 213 GHashTable *template_rsc_sets; //!< Mappings of template ID to resource ID 214 215 // @COMPAT Replace this with a fencer variable (only place it's used) 216 const char *localhost; //!< \deprecated Do not use 217 218 GHashTable *tags; //!< Configuration tags (ID -> pcmk_tag_t *) 219 int blocked_resources; //!< Number of blocked resources in cluster 220 int disabled_resources; //!< Number of disabled resources in cluster 221 GList *param_check; //!< History entries that need to be checked 222 GList *stop_needed; //!< Containers that need stop actions 223 time_t recheck_by; //!< Hint to controller when to reschedule 224 int ninstances; //!< Total number of resource instances 225 guint shutdown_lock; //!< How long to lock resources (seconds) 226 int priority_fencing_delay; //!< Priority fencing delay 227 228 // pcmk__output_t * 229 void *priv; //!< For Pacemaker use only 230 231 guint node_pending_timeout; //!< Pending join times out after this (ms) 232 }; 233 234 #ifdef __cplusplus 235 } 236 #endif 237 238 #endif // PCMK__CRM_COMMON_SCHEDULER__H