1 /* 2 * Copyright 2004-2024 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/rules.h> 24 #include <crm/common/scheduler_types.h> 25 #include <crm/common/tags.h> 26 #include <crm/common/tickets.h> 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 /*! 33 * \file 34 * \brief Scheduler API 35 * \ingroup core 36 */ 37 38 // NOTE: sbd (as of at least 1.5.2) uses this enum 39 //! Possible responses to loss of quorum 40 enum pe_quorum_policy { 41 pcmk_no_quorum_freeze, //<! Do not recover resources from outside partition 42 pcmk_no_quorum_stop, //<! Stop all resources in partition 43 pcmk_no_quorum_ignore, //<! Act as if partition still holds quorum 44 pcmk_no_quorum_fence, //<! Fence all nodes in partition 45 pcmk_no_quorum_demote, //<! Demote promotable resources and stop all others 46 47 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) 48 // NOTE: sbd (as of at least 1.5.2) uses this value 49 //! \deprecated Use pcmk_no_quorum_freeze instead 50 no_quorum_freeze = pcmk_no_quorum_freeze, 51 52 // NOTE: sbd (as of at least 1.5.2) uses this value 53 //! \deprecated Use pcmk_no_quorum_stop instead 54 no_quorum_stop = pcmk_no_quorum_stop, 55 56 // NOTE: sbd (as of at least 1.5.2) uses this value 57 //! \deprecated Use pcmk_no_quorum_ignore instead 58 no_quorum_ignore = pcmk_no_quorum_ignore, 59 60 //! \deprecated Use pcmk_no_quorum_fence instead 61 no_quorum_suicide = pcmk_no_quorum_fence, 62 63 // NOTE: sbd (as of at least 1.5.2) uses this value 64 //! \deprecated Use pcmk_no_quorum_demote instead 65 no_quorum_demote = pcmk_no_quorum_demote, 66 #endif 67 }; 68 69 // Scheduling options and conditions 70 //!@{ 71 //! \deprecated Do not use 72 enum pcmk_scheduler_flags { 73 // No scheduler flags set (compare with equality rather than bit set) 74 pcmk_sched_none = 0ULL, 75 76 /* These flags are dynamically determined conditions */ 77 78 // Whether partition has quorum (via \c PCMK_XA_HAVE_QUORUM attribute) 79 //! \deprecated Call pcmk_has_quorum() to check quorum instead 80 pcmk_sched_quorate = (1ULL << 0), 81 82 // Whether cluster is symmetric (via symmetric-cluster property) 83 pcmk_sched_symmetric_cluster = (1ULL << 1), 84 85 // Whether cluster is in maintenance mode (via maintenance-mode property) 86 pcmk_sched_in_maintenance = (1ULL << 3), 87 88 // Whether fencing is enabled (via stonith-enabled property) 89 pcmk_sched_fencing_enabled = (1ULL << 4), 90 91 // Whether cluster has a fencing resource (via CIB resources) 92 /*! \deprecated To indicate the cluster has a fencing resource, add either a 93 * fencing resource configuration or the have-watchdog cluster option to the 94 * input CIB 95 */ 96 pcmk_sched_have_fencing = (1ULL << 5), 97 98 // Whether any resource provides or requires unfencing (via CIB resources) 99 pcmk_sched_enable_unfencing = (1ULL << 6), 100 101 // Whether concurrent fencing is allowed (via concurrent-fencing property) 102 pcmk_sched_concurrent_fencing = (1ULL << 7), 103 104 /* 105 * Whether resources removed from the configuration should be stopped (via 106 * stop-orphan-resources property) 107 */ 108 pcmk_sched_stop_removed_resources = (1ULL << 8), 109 110 /* 111 * Whether recurring actions removed from the configuration should be 112 * cancelled (via stop-orphan-actions property) 113 */ 114 pcmk_sched_cancel_removed_actions = (1ULL << 9), 115 116 // Whether to stop all resources (via stop-all-resources property) 117 pcmk_sched_stop_all = (1ULL << 10), 118 119 /* 120 * Whether start failure should be treated as if 121 * \c PCMK_META_MIGRATION_THRESHOLD is 1 (via 122 * \c PCMK_OPT_START_FAILURE_IS_FATAL property) 123 */ 124 pcmk_sched_start_failure_fatal = (1ULL << 12), 125 126 // Unused 127 pcmk_sched_remove_after_stop = (1ULL << 13), 128 129 // Whether unseen nodes should be fenced (via startup-fencing property) 130 pcmk_sched_startup_fencing = (1ULL << 14), 131 132 /* 133 * Whether resources should be left stopped when their node shuts down 134 * cleanly (via shutdown-lock property) 135 */ 136 pcmk_sched_shutdown_lock = (1ULL << 15), 137 138 /* 139 * Whether resources' current state should be probed (when unknown) before 140 * scheduling any other actions (via the enable-startup-probes property) 141 */ 142 pcmk_sched_probe_resources = (1ULL << 16), 143 144 // Whether the CIB status section has been parsed yet 145 pcmk_sched_have_status = (1ULL << 17), 146 147 // Whether the cluster includes any Pacemaker Remote nodes (via CIB) 148 pcmk_sched_have_remote_nodes = (1ULL << 18), 149 150 151 /* The remaining flags are scheduling options that must be set explicitly */ 152 153 /* 154 * Whether to skip unpacking the CIB status section and stop the scheduling 155 * sequence after applying node-specific location criteria (skipping 156 * assignment, ordering, actions, etc.). 157 */ 158 pcmk_sched_location_only = (1ULL << 20), 159 160 // Whether sensitive resource attributes have been masked 161 pcmk_sched_sanitized = (1ULL << 21), 162 163 // Skip counting of total, disabled, and blocked resource instances 164 pcmk_sched_no_counts = (1ULL << 23), 165 166 /* 167 * Skip deprecated code kept solely for backward API compatibility 168 * (internal code should always set this) 169 */ 170 pcmk_sched_no_compat = (1ULL << 24), 171 172 // Whether node scores should be output instead of logged 173 pcmk_sched_output_scores = (1ULL << 25), 174 175 // Whether to show node and resource utilization (in log or output) 176 pcmk_sched_show_utilization = (1ULL << 26), 177 178 /* 179 * Whether to stop the scheduling sequence after unpacking the CIB, 180 * calculating cluster status, and applying node health (skipping 181 * applying node-specific location criteria, assignment, etc.) 182 */ 183 pcmk_sched_validate_only = (1ULL << 27), 184 }; 185 //!@} 186 187 // Implementation of pcmk_scheduler_t 188 // @COMPAT Make contents internal when we can break API backward compatibility 189 //!@{ 190 //! \deprecated Do not use (public access will be removed in a future release) 191 struct pe_working_set_s { 192 // Be careful about when each piece of information is available and final 193 194 // NOTE: sbd (as of at least 1.5.2) uses this 195 //! \deprecated Set scheduler input with pcmk_set_scheduler_cib() instead 196 xmlNode *input; // CIB XML 197 198 crm_time_t *now; // Current time for evaluation purposes 199 char *dc_uuid; // Node ID of designated controller 200 201 // NOTE: sbd (as of at least 1.5.2) uses this 202 //! \deprecated Call pcmk_get_dc() instead 203 pcmk_node_t *dc_node; // Node object for DC 204 205 const char *stonith_action; // Default fencing action 206 const char *placement_strategy; // Value of placement-strategy property 207 208 // NOTE: sbd (as of at least 1.5.2) uses this 209 // @COMPAT Change to uint64_t at a compatibility break 210 //! \deprecated Call pcmk_has_quorum() to check quorum 211 unsigned long long flags; // Group of enum pcmk_scheduler_flags 212 213 int stonith_timeout; // Value of stonith-timeout property 214 215 // NOTE: sbd (as of at least 1.5.2) uses this 216 //! \deprecated Call pcmk_get_no_quorum_policy() to get no-quorum policy 217 enum pe_quorum_policy no_quorum_policy; // Response to loss of quorum 218 219 GHashTable *config_hash; // Cluster properties 220 221 // Ticket constraints unpacked from ticket state 222 GHashTable *tickets; 223 224 // Actions for which there can be only one (such as "fence node X") 225 GHashTable *singletons; 226 227 // NOTE: sbd (as of at least 1.5.2) uses this 228 //! \deprecated Call pcmk_find_node() to find a node instead 229 GList *nodes; // Nodes in cluster 230 231 GList *resources; // Resources in cluster 232 GList *placement_constraints; // Location constraints 233 GList *ordering_constraints; // Ordering constraints 234 GList *colocation_constraints; // Colocation constraints 235 236 // Ticket constraints unpacked by libpacemaker 237 GList *ticket_constraints; 238 239 GList *actions; // Scheduled actions 240 xmlNode *failed; // History entries of failed actions 241 xmlNode *op_defaults; // Configured operation defaults 242 xmlNode *rsc_defaults; // Configured resource defaults 243 int num_synapse; // Number of transition graph synapses 244 int max_valid_nodes; // \deprecated Do not use 245 int order_id; // ID to use for next created ordering 246 int action_id; // ID to use for next created action 247 xmlNode *graph; // Transition graph 248 GHashTable *template_rsc_sets; // Mappings of template ID to resource ID 249 250 // @COMPAT Replace this with a fencer variable (only place it's used) 251 const char *localhost; // \deprecated Do not use 252 253 GHashTable *tags; // Configuration tags (ID -> pcmk_tag_t *) 254 int blocked_resources; // Number of blocked resources in cluster 255 int disabled_resources; // Number of disabled resources in cluster 256 GList *param_check; // History entries that need to be checked 257 GList *stop_needed; // Containers that need stop actions 258 time_t recheck_by; // Hint to controller when to reschedule 259 int ninstances; // Total number of resource instances 260 guint shutdown_lock; // How long to lock resources (seconds) 261 int priority_fencing_delay; // Priority fencing delay 262 263 // pcmk__output_t * 264 void *priv; // For Pacemaker use only 265 266 guint node_pending_timeout; // Pending join times out after this (ms) 267 }; 268 //!@} 269 270 /* Whether the scheduler input currently being processed has warnings or errors 271 * 272 * @COMPAT When we can break API compatibility, we should make these 273 * internal-only. Ideally they would be converted to pcmk_scheduler_flags 274 * values, but everywhere they're needed doesn't currently have access to the 275 * scheduler data. 276 */ 277 //!@{ 278 //! \deprecated Do not use 279 extern gboolean was_processing_error; 280 extern gboolean was_processing_warning; 281 //!@} 282 283 pcmk_node_t *pcmk_get_dc(const pcmk_scheduler_t *scheduler); 284 enum pe_quorum_policy pcmk_get_no_quorum_policy(const pcmk_scheduler_t 285 *scheduler); 286 287 int pcmk_set_scheduler_cib(pcmk_scheduler_t *scheduler, xmlNode *cib); 288 289 bool pcmk_has_quorum(const pcmk_scheduler_t *scheduler); 290 pcmk_node_t *pcmk_find_node(const pcmk_scheduler_t *scheduler, 291 const char *node_name); 292 293 #ifdef __cplusplus 294 } 295 #endif 296 297 #endif // PCMK__CRM_COMMON_SCHEDULER__H