pacemaker 2.1.7-2.1.7
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
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
21extern "C" {
22#endif
23
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
74
96
101
103 pcmk_rsc_removed = (1ULL << 0),
104
106 pcmk_rsc_managed = (1ULL << 1),
107
109 pcmk_rsc_blocked = (1ULL << 2),
110
113
115 pcmk_rsc_notify = (1ULL << 4),
116
118 pcmk_rsc_unique = (1ULL << 5),
119
122
124 pcmk_rsc_promotable = (1ULL << 7),
125
127 pcmk_rsc_unassigned = (1ULL << 8),
128
130 pcmk_rsc_assigning = (1ULL << 9),
131
134
136 pcmk_rsc_restarting = (1ULL << 11),
137
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
161
163 pcmk_rsc_starting = (1ULL << 20),
164
166 pcmk_rsc_stopping = (1ULL << 21),
167
170
172 pcmk_rsc_migratable = (1ULL << 23),
173
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
191
194};
195
233
240
242 pe_print_log = (1 << 0),
243 pe_print_html = (1 << 1),
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
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
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;
402
404 xmlNode *xml;
405
407 xmlNode *orig_xml;
408
410 xmlNode *ops_xml;
411
418
420
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
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
const char * name
Definition cib.c:26
uint64_t flags
Definition remote.c:3
pcmk_scheduler_t * scheduler
pe_print_options
Definition resources.h:241
@ pe_print_ncurses
Definition resources.h:244
@ pe_print_printf
Definition resources.h:245
@ pe_print_rsconly
Definition resources.h:249
@ pe_print_implicit
Definition resources.h:257
@ pe_print_log
Definition resources.h:242
@ pe_print_brief
Definition resources.h:253
@ pe_print_xml
Definition resources.h:252
@ pe_print_clone_active
Definition resources.h:256
@ pe_print_max_details
Definition resources.h:248
@ pe_print_details
Definition resources.h:247
@ pe_print_dev
Definition resources.h:246
@ pe_print_pending
Definition resources.h:254
@ pe_print_suppres_nl
Definition resources.h:251
@ pe_print_clone_details
Definition resources.h:255
@ pe_print_html
Definition resources.h:243
@ pe_print_ops
Definition resources.h:250
rsc_start_requirement
What resource needs before it can be recovered from a failed node.
Definition resources.h:58
@ pcmk_requires_fencing
Resource can be recovered after fencing.
Definition resources.h:61
@ pcmk_requires_quorum
Resource can be recovered if quorate.
Definition resources.h:60
@ rsc_req_quorum
Definition resources.h:68
@ pcmk_requires_nothing
Resource can be recovered immediately.
Definition resources.h:59
@ rsc_req_stonith
Definition resources.h:71
@ rsc_req_nothing
Definition resources.h:65
rsc_recovery_type
How to recover a resource that is incorrectly active on multiple nodes.
Definition resources.h:76
@ recovery_stop_start
Definition resources.h:84
@ pcmk_multiply_active_block
Do nothing to resource.
Definition resources.h:79
@ pcmk_multiply_active_restart
Stop on all, start on desired.
Definition resources.h:77
@ recovery_block
Definition resources.h:90
@ pcmk_multiply_active_stop
Stop on all and leave stopped.
Definition resources.h:78
@ recovery_stop_only
Definition resources.h:87
@ recovery_stop_unexpected
Definition resources.h:93
@ pcmk_multiply_active_unexpected
Stop unexpected instances.
Definition resources.h:80
pe_find
Search options for resources (exact resource ID always matches)
Definition resources.h:197
@ pcmk_rsc_match_anon_basename
Also match anonymous clone instances by base name.
Definition resources.h:202
@ pe_find_inactive
Definition resources.h:211
@ pcmk_rsc_match_clone_only
Match only clones and their instances, by either clone or instance ID.
Definition resources.h:205
@ pe_find_any
Definition resources.h:230
@ pcmk_rsc_match_basename
Match clone instances (even unique) by base name as well as exact ID.
Definition resources.h:214
@ pe_find_clone
Definition resources.h:224
@ pcmk_rsc_match_history
Also match clone instance ID from resource history.
Definition resources.h:199
@ pcmk_rsc_match_current_node
If matching by node, compare current node instead of assigned node.
Definition resources.h:208
@ pe_find_renamed
Definition resources.h:218
@ pe_find_current
Definition resources.h:227
@ pe_find_anon
Definition resources.h:221
pe_obj_types
Resource variants supported by Pacemaker.
Definition resources.h:31
@ pcmk_rsc_variant_group
Group resource.
Definition resources.h:35
@ pcmk_rsc_variant_primitive
Primitive resource.
Definition resources.h:34
@ pe_group
Definition resources.h:47
@ pcmk_rsc_variant_bundle
Bundle resource.
Definition resources.h:37
@ pcmk_rsc_variant_unknown
Unknown resource variant.
Definition resources.h:33
@ pe_container
Definition resources.h:53
@ pe_unknown
Definition resources.h:41
@ pe_native
Definition resources.h:44
@ pe_clone
Definition resources.h:50
@ pcmk_rsc_variant_clone
Clone resource.
Definition resources.h:36
pcmk_rsc_flags
Resource scheduling flags.
Definition resources.h:98
@ pcmk_rsc_detect_loop
Flag for non-scheduler code to use to detect recursion loops.
Definition resources.h:154
@ pcmk_rsc_promotable
Whether resource can be promoted and demoted.
Definition resources.h:124
@ pcmk_rsc_unassigned
Whether resource has not yet been assigned to a node.
Definition resources.h:127
@ pcmk_rsc_assigning
Whether resource is in the process of being assigned to a node.
Definition resources.h:130
@ pcmk_rsc_stop_if_failed
Whether resource must be stopped (instead of demoted) if it is failed.
Definition resources.h:139
@ pcmk_rsc_critical
Whether resource has "critical" meta-attribute enabled.
Definition resources.h:148
@ pcmk_rsc_migratable
Whether resource is allowed to live-migrate.
Definition resources.h:172
@ pcmk_rsc_unique
Whether resource is not an anonymous clone instance.
Definition resources.h:118
@ pcmk_rsc_maintenance
Whether resource, its node, or entire cluster is in maintenance mode.
Definition resources.h:181
@ pcmk_no_rsc_flags
No resource flags set (compare with equality rather than bit set)
Definition resources.h:100
@ pcmk_rsc_needs_fencing
Whether resource requires fencing before recovery if on unclean node.
Definition resources.h:190
@ pcmk_rsc_replica_container
Whether resource is an implicit container resource for a bundle replica.
Definition resources.h:178
@ pcmk_rsc_runnable
Definition resources.h:157
@ pcmk_rsc_needs_unfencing
Whether resource can be started or promoted only on unfenced nodes.
Definition resources.h:193
@ pcmk_rsc_removed
Whether resource has been removed from the configuration.
Definition resources.h:103
@ pcmk_rsc_notify
Whether resource has clone notifications enabled.
Definition resources.h:115
@ pcmk_rsc_updating_nodes
Whether resource is in the process of modifying allowed node scores.
Definition resources.h:133
@ pcmk_rsc_remote_nesting_allowed
Whether resource is a remote connection allowed to run on a remote node.
Definition resources.h:145
@ pcmk_rsc_reload
Whether a reload action has been scheduled for resource.
Definition resources.h:142
@ pcmk_rsc_start_pending
Whether resource has pending start action in history.
Definition resources.h:160
@ pcmk_rsc_stopping
Definition resources.h:166
@ pcmk_rsc_blocked
Whether resource is blocked from further action.
Definition resources.h:109
@ pcmk_rsc_restarting
Whether resource is in the process of scheduling actions to restart.
Definition resources.h:136
@ pcmk_rsc_fence_device
Whether resource's class is "stonith".
Definition resources.h:121
@ pcmk_rsc_needs_quorum
Whether resource can be started or promoted only on quorate nodes.
Definition resources.h:187
@ pcmk_rsc_removed_filler
Whether resource has been removed but has a container.
Definition resources.h:112
@ pcmk_rsc_stop_unexpected
Whether resource is multiply active with recovery set to stop_unexpected.
Definition resources.h:169
@ pcmk_rsc_has_filler
Definition resources.h:184
@ pcmk_rsc_managed
Whether resource is managed.
Definition resources.h:106
@ pcmk_rsc_ignore_failure
Whether resource has an ignorable failure.
Definition resources.h:175
@ pcmk_rsc_failed
Whether resource is considered failed.
Definition resources.h:151
@ pcmk_rsc_starting
Definition resources.h:163
struct resource_object_functions_s pcmk_rsc_methods_t
Resource object methods.
pe_restart
Definition resources.h:236
@ pe_restart_ignore
Definition resources.h:238
@ pe_restart_restart
Definition resources.h:237
Scheduler API for resource roles.
rsc_role_e
Definition roles.h:27
Type aliases needed to define scheduler objects.
Implementation of pcmk_node_t.
Definition nodes.h:130
Implementation of pcmk_resource_t.
Definition resources.h:399
pcmk_assignment_methods_t * cmds
Resource assignment methods.
Definition resources.h:417
GList * running_on
Nodes where resource may be active.
Definition resources.h:460
GList * actions
Definition resources.h:447
GList * rsc_location
Definition resources.h:446
int failure_timeout
Failure timeout.
Definition resources.h:425
enum pe_obj_types variant
Resource variant.
Definition resources.h:414
pcmk_node_t * partial_migration_target
The destination node, if migrate_to completed but migrate_from has not.
Definition resources.h:454
GHashTable * meta
Resource's meta-attributes.
Definition resources.h:471
GList * rsc_cons
Definition resources.h:445
GList * rsc_cons_lhs
Definition resources.h:444
GList * children
Resource's child resources, if any.
Definition resources.h:475
pcmk_scheduler_t * cluster
Cluster that resource is part of.
Definition resources.h:412
int migration_threshold
Migration threshold.
Definition resources.h:426
gboolean exclusive_discover
Whether exclusive probing is enabled.
Definition resources.h:433
pcmk_node_t * partial_migration_source
The source node, if migrate_to completed but migrate_from has not.
Definition resources.h:457
enum pe_restart restart_type
Definition resources.h:421
pcmk_resource_t * container
Resource containing this one, if any.
Definition resources.h:480
pcmk_rsc_methods_t * fns
Resource object methods.
Definition resources.h:416
GHashTable * known_on
Nodes where resource has been probed (key is node ID, not name)
Definition resources.h:463
char * clone_name
Resource instance ID in history.
Definition resources.h:401
int priority
Configured priority.
Definition resources.h:422
GHashTable * parameters
Definition resources.h:472
gboolean is_remote_node
Whether this is a remote connection.
Definition resources.h:432
char * id
Resource ID in configuration.
Definition resources.h:400
pcmk_node_t * allocated_to
Node resource is assigned to.
Definition resources.h:451
xmlNode * xml
Resource configuration (possibly expanded from template)
Definition resources.h:404
GHashTable * utilization
Resource's utilization attributes.
Definition resources.h:473
GHashTable * allowed_nodes
Nodes where resource may run (key is node ID, not name)
Definition resources.h:466
GList * dangling_migrations
Definition resources.h:478
int sort_index
Promotion score on assigned node.
Definition resources.h:424
pcmk_node_t * lock_node
Resource shutdown-locked to this node.
Definition resources.h:485
GHashTable * parameter_cache
Definition resources.h:495
GList * rsc_tickets
Definition resources.h:448
void * variant_opaque
Variant-specific (and private) data.
Definition resources.h:415
unsigned long long flags
Group of enum pcmk_rsc_flags.
Definition resources.h:429
pcmk_node_t * pending_node
Node on which pending_task is happening.
Definition resources.h:484
char * pending_task
Pending action in history, if any.
Definition resources.h:428
guint remote_reconnect_ms
Retry interval for remote connections.
Definition resources.h:427
enum rsc_recovery_type recovery_type
How to recover if failed.
Definition resources.h:419
GList * fillers
Resources contained by this one, if any.
Definition resources.h:481
xmlNode * orig_xml
Original resource configuration, if using template.
Definition resources.h:407
enum rsc_role_e next_role
Resource's scheduled next role.
Definition resources.h:469
enum rsc_role_e role
Resource's current role.
Definition resources.h:468
int stickiness
Extra preference for current node.
Definition resources.h:423
pcmk_resource_t * parent
Resource's parent resource, if any.
Definition resources.h:413
xmlNode * ops_xml
Configuration of resource operations (possibly expanded from template)
Definition resources.h:410
time_t lock_time
When shutdown lock started.
Definition resources.h:487
Implementation of pcmk_scheduler_t.
Definition scheduler.h:172
Resource object methods.
Definition resources.h:266
void(* free)(pcmk_resource_t *rsc)
Free all memory used by a resource.
Definition resources.h:347
void(* print)(pcmk_resource_t *rsc, const char *pre_text, long options, void *print_data)
Definition resources.h:306
enum rsc_role_e(* state)(const pcmk_resource_t *rsc, gboolean current)
Get resource's current or assigned role.
Definition resources.h:327
void(* count)(pcmk_resource_t *rsc)
Increment cluster's instance counts for a resource.
Definition resources.h:357
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
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
gboolean(* active)(pcmk_resource_t *rsc, gboolean all)
Check whether a resource is active.
Definition resources.h:317