pacemaker  2.1.9-49aab99839
Scalable High-Availability cluster resource manager
scheduler.h
Go to the documentation of this file.
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>
25 #include <crm/common/tags.h>
26 #include <crm/common/tickets.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
38 // NOTE: sbd (as of at least 1.5.2) uses this enum
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
51 
52  // NOTE: sbd (as of at least 1.5.2) uses this value
55 
56  // NOTE: sbd (as of at least 1.5.2) uses this value
59 
62 
63  // NOTE: sbd (as of at least 1.5.2) uses this value
66 #endif
67 };
68 
69 // Scheduling options and conditions
73  // No scheduler flags set (compare with equality rather than bit set)
75 
76  /* These flags are dynamically determined conditions */
77 
78  // Whether partition has quorum (via \c PCMK_XA_HAVE_QUORUM attribute)
80  pcmk_sched_quorate = (1ULL << 0),
81 
82  // Whether cluster is symmetric (via symmetric-cluster property)
84 
85  // Whether cluster is in maintenance mode (via maintenance-mode property)
87 
88  // Whether fencing is enabled (via stonith-enabled property)
90 
91  // Whether cluster has a fencing resource (via CIB resources)
96  pcmk_sched_have_fencing = (1ULL << 5),
97 
98  // Whether any resource provides or requires unfencing (via CIB resources)
100 
101  // Whether concurrent fencing is allowed (via concurrent-fencing property)
103 
104  /*
105  * Whether resources removed from the configuration should be stopped (via
106  * stop-orphan-resources property)
107  */
109 
110  /*
111  * Whether recurring actions removed from the configuration should be
112  * cancelled (via stop-orphan-actions property)
113  */
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  */
125 
126  // Unused
128 
129  // Whether unseen nodes should be fenced (via startup-fencing property)
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  */
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)
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)
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 };
186 
187 // Implementation of pcmk_scheduler_t
188 // @COMPAT Make contents internal when we can break API backward compatibility
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
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
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
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
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
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
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 };
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  */
279 extern gboolean was_processing_error;
280 extern gboolean was_processing_warning;
282 
285  *scheduler);
286 
288 
291  const char *node_name);
292 
293 #ifdef __cplusplus
294 }
295 #endif
296 
297 #endif // PCMK__CRM_COMMON_SCHEDULER__H
GHashTable * tags
Definition: scheduler.h:253
pcmk_node_t * pcmk_find_node(const pcmk_scheduler_t *scheduler, const char *node_name)
Find a node by name in scheduler data.
Definition: scheduler.c:103
enum pe_quorum_policy no_quorum_policy
Definition: scheduler.h:217
xmlNode * failed
Definition: scheduler.h:240
Scheduler API for resources.
Type aliases needed to define scheduler objects.
struct crm_time_s crm_time_t
Definition: iso8601.h:32
gboolean was_processing_warning
Definition: scheduler.c:22
int priority_fencing_delay
Definition: scheduler.h:261
xmlNode * op_defaults
Definition: scheduler.h:241
APIs related to actions.
pcmk_node_t * pcmk_get_dc(const pcmk_scheduler_t *scheduler)
Definition: scheduler.c:33
GList * actions
Definition: scheduler.h:239
GHashTable * tickets
Definition: scheduler.h:222
pe_quorum_policy
Possible responses to loss of quorum.
Definition: scheduler.h:40
GList * resources
Definition: scheduler.h:231
GList * ticket_constraints
Definition: scheduler.h:237
Scheduler API for resource roles.
xmlNode * rsc_defaults
Definition: scheduler.h:242
const char * stonith_action
Definition: scheduler.h:205
gboolean was_processing_error
Definition: scheduler.c:21
GHashTable * config_hash
Definition: scheduler.h:219
ISO_8601 Date handling.
time_t recheck_by
Definition: scheduler.h:258
bool pcmk_has_quorum(const pcmk_scheduler_t *scheduler)
Definition: scheduler.c:85
xmlNode * input
Definition: scheduler.h:196
const char * placement_strategy
Definition: scheduler.h:206
guint shutdown_lock
Definition: scheduler.h:260
Scheduler API for nodes.
const char * localhost
Definition: scheduler.h:251
GList * ordering_constraints
Definition: scheduler.h:233
guint node_pending_timeout
Definition: scheduler.h:266
pcmk_scheduler_t * scheduler
GList * param_check
Definition: scheduler.h:256
int disabled_resources
Definition: scheduler.h:255
GList * colocation_constraints
Definition: scheduler.h:234
Scheduler API for configuration tags.
Scheduler API for tickets.
GList * placement_constraints
Definition: scheduler.h:232
int pcmk_set_scheduler_cib(pcmk_scheduler_t *scheduler, xmlNode *cib)
Definition: scheduler.c:67
GHashTable * singletons
Definition: scheduler.h:225
unsigned long long flags
Definition: scheduler.h:211
Scheduler API for rules.
enum pe_quorum_policy pcmk_get_no_quorum_policy(const pcmk_scheduler_t *scheduler)
Definition: scheduler.c:47
pcmk_scheduler_flags
Definition: scheduler.h:72
crm_time_t * now
Definition: scheduler.h:198
GHashTable * template_rsc_sets
Definition: scheduler.h:248
pcmk_node_t * dc_node
Definition: scheduler.h:203
GList * stop_needed
Definition: scheduler.h:257
xmlNode * graph
Definition: scheduler.h:247