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