pacemaker  2.0.4-2deceaa
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pe_types.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2020 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 PE_TYPES__H
11 # define PE_TYPES__H
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
23 # include <stdbool.h> // bool
24 # include <sys/types.h> // time_t
25 # include <glib.h> // gboolean, guint, GList, GHashTable
26 # include <crm/crm.h> // GListPtr
27 # include <crm/common/iso8601.h>
28 # include <crm/pengine/common.h>
29 
30 typedef struct pe_node_s pe_node_t;
31 typedef struct pe_action_s pe_action_t;
34 
36  pe_unknown = -1,
37  pe_native = 0,
38  pe_group = 1,
39  pe_clone = 2,
41 };
42 
45  pe_resource_t *(*find_rsc) (pe_resource_t *parent, const char *search,
46  const pe_node_t *node, int flags);
47  /* parameter result must be free'd */
48  char *(*parameter) (pe_resource_t*, pe_node_t*, gboolean, const char*,
50  void (*print) (pe_resource_t*, const char*, long, void*);
51  gboolean (*active) (pe_resource_t*, gboolean);
52  enum rsc_role_e (*state) (const pe_resource_t*, gboolean);
53  pe_node_t *(*location) (const pe_resource_t*, GList**, int);
54  void (*free) (pe_resource_t*);
55  void (*count) (pe_resource_t*);
57 
59 
65 };
66 
67 enum node_type {
71 };
72 
74 enum pe_restart {
77 };
78 
80 enum pe_find {
81  pe_find_renamed = 0x001,
82  pe_find_anon = 0x002,
83  pe_find_clone = 0x004,
84  pe_find_current = 0x008,
85  pe_find_inactive = 0x010,
86  pe_find_any = 0x020,
87 };
88 
89 // @TODO Make these an enum
90 
91 # define pe_flag_have_quorum 0x00000001ULL
92 # define pe_flag_symmetric_cluster 0x00000002ULL
93 # define pe_flag_maintenance_mode 0x00000008ULL
94 
95 # define pe_flag_stonith_enabled 0x00000010ULL
96 # define pe_flag_have_stonith_resource 0x00000020ULL
97 # define pe_flag_enable_unfencing 0x00000040ULL
98 # define pe_flag_concurrent_fencing 0x00000080ULL
99 
100 # define pe_flag_stop_rsc_orphans 0x00000100ULL
101 # define pe_flag_stop_action_orphans 0x00000200ULL
102 # define pe_flag_stop_everything 0x00000400ULL
103 
104 # define pe_flag_start_failure_fatal 0x00001000ULL
105 # define pe_flag_remove_after_stop 0x00002000ULL
106 # define pe_flag_startup_fencing 0x00004000ULL
107 # define pe_flag_shutdown_lock 0x00008000ULL
108 
109 # define pe_flag_startup_probes 0x00010000ULL
110 # define pe_flag_have_status 0x00020000ULL
111 # define pe_flag_have_remote_nodes 0x00040000ULL
112 
113 # define pe_flag_quick_location 0x00100000ULL
114 # define pe_flag_sanitized 0x00200000ULL
115 # define pe_flag_stdout 0x00400000ULL
116 
118 # define pe_flag_no_counts 0x00800000ULL
119 
123 # define pe_flag_no_compat 0x01000000ULL
124 
126  xmlNode *input;
128 
129  /* options extracted from the input */
130  char *dc_uuid;
132  const char *stonith_action;
133  const char *placement_strategy;
134 
135  unsigned long long flags;
136 
139 
140  GHashTable *config_hash;
141  GHashTable *tickets;
142 
143  // Actions for which there can be only one (e.g. fence nodeX)
144  GHashTable *singletons;
145 
152 
154  xmlNode *failed;
155  xmlNode *op_defaults;
156  xmlNode *rsc_defaults;
157 
158  /* stats */
161  int order_id;
163 
164  /* final output */
165  xmlNode *graph;
166 
167  GHashTable *template_rsc_sets;
168  const char *localhost;
169  GHashTable *tags;
170 
173 
174  GList *param_check; // History entries that need to be checked
175  GList *stop_needed; // Containers that need stop actions
176  time_t recheck_by; // Hint to controller to re-run scheduler by this time
177  int ninstances; // Total number of resource instances
178  guint shutdown_lock;// How long (seconds) to lock resources to shutdown node
179  int priority_fencing_delay; // Priority fencing delay
180 };
181 
183  /* Clear fail count if parameters changed for un-expired start or monitor
184  * last_failure.
185  */
187 
188  /* Clear fail count if parameters changed for start, monitor, promote, or
189  * migrate_from actions for active resources.
190  */
192 };
193 
195  const char *id;
196  const char *uname;
198 
199  /* @TODO convert these flags into a bitfield */
200  gboolean online;
201  gboolean standby;
202  gboolean standby_onfail;
203  gboolean pending;
204  gboolean unclean;
205  gboolean unseen;
206  gboolean shutdown;
207  gboolean expected_up;
208  gboolean is_dc;
209  gboolean maintenance;
213  gboolean remote_maintenance; /* what the remote-rsc is thinking */
214  gboolean unpacked;
215 
218  GListPtr running_rsc; /* pe_resource_t* */
219  GListPtr allocated_rsc; /* pe_resource_t* */
220 
221  GHashTable *attrs; /* char* => char* */
222  GHashTable *utilization;
223  GHashTable *digest_cache;
224  int priority; // calculated based on the priority of resources running on the node
225 };
226 
227 struct pe_node_s {
228  int weight;
229  gboolean fixed;
230  int count;
233 };
234 
235 # define pe_rsc_orphan 0x00000001ULL
236 # define pe_rsc_managed 0x00000002ULL
237 # define pe_rsc_block 0x00000004ULL
238 # define pe_rsc_orphan_container_filler 0x00000008ULL
239 
240 # define pe_rsc_notify 0x00000010ULL
241 # define pe_rsc_unique 0x00000020ULL
242 # define pe_rsc_fence_device 0x00000040ULL
243 # define pe_rsc_promotable 0x00000080ULL
244 
245 # define pe_rsc_provisional 0x00000100ULL
246 # define pe_rsc_allocating 0x00000200ULL
247 # define pe_rsc_merging 0x00000400ULL
248 
249 # define pe_rsc_reload 0x00002000ULL
250 # define pe_rsc_allow_remote_remotes 0x00004000ULL
251 
252 # define pe_rsc_failed 0x00010000ULL
253 # define pe_rsc_runnable 0x00040000ULL
254 # define pe_rsc_start_pending 0x00080000ULL
255 
256 # define pe_rsc_starting 0x00100000ULL
257 # define pe_rsc_stopping 0x00200000ULL
258 # define pe_rsc_allow_migrate 0x00800000ULL
259 
260 # define pe_rsc_failure_ignored 0x01000000ULL
261 # define pe_rsc_maintenance 0x04000000ULL
262 # define pe_rsc_is_container 0x08000000ULL
263 
264 # define pe_rsc_needs_quorum 0x10000000ULL
265 # define pe_rsc_needs_fencing 0x20000000ULL
266 # define pe_rsc_needs_unfencing 0x40000000ULL
267 
269  pe_graph_none = 0x00000,
272  pe_graph_disable = 0x00004,
273 };
274 
275 /* *INDENT-OFF* */
277  pe_action_pseudo = 0x00001,
281 
285 
286  pe_action_dumped = 0x00100,
288  pe_action_clear = 0x00400,
289  pe_action_dangle = 0x00800,
290 
291  /* This action requires one or more of its dependencies to be runnable.
292  * We use this to clear the runnable flag before checking dependencies.
293  */
295 
298  pe_action_dedup = 0x08000,
299 
300  pe_action_dc = 0x10000,
301 };
302 /* *INDENT-ON* */
303 
305  char *id;
306  char *clone_name;
307  xmlNode *xml;
308  xmlNode *orig_xml;
309  xmlNode *ops_xml;
310 
313 
318 
320 
321  // @TODO only pe_restart_restart is of interest, so merge into flags
323 
324  int priority;
331 
332  unsigned long long flags;
333 
334  // @TODO merge these into flags
335  gboolean is_remote_node;
337 
340  GListPtr rsc_cons_lhs; // List of rsc_colocation_t*
341  GListPtr rsc_cons; // List of rsc_colocation_t*
342  GListPtr rsc_location; // List of pe__location_t*
343  GListPtr actions; // List of pe_action_t*
344  GListPtr rsc_tickets; // List of rsc_ticket*
346 
350  GListPtr running_on; /* pe_node_t* */
351  GHashTable *known_on; /* pe_node_t* */
352  GHashTable *allowed_nodes; /* pe_node_t* */
353 
356 
357  GHashTable *meta;
358  GHashTable *parameters;
359  GHashTable *utilization;
360 
361  GListPtr children; /* pe_resource_t* */
362  GListPtr dangling_migrations; /* pe_node_t* */
363 
366 
367  pe_node_t *pending_node; // Node on which pending_task is happening
368  pe_node_t *lock_node; // Resource is shutdown-locked to this node
369  time_t lock_time; // When shutdown lock started
370 
371 #if ENABLE_VERSIONED_ATTRS
372  xmlNode *versioned_parameters;
373 #endif
374 };
375 
376 #if ENABLE_VERSIONED_ATTRS
377 // Used as action->action_details if action->rsc is not NULL
378 typedef struct pe_rsc_action_details_s {
379  xmlNode *versioned_parameters;
380  xmlNode *versioned_meta;
381 } pe_rsc_action_details_t;
382 #endif
383 
384 struct pe_action_s {
385  int id;
386  int priority;
387 
390  xmlNode *op_entry;
391 
392  char *task;
393  char *uuid;
394  char *cancel_task;
395  char *reason;
396 
401 
402  GHashTable *meta;
403  GHashTable *extra;
404 
405  /*
406  * These two varables are associated with the constraint logic
407  * that involves first having one or more actions runnable before
408  * then allowing this action to execute.
409  *
410  * These varables are used with features such as 'clone-min' which
411  * requires at minimum X number of cloned instances to be running
412  * before an order dependency can run. Another option that uses
413  * this is 'require-all=false' in ordering constrants. This option
414  * says "only require one instance of a resource to start before
415  * allowing dependencies to start" -- basically, require-all=false is
416  * the same as clone-min=1.
417  */
418 
419  /* current number of known runnable actions in the before list. */
421  /* the number of "before" runnable actions required for this action
422  * to be considered runnable */
424 
425  GListPtr actions_before; /* pe_action_wrapper_t* */
426  GListPtr actions_after; /* pe_action_wrapper_t* */
427 
428  /* Some of the above fields could be moved to the details,
429  * except for API backward compatibility.
430  */
431  void *action_details; // varies by type of action
432 };
433 
434 typedef struct pe_ticket_s {
435  char *id;
436  gboolean granted;
437  time_t last_granted;
438  gboolean standby;
439  GHashTable *state;
440 } pe_ticket_t;
441 
442 typedef struct pe_tag_s {
443  char *id;
445 } pe_tag_t;
446 
452 };
453 
458 };
459 
460 /* *INDENT-OFF* */
462  pe_order_none = 0x0, /* deleted */
463  pe_order_optional = 0x1, /* pure ordering, nothing implied */
464  pe_order_apply_first_non_migratable = 0x2, /* Only apply this constraint's ordering if first is not migratable. */
465 
466  pe_order_implies_first = 0x10, /* If 'then' is required, ensure 'first' is too */
467  pe_order_implies_then = 0x20, /* If 'first' is required, ensure 'then' is too */
468  pe_order_implies_first_master = 0x40, /* Imply 'first' is required when 'then' is required and then's rsc holds Master role. */
469 
470  /* first requires then to be both runnable and migrate runnable. */
472 
473  pe_order_runnable_left = 0x100, /* 'then' requires 'first' to be runnable */
474 
475  pe_order_pseudo_left = 0x200, /* 'then' can only be pseudo if 'first' is runnable */
476  pe_order_implies_then_on_node = 0x400, /* If 'first' is required on 'nodeX',
477  * ensure instances of 'then' on 'nodeX' are too.
478  * Only really useful if 'then' is a clone and 'first' is not
479  */
480  pe_order_probe = 0x800, /* If 'first->rsc' is
481  * - running but about to stop, ignore the constraint
482  * - otherwise, behave as runnable_left
483  */
484 
485  pe_order_restart = 0x1000, /* 'then' is runnable if 'first' is optional or runnable */
486  pe_order_stonith_stop = 0x2000, /* only applies if the action is non-pseudo */
487  pe_order_serialize_only = 0x4000, /* serialize */
488  pe_order_same_node = 0x8000, /* applies only if 'first' and 'then' are on same node */
489 
490  pe_order_implies_first_printed = 0x10000, /* Like ..implies_first but only ensures 'first' is printed, not mandatory */
491  pe_order_implies_then_printed = 0x20000, /* Like ..implies_then but only ensures 'then' is printed, not mandatory */
492 
493  pe_order_asymmetrical = 0x100000, /* Indicates asymmetrical one way ordering constraint. */
494  pe_order_load = 0x200000, /* Only relevant if... */
495  pe_order_one_or_more = 0x400000, /* 'then' is runnable only if one or more of its dependencies are too */
497 
498  pe_order_preserve = 0x1000000, /* Hack for breaking user ordering constraints with container resources */
499  pe_order_then_cancels_first = 0x2000000, // if 'then' becomes required, 'first' becomes optional
500  pe_order_trace = 0x4000000, /* test marker */
501 };
502 /* *INDENT-ON* */
503 
504 typedef struct pe_action_wrapper_s {
509 
510 #ifndef PCMK__NO_COMPAT
511 /* Everything here is deprecated and kept only for public API backward
512  * compatibility. It will be moved to compatibility.h when 2.1.0 is released.
513  */
514 
516 typedef struct pe_action_s action_t;
520 typedef struct pe_node_s node_t;
524 typedef struct pe_resource_s resource_t;
526 typedef struct pe_tag_s tag_t;
528 typedef struct pe_ticket_s ticket_t;
529 
530 #endif
531 
532 #ifdef __cplusplus
533 }
534 #endif
535 
536 #endif // PE_TYPES__H
GHashTable * tags
Definition: pe_types.h:169
enum pe_link_state state
Definition: pe_types.h:506
GListPtr nodes
Definition: pe_types.h:146
GListPtr allocated_rsc
Definition: pe_types.h:219
xmlNode * orig_xml
Definition: pe_types.h:308
struct pe_ticket_s pe_ticket_t
enum rsc_start_requirement needs
Definition: pe_types.h:398
pe_quorum_policy
Definition: pe_types.h:60
enum pe_quorum_policy no_quorum_policy
Definition: pe_types.h:138
A dumping ground.
GHashTable * known_on
Definition: pe_types.h:351
xmlNode * failed
Definition: pe_types.h:154
xmlNode * ops_xml
Definition: pe_types.h:309
GHashTable * attrs
Definition: pe_types.h:221
gboolean unseen
Definition: pe_types.h:205
gboolean fixed
Definition: pe_types.h:229
int runnable_before
Definition: pe_types.h:420
GListPtr dangling_migrations
Definition: pe_types.h:362
enum rsc_role_e(* state)(const pe_resource_t *, gboolean)
Definition: pe_types.h:52
GHashTable * state
Definition: pe_types.h:439
pe_check_parameters
Definition: pe_types.h:182
int priority
Definition: pe_types.h:386
pe_resource_t * container
Definition: pe_types.h:364
pe_node_t * partial_migration_source
Definition: pe_types.h:349
struct crm_time_s crm_time_t
Definition: iso8601.h:32
enum rsc_role_e role
Definition: pe_types.h:354
int count
Definition: pe_types.h:230
resource_alloc_functions_t * cmds
Definition: pe_types.h:317
gboolean standby
Definition: pe_types.h:438
int priority_fencing_delay
Definition: pe_types.h:179
Internal tracking for transition graph creation.
Definition: pe_types.h:450
xmlNode * op_defaults
Definition: pe_types.h:155
Internal tracking for transition graph creation.
Definition: pe_types.h:451
GListPtr rsc_tickets
Definition: pe_types.h:344
xmlNode * xml
Definition: pe_types.h:307
pe_resource_t * rsc
Definition: pe_types.h:388
enum rsc_role_e next_role
Definition: pe_types.h:355
enum action_fail_response on_fail
Definition: pe_types.h:399
gboolean exclusive_discover
Definition: pe_types.h:336
struct resource_object_functions_s resource_object_functions_t
pe_resource_t * remote_rsc
Definition: pe_types.h:217
char * cancel_task
Definition: pe_types.h:394
GHashTable * meta
Definition: pe_types.h:357
match resource not running anywhere
Definition: pe_types.h:85
resource_object_functions_t * fns
Definition: pe_types.h:316
GHashTable * parameters
Definition: pe_types.h:358
GListPtr fillers
Definition: pe_types.h:365
gboolean pending
Definition: pe_types.h:203
GListPtr resources
Definition: pe_types.h:147
char * id
Definition: pe_types.h:443
int order_id
Deprecated (will be removed in a future release)
Definition: pe_types.h:161
xmlNode * op_entry
Definition: pe_types.h:390
GListPtr rsc_cons
Definition: pe_types.h:341
pe_node_t * partial_migration_target
Definition: pe_types.h:348
int migration_threshold
Definition: pe_types.h:328
GHashTable * tickets
Definition: pe_types.h:141
pe_node_t * allocated_to
Definition: pe_types.h:347
pe_action_t * action
Definition: pe_types.h:507
gboolean remote_was_fenced
Definition: pe_types.h:212
pe_discover_e
Definition: pe_types.h:454
char * pending_task
Definition: pe_types.h:330
gboolean remote_requires_reset
Definition: pe_types.h:211
GListPtr actions_before
Definition: pe_types.h:425
action_fail_response
Definition: common.h:26
char * reason
Definition: pe_types.h:395
char * dc_uuid
Definition: pe_types.h:130
void * action_details
Definition: pe_types.h:431
GHashTable * extra
Definition: pe_types.h:403
pe_node_t * lock_node
Definition: pe_types.h:368
void(* count)(pe_resource_t *)
Definition: pe_types.h:55
gboolean remote_maintenance
Definition: pe_types.h:213
gboolean is_dc
Definition: pe_types.h:208
GListPtr placement_constraints
Definition: pe_types.h:148
pe_link_state
Internal tracking for transition graph creation.
Definition: pe_types.h:448
rsc_recovery_type
Definition: common.h:64
int weight
Definition: pe_types.h:228
guint remote_reconnect_ms
Definition: pe_types.h:329
pe_action_flags
Definition: pe_types.h:276
enum pe_quorum_policy no_quorum_policy_t
Definition: pe_types.h:522
pe_find
Determine behavior of pe_find_resource_with_flags()
Definition: pe_types.h:80
gboolean unpacked
Definition: pe_types.h:214
int failure_timeout
Definition: pe_types.h:327
xmlNode * rsc_defaults
Definition: pe_types.h:156
match only clone instances
Definition: pe_types.h:83
char * task
Definition: pe_types.h:392
GListPtr refs
Definition: pe_types.h:444
GHashTable * meta
Definition: pe_types.h:402
int blocked_resources
Definition: pe_types.h:171
const char * stonith_action
Definition: pe_types.h:132
struct pe_node_shared_s * details
Definition: pe_types.h:231
GListPtr running_on
Definition: pe_types.h:350
enum rsc_recovery_type recovery_type
Definition: pe_types.h:319
pe_node_t * node
Definition: pe_types.h:389
unsigned long long flags
Definition: pe_types.h:332
const char * uname
Definition: pe_types.h:196
GListPtr actions
Definition: pe_types.h:153
GHashTable * config_hash
Definition: pe_types.h:140
Internal state tracking when creating graph.
Definition: pe_types.h:300
char * clone_name
Definition: pe_types.h:306
ISO_8601 Date handling.
time_t lock_time
Definition: pe_types.h:369
enum pe_restart restart_type
Definition: pe_types.h:322
time_t recheck_by
Definition: pe_types.h:176
pe_graph_flags
Definition: pe_types.h:268
time_t last_granted
Definition: pe_types.h:437
GHashTable * utilization
Definition: pe_types.h:359
rsc_start_requirement
Definition: common.h:70
GListPtr rsc_cons_lhs
Definition: pe_types.h:340
gboolean standby
Definition: pe_types.h:201
pe_restart
Definition: pe_types.h:74
char * uuid
Definition: pe_types.h:393
gboolean expected_up
Definition: pe_types.h:207
match base name of any clone instance
Definition: pe_types.h:86
enum pe_obj_types variant
Definition: pe_types.h:314
xmlNode * input
Definition: pe_types.h:126
gboolean granted
Definition: pe_types.h:436
const char * placement_strategy
Definition: pe_types.h:133
int rsc_discover_mode
Definition: pe_types.h:232
GListPtr actions
Definition: pe_types.h:343
GListPtr rsc_location
Definition: pe_types.h:342
void(* print)(pe_resource_t *, const char *, long, void *)
Definition: pe_types.h:50
const char * id
Definition: pe_types.h:195
char * id
Definition: pe_types.h:435
guint shutdown_lock
Definition: pe_types.h:178
GListPtr ordering_constraints
Definition: pe_types.h:149
GListPtr colocation_constraints
Definition: pe_types.h:150
match resource ID or LRM history ID
Definition: pe_types.h:81
gboolean rsc_discovery_enabled
Definition: pe_types.h:210
GListPtr running_rsc
Definition: pe_types.h:218
pe_node_t * dc_node
Definition: pe_types.h:131
const char * localhost
Definition: pe_types.h:168
gboolean is_remote_node
Definition: pe_types.h:335
pe_node_t * pending_node
Definition: pe_types.h:367
GListPtr children
Definition: pe_types.h:361
void * variant_opaque
Definition: pe_types.h:315
int sort_index
Definition: pe_types.h:326
GList * param_check
Definition: pe_types.h:174
GListPtr ticket_constraints
Definition: pe_types.h:151
int disabled_resources
Definition: pe_types.h:172
node_type
Definition: pe_types.h:67
GListPtr actions_after
Definition: pe_types.h:426
void(* free)(pe_resource_t *)
Definition: pe_types.h:54
GHashTable * utilization
Definition: pe_types.h:222
enum rsc_role_e fail_role
Definition: pe_types.h:400
gboolean shutdown
Definition: pe_types.h:206
struct pe_tag_s pe_tag_t
rsc_role_e
Definition: common.h:76
enum pe_action_flags flags
Definition: pe_types.h:397
gboolean maintenance
Definition: pe_types.h:209
GHashTable * digest_cache
cache of calculated resource digests
Definition: pe_types.h:223
pe_working_set_t * cluster
Definition: pe_types.h:311
struct pe_action_wrapper_s pe_action_wrapper_t
gboolean(* active)(pe_resource_t *, gboolean)
Definition: pe_types.h:51
GHashTable * singletons
Definition: pe_types.h:144
unsigned long long flags
Definition: pe_types.h:135
int stickiness
Definition: pe_types.h:325
gboolean standby_onfail
Definition: pe_types.h:202
gboolean(* unpack)(pe_resource_t *, pe_working_set_t *)
Definition: pe_types.h:44
enum pe_ordering type
Definition: pe_types.h:505
gboolean unclean
Definition: pe_types.h:204
GList * GListPtr
Definition: crm.h:214
enum node_type type
Definition: pe_types.h:197
crm_time_t * now
Definition: pe_types.h:127
GHashTable * template_rsc_sets
Definition: pe_types.h:167
pe_ordering
Definition: pe_types.h:461
gboolean online
Definition: pe_types.h:200
uint64_t flags
Definition: remote.c:149
match resource active on specified node
Definition: pe_types.h:84
int required_runnable_before
Definition: pe_types.h:423
GList * stop_needed
Definition: pe_types.h:175
pe_resource_t * parent
Definition: pe_types.h:312
pe_obj_types
Definition: pe_types.h:35
xmlNode * graph
Definition: pe_types.h:165
char * id
Definition: pe_types.h:305
GHashTable * allowed_nodes
Definition: pe_types.h:352
match base name of anonymous clone instances
Definition: pe_types.h:82