pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
resources.h
Go to the documentation of this file.
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_RESOURCES__H
11 # define PCMK__CRM_COMMON_RESOURCES__H
12 
13 #include <sys/types.h> // time_t
14 #include <libxml/tree.h> // xmlNode
15 #include <glib.h> // gboolean, guint, GList, GHashTable
16 
17 #include <crm/common/roles.h> // enum rsc_role_e
18 #include <crm/common/scheduler_types.h> // pcmk_resource_t, etc.
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
30 enum pe_obj_types {
32  // Order matters: some code compares greater or lesser than
38 
39 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
42 
45 
48 
51 
54 #endif
55 };
56 
62 
63 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
66 
69 
72 #endif
73 };
74 
81 
82 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
85 
88 
91 
94 #endif
95 };
96 
101 
103  pcmk_rsc_removed = (1ULL << 0),
104 
106  pcmk_rsc_managed = (1ULL << 1),
107 
109  pcmk_rsc_blocked = (1ULL << 2),
110 
112  pcmk_rsc_removed_filler = (1ULL << 3),
113 
115  pcmk_rsc_notify = (1ULL << 4),
116 
118  pcmk_rsc_unique = (1ULL << 5),
119 
121  pcmk_rsc_fence_device = (1ULL << 6),
122 
124  pcmk_rsc_promotable = (1ULL << 7),
125 
127  pcmk_rsc_unassigned = (1ULL << 8),
128 
130  pcmk_rsc_assigning = (1ULL << 9),
131 
133  pcmk_rsc_updating_nodes = (1ULL << 10),
134 
136  pcmk_rsc_restarting = (1ULL << 11),
137 
139  pcmk_rsc_stop_if_failed = (1ULL << 12),
140 
142  pcmk_rsc_reload = (1ULL << 13),
143 
146 
148  pcmk_rsc_critical = (1ULL << 15),
149 
151  pcmk_rsc_failed = (1ULL << 16),
152 
154  pcmk_rsc_detect_loop = (1ULL << 17),
155 
157  pcmk_rsc_runnable = (1ULL << 18),
158 
160  pcmk_rsc_start_pending = (1ULL << 19),
161 
163  pcmk_rsc_starting = (1ULL << 20),
164 
166  pcmk_rsc_stopping = (1ULL << 21),
167 
169  pcmk_rsc_stop_unexpected = (1ULL << 22),
170 
172  pcmk_rsc_migratable = (1ULL << 23),
173 
175  pcmk_rsc_ignore_failure = (1ULL << 24),
176 
179 
181  pcmk_rsc_maintenance = (1ULL << 26),
182 
184  pcmk_rsc_has_filler = (1ULL << 27),
185 
187  pcmk_rsc_needs_quorum = (1ULL << 28),
188 
190  pcmk_rsc_needs_fencing = (1ULL << 29),
191 
193  pcmk_rsc_needs_unfencing = (1ULL << 30),
194 };
195 
197 enum pe_find {
200 
203 
206 
209 
211  pe_find_inactive = (1 << 4),
212 
215 
216 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
219 
222 
225 
228 
231 #endif
232 };
233 
239 };
240 
242  pe_print_log = (1 << 0),
243  pe_print_html = (1 << 1),
244  pe_print_ncurses = (1 << 2),
245  pe_print_printf = (1 << 3),
246  pe_print_dev = (1 << 4), // Ignored
247  pe_print_details = (1 << 5), // Ignored
248  pe_print_max_details = (1 << 6), // Ignored
249  pe_print_rsconly = (1 << 7),
250  pe_print_ops = (1 << 8),
252  pe_print_xml = (1 << 10),
253  pe_print_brief = (1 << 11),
254  pe_print_pending = (1 << 12),
256  pe_print_clone_active = (1 << 14), // Print clone instances only if active
257  pe_print_implicit = (1 << 15) // Print implicitly created resources
258 };
260 
261 // Resource assignment methods (implementation defined by libpacemaker)
264 
276 
287  pcmk_resource_t *(*find_rsc)(pcmk_resource_t *rsc, const char *search,
288  const pcmk_node_t *node, int flags);
289 
302  char *(*parameter)(pcmk_resource_t *rsc, pcmk_node_t *node, gboolean create,
303  const char *name, pcmk_scheduler_t *scheduler);
304 
306  void (*print)(pcmk_resource_t *rsc, const char *pre_text, long options,
307  void *print_data);
308 
317  gboolean (*active)(pcmk_resource_t *rsc, gboolean all);
318 
327  enum rsc_role_e (*state)(const pcmk_resource_t *rsc, gboolean current);
328 
339  pcmk_node_t *(*location)(const pcmk_resource_t *rsc, GList **list,
340  int current);
341 
347  void (*free)(pcmk_resource_t *rsc);
348 
357  void (*count)(pcmk_resource_t *rsc);
358 
369  gboolean (*is_filtered)(const pcmk_resource_t *rsc, GList *only_rsc,
370  gboolean check_parent);
371 
384  pcmk_node_t *(*active_node)(const pcmk_resource_t *rsc,
385  unsigned int *count_all,
386  unsigned int *count_clean);
387 
395  unsigned int (*max_per_node)(const pcmk_resource_t *rsc);
397 
400  char *id;
401  char *clone_name;
402 
404  xmlNode *xml;
405 
407  xmlNode *orig_xml;
408 
410  xmlNode *ops_xml;
411 
418 
420 
422  int priority;
428  char *pending_task;
429  unsigned long long flags;
430 
431  // @TODO Merge these into flags
432  gboolean is_remote_node;
434 
435  /* Pay special attention to whether you want to use rsc_cons_lhs and
436  * rsc_cons directly, which include only colocations explicitly involving
437  * this resource, or call libpacemaker's pcmk__with_this_colocations() and
438  * pcmk__this_with_colocations() functions, which may return relevant
439  * colocations involving the resource's ancestors as well.
440  */
441 
444  GList *rsc_cons_lhs; // Colocations of other resources with this one
445  GList *rsc_cons; // Colocations of this resource with others
446  GList *rsc_location; // Location constraints for resource
447  GList *actions; // Actions scheduled for resource
448  GList *rsc_tickets; // Ticket constraints for resource
450 
452 
455 
458 
460  GList *running_on;
461 
463  GHashTable *known_on;
464 
466  GHashTable *allowed_nodes;
467 
470 
471  GHashTable *meta;
472  GHashTable *parameters;
473  GHashTable *utilization;
474 
475  GList *children;
476 
477  // Source nodes where stop is needed after migrate_from and migrate_to
479 
481  GList *fillers;
482 
483  // @COMPAT These should be made const at next API compatibility break
486 
487  time_t lock_time;
488 
495  GHashTable *parameter_cache;
496 };
497 
498 #ifdef __cplusplus
499 }
500 #endif
501 
502 #endif // PCMK__CRM_COMMON_RESOURCES__H
pcmk_assignment_methods_t * cmds
Resource assignment methods.
Definition: resources.h:417
Whether resource has clone notifications enabled.
Definition: resources.h:115
xmlNode * orig_xml
Original resource configuration, if using template.
Definition: resources.h:407
Whether resource has been removed but has a container.
Definition: resources.h:112
Resource can be recovered after fencing.
Definition: resources.h:61
pcmk_rsc_flags
Resource scheduling flags.
Definition: resources.h:98
GHashTable * known_on
Nodes where resource has been probed (key is node ID, not name)
Definition: resources.h:463
pcmk_scheduler_t * cluster
Cluster that resource is part of.
Definition: resources.h:412
xmlNode * ops_xml
Configuration of resource operations (possibly expanded from template)
Definition: resources.h:410
Resource can be recovered immediately.
Definition: resources.h:59
Also match anonymous clone instances by base name.
Definition: resources.h:202
GList * rsc_tickets
Definition: resources.h:448
GList * rsc_cons
Definition: resources.h:445
pcmk_node_t * partial_migration_target
The destination node, if migrate_to completed but migrate_from has not.
Definition: resources.h:454
Whether resource is an implicit container resource for a bundle replica.
Definition: resources.h:178
const char * name
Definition: cib.c:26
Type aliases needed to define scheduler objects.
pe_find
Search options for resources (exact resource ID always matches)
Definition: resources.h:197
enum rsc_role_e role
Resource&#39;s current role.
Definition: resources.h:468
GList * children
Resource&#39;s child resources, if any.
Definition: resources.h:475
Match only clones and their instances, by either clone or instance ID.
Definition: resources.h:205
Whether resource can be started or promoted only on quorate nodes.
Definition: resources.h:187
xmlNode * xml
Resource configuration (possibly expanded from template)
Definition: resources.h:404
enum rsc_role_e(* state)(const pcmk_resource_t *rsc, gboolean current)
Get resource&#39;s current or assigned role.
Definition: resources.h:327
enum rsc_role_e next_role
Resource&#39;s scheduled next role.
Definition: resources.h:469
gboolean exclusive_discover
Whether exclusive probing is enabled.
Definition: resources.h:433
Do nothing to resource.
Definition: resources.h:79
GHashTable * meta
Resource&#39;s meta-attributes.
Definition: resources.h:471
Whether resource, its node, or entire cluster is in maintenance mode.
Definition: resources.h:181
GHashTable * parameters
Definition: resources.h:472
Group resource.
Definition: resources.h:35
GList * rsc_cons_lhs
Definition: resources.h:444
int migration_threshold
Migration threshold.
Definition: resources.h:426
void(* print)(pcmk_resource_t *rsc, const char *pre_text, long options, void *print_data)
Definition: resources.h:306
pcmk_resource_t * container
Resource containing this one, if any.
Definition: resources.h:480
Implementation of pcmk_scheduler_t.
Definition: scheduler.h:172
char * pending_task
Pending action in history, if any.
Definition: resources.h:428
rsc_start_requirement
What resource needs before it can be recovered from a failed node.
Definition: resources.h:58
Also match clone instance ID from resource history.
Definition: resources.h:199
Stop on all and leave stopped.
Definition: resources.h:78
pcmk_resource_t * parent
Resource&#39;s parent resource, if any.
Definition: resources.h:413
GList * dangling_migrations
Definition: resources.h:478
guint remote_reconnect_ms
Retry interval for remote connections.
Definition: resources.h:427
void(* free)(pcmk_resource_t *rsc)
Free all memory used by a resource.
Definition: resources.h:347
Whether resource is in the process of being assigned to a node.
Definition: resources.h:130
Bundle resource.
Definition: resources.h:37
gboolean(* unpack)(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler)
Parse variant-specific resource XML from CIB into struct members.
Definition: resources.h:275
unsigned int(* max_per_node)(const pcmk_resource_t *rsc)
Get maximum resource instances per node.
Definition: resources.h:395
Implementation of pcmk_resource_t.
Definition: resources.h:399
Scheduler API for resource roles.
Primitive resource.
Definition: resources.h:34
int failure_timeout
Failure timeout.
Definition: resources.h:425
int priority
Configured priority.
Definition: resources.h:422
Whether resource is considered failed.
Definition: resources.h:151
Whether resource must be stopped (instead of demoted) if it is failed.
Definition: resources.h:139
struct resource_object_functions_s pcmk_rsc_methods_t
Resource object methods.
Whether resource is multiply active with recovery set to stop_unexpected.
Definition: resources.h:169
enum rsc_recovery_type recovery_type
How to recover if failed.
Definition: resources.h:419
pe_obj_types
Resource variants supported by Pacemaker.
Definition: resources.h:31
unsigned long long flags
Group of enum pcmk_rsc_flags.
Definition: resources.h:429
rsc_role_e
Definition: roles.h:27
char * clone_name
Resource instance ID in history.
Definition: resources.h:401
Match clone instances (even unique) by base name as well as exact ID.
Definition: resources.h:214
time_t lock_time
When shutdown lock started.
Definition: resources.h:487
enum pe_restart restart_type
Definition: resources.h:421
GList * actions
Definition: resources.h:447
rsc_recovery_type
How to recover a resource that is incorrectly active on multiple nodes.
Definition: resources.h:76
GHashTable * utilization
Resource&#39;s utilization attributes.
Definition: resources.h:473
Flag for non-scheduler code to use to detect recursion loops.
Definition: resources.h:154
Whether resource is blocked from further action.
Definition: resources.h:109
Implementation of pcmk_node_t.
Definition: nodes.h:130
enum pe_obj_types variant
Resource variant.
Definition: resources.h:414
Stop unexpected instances.
Definition: resources.h:80
Resource can be recovered if quorate.
Definition: resources.h:60
Whether resource has pending start action in history.
Definition: resources.h:160
Whether resource has "critical" meta-attribute enabled.
Definition: resources.h:148
Whether resource is in the process of scheduling actions to restart.
Definition: resources.h:136
GList * fillers
Resources contained by this one, if any.
Definition: resources.h:481
Whether resource has an ignorable failure.
Definition: resources.h:175
Whether resource has not yet been assigned to a node.
Definition: resources.h:127
gboolean(* active)(pcmk_resource_t *rsc, gboolean all)
Check whether a resource is active.
Definition: resources.h:317
Whether resource is a remote connection allowed to run on a remote node.
Definition: resources.h:145
Whether resource is in the process of modifying allowed node scores.
Definition: resources.h:133
gboolean is_remote_node
Whether this is a remote connection.
Definition: resources.h:432
Whether resource requires fencing before recovery if on unclean node.
Definition: resources.h:190
Whether resource&#39;s class is "stonith".
Definition: resources.h:121
pcmk_rsc_methods_t * fns
Resource object methods.
Definition: resources.h:416
void * variant_opaque
Variant-specific (and private) data.
Definition: resources.h:415
int sort_index
Promotion score on assigned node.
Definition: resources.h:424
pcmk_scheduler_t * scheduler
If matching by node, compare current node instead of assigned node.
Definition: resources.h:208
pcmk_node_t * lock_node
Resource shutdown-locked to this node.
Definition: resources.h:485
pe_print_options
Definition: resources.h:241
Whether resource is allowed to live-migrate.
Definition: resources.h:172
Stop on all, start on desired.
Definition: resources.h:77
pcmk_node_t * allocated_to
Node resource is assigned to.
Definition: resources.h:451
GList * rsc_location
Definition: resources.h:446
Resource object methods.
Definition: resources.h:266
gboolean(* is_filtered)(const pcmk_resource_t *rsc, GList *only_rsc, gboolean check_parent)
Check whether a given resource is in a list of resources.
Definition: resources.h:369
GList * running_on
Nodes where resource may be active.
Definition: resources.h:460
Whether a reload action has been scheduled for resource.
Definition: resources.h:142
pe_restart
Definition: resources.h:236
GHashTable * parameter_cache
Definition: resources.h:495
pcmk_node_t * pending_node
Node on which pending_task is happening.
Definition: resources.h:484
Whether resource can be promoted and demoted.
Definition: resources.h:124
int stickiness
Extra preference for current node.
Definition: resources.h:423
Clone resource.
Definition: resources.h:36
Whether resource is managed.
Definition: resources.h:106
Whether resource can be started or promoted only on unfenced nodes.
Definition: resources.h:193
Whether resource has been removed from the configuration.
Definition: resources.h:103
uint64_t flags
Definition: remote.c:215
Whether resource is not an anonymous clone instance.
Definition: resources.h:118
Unknown resource variant.
Definition: resources.h:33
void(* count)(pcmk_resource_t *rsc)
Increment cluster&#39;s instance counts for a resource.
Definition: resources.h:357
pcmk_node_t * partial_migration_source
The source node, if migrate_to completed but migrate_from has not.
Definition: resources.h:457
No resource flags set (compare with equality rather than bit set)
Definition: resources.h:100
char * id
Resource ID in configuration.
Definition: resources.h:400
GHashTable * allowed_nodes
Nodes where resource may run (key is node ID, not name)
Definition: resources.h:466