pacemaker  2.0.1-15814c6c0d
Scalable High-Availability cluster resource manager
status.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2018 Andrew Beekhof <andrew@beekhof.net>
3  *
4  * This source code is licensed under the GNU Lesser General Public License
5  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
6  */
7 
8 #ifndef PENGINE_STATUS__H
9 # define PENGINE_STATUS__H
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
21 # include <glib.h>
22 # include <stdbool.h>
23 # include <crm/common/iso8601.h>
24 # include <crm/pengine/common.h>
25 
26 typedef struct pe_node_s pe_node_t;
27 typedef struct pe_action_s pe_action_t;
30 
31 # include <crm/pengine/complex.h>
32 
38 };
39 
40 enum node_type {
44 };
45 
47 enum pe_restart {
50 };
51 
53 enum pe_find {
54  pe_find_renamed = 0x001,
55  pe_find_anon = 0x002,
56  pe_find_clone = 0x004,
57  pe_find_current = 0x008,
58  pe_find_inactive = 0x010,
59  pe_find_any = 0x020,
60 };
61 
62 # define pe_flag_have_quorum 0x00000001ULL
63 # define pe_flag_symmetric_cluster 0x00000002ULL
64 # define pe_flag_maintenance_mode 0x00000008ULL
65 
66 # define pe_flag_stonith_enabled 0x00000010ULL
67 # define pe_flag_have_stonith_resource 0x00000020ULL
68 # define pe_flag_enable_unfencing 0x00000040ULL
69 # define pe_flag_concurrent_fencing 0x00000080ULL
70 
71 # define pe_flag_stop_rsc_orphans 0x00000100ULL
72 # define pe_flag_stop_action_orphans 0x00000200ULL
73 # define pe_flag_stop_everything 0x00000400ULL
74 
75 # define pe_flag_start_failure_fatal 0x00001000ULL
76 # define pe_flag_remove_after_stop 0x00002000ULL
77 # define pe_flag_startup_fencing 0x00004000ULL
78 
79 # define pe_flag_startup_probes 0x00010000ULL
80 # define pe_flag_have_status 0x00020000ULL
81 # define pe_flag_have_remote_nodes 0x00040000ULL
82 
83 # define pe_flag_quick_location 0x00100000ULL
84 # define pe_flag_sanitized 0x00200000ULL
85 # define pe_flag_stdout 0x00400000ULL
86 
88  xmlNode *input;
90 
91  /* options extracted from the input */
92  char *dc_uuid;
94  const char *stonith_action;
95  const char *placement_strategy;
96 
97  unsigned long long flags;
98 
101 
102  GHashTable *config_hash;
103  GHashTable *tickets;
104 
105  // Actions for which there can be only one (e.g. fence nodeX)
106  GHashTable *singletons;
107 
114 
116  xmlNode *failed;
117  xmlNode *op_defaults;
118  xmlNode *rsc_defaults;
119 
120  /* stats */
123  int order_id;
125 
126  /* final output */
127  xmlNode *graph;
128 
129  GHashTable *template_rsc_sets;
130  const char *localhost;
131  GHashTable *tags;
132 
135 
136  GList *param_check; // History entries that need to be checked
137  GList *stop_needed; // Containers that need stop actions
138 };
139 
141  /* Clear fail count if parameters changed for un-expired start or monitor
142  * last_failure.
143  */
145 
146  /* Clear fail count if parameters changed for start, monitor, promote, or
147  * migrate_from actions for active resources.
148  */
150 };
151 
153  const char *id;
154  const char *uname;
156 
157  /* @TODO convert these flags into a bitfield */
158  gboolean online;
159  gboolean standby;
160  gboolean standby_onfail;
161  gboolean pending;
162  gboolean unclean;
163  gboolean unseen;
164  gboolean shutdown;
165  gboolean expected_up;
166  gboolean is_dc;
167  gboolean maintenance;
171  gboolean remote_maintenance; /* what the remote-rsc is thinking */
172  gboolean unpacked;
173 
176  GListPtr running_rsc; /* pe_resource_t* */
177  GListPtr allocated_rsc; /* pe_resource_t* */
178 
179  GHashTable *attrs; /* char* => char* */
180  GHashTable *utilization;
181  GHashTable *digest_cache;
182 };
183 
184 struct pe_node_s {
185  int weight;
186  gboolean fixed;
187  int count;
190 };
191 
192 # define pe_rsc_orphan 0x00000001ULL
193 # define pe_rsc_managed 0x00000002ULL
194 # define pe_rsc_block 0x00000004ULL
195 # define pe_rsc_orphan_container_filler 0x00000008ULL
196 
197 # define pe_rsc_notify 0x00000010ULL
198 # define pe_rsc_unique 0x00000020ULL
199 # define pe_rsc_fence_device 0x00000040ULL
200 # define pe_rsc_promotable 0x00000080ULL
201 
202 # define pe_rsc_provisional 0x00000100ULL
203 # define pe_rsc_allocating 0x00000200ULL
204 # define pe_rsc_merging 0x00000400ULL
205 
206 # define pe_rsc_reload 0x00002000ULL
207 # define pe_rsc_allow_remote_remotes 0x00004000ULL
208 
209 # define pe_rsc_failed 0x00010000ULL
210 # define pe_rsc_runnable 0x00040000ULL
211 # define pe_rsc_start_pending 0x00080000ULL
212 
213 # define pe_rsc_starting 0x00100000ULL
214 # define pe_rsc_stopping 0x00200000ULL
215 # define pe_rsc_allow_migrate 0x00800000ULL
216 
217 # define pe_rsc_failure_ignored 0x01000000ULL
218 # define pe_rsc_maintenance 0x04000000ULL
219 # define pe_rsc_is_container 0x08000000ULL
220 
221 # define pe_rsc_needs_quorum 0x10000000ULL
222 # define pe_rsc_needs_fencing 0x20000000ULL
223 # define pe_rsc_needs_unfencing 0x40000000ULL
224 
226  pe_graph_none = 0x00000,
229  pe_graph_disable = 0x00004,
230 };
231 
232 /* *INDENT-OFF* */
234  pe_action_pseudo = 0x00001,
238 
242 
243  pe_action_dumped = 0x00100,
245  pe_action_clear = 0x00400,
246  pe_action_dangle = 0x00800,
247 
248  /* This action requires one or more of its dependencies to be runnable.
249  * We use this to clear the runnable flag before checking dependencies.
250  */
252 
255 };
256 /* *INDENT-ON* */
257 
259  char *id;
260  char *clone_name;
261  xmlNode *xml;
262  xmlNode *orig_xml;
263  xmlNode *ops_xml;
264 
267 
268  enum pe_obj_types variant;
272 
273  enum rsc_recovery_type recovery_type;
274 
275  // @TODO only pe_restart_restart is of interest, so merge into flags
276  enum pe_restart restart_type;
277 
278  int priority;
285 
286  unsigned long long flags;
287 
288  // @TODO merge these into flags
289  gboolean is_remote_node;
291 
294  GListPtr rsc_cons_lhs; // List of rsc_colocation_t*
295  GListPtr rsc_cons; // List of rsc_colocation_t*
296  GListPtr rsc_location; // List of pe__location_t*
297  GListPtr actions; // List of pe_action_t*
298  GListPtr rsc_tickets; // List of rsc_ticket*
300 
304  GListPtr running_on; /* pe_node_t* */
305  GHashTable *known_on; /* pe_node_t* */
306  GHashTable *allowed_nodes; /* pe_node_t* */
307 
308  enum rsc_role_e role;
309  enum rsc_role_e next_role;
310 
311  GHashTable *meta;
312  GHashTable *parameters;
313  GHashTable *utilization;
314 
315  GListPtr children; /* pe_resource_t* */
316  GListPtr dangling_migrations; /* pe_node_t* */
317 
320 
321  pe_node_t *pending_node; // Node on which pending_task is happening
322 
323 #if ENABLE_VERSIONED_ATTRS
324  xmlNode *versioned_parameters;
325 #endif
326 };
327 
328 #if ENABLE_VERSIONED_ATTRS
329 // Used as action->action_details if action->rsc is not NULL
330 typedef struct pe_rsc_action_details_s {
331  xmlNode *versioned_parameters;
332  xmlNode *versioned_meta;
333 } pe_rsc_action_details_t;
334 #endif
335 
336 struct pe_action_s {
337  int id;
338  int priority;
339 
342  xmlNode *op_entry;
343 
344  char *task;
345  char *uuid;
346  char *cancel_task;
347  char *reason;
348 
351  enum action_fail_response on_fail;
352  enum rsc_role_e fail_role;
353 
354  GHashTable *meta;
355  GHashTable *extra;
356 
357  /*
358  * These two varables are associated with the constraint logic
359  * that involves first having one or more actions runnable before
360  * then allowing this action to execute.
361  *
362  * These varables are used with features such as 'clone-min' which
363  * requires at minimum X number of cloned instances to be running
364  * before an order dependency can run. Another option that uses
365  * this is 'require-all=false' in ordering constrants. This option
366  * says "only require one instance of a resource to start before
367  * allowing dependencies to start" -- basically, require-all=false is
368  * the same as clone-min=1.
369  */
370 
371  /* current number of known runnable actions in the before list. */
373  /* the number of "before" runnable actions required for this action
374  * to be considered runnable */
376 
377  GListPtr actions_before; /* pe_action_wrapper_t* */
378  GListPtr actions_after; /* pe_action_wrapper_t* */
379 
380  /* Some of the above fields could be moved to the details,
381  * except for API backward compatibility.
382  */
383  void *action_details; // varies by type of action
384 };
385 
386 typedef struct pe_ticket_s {
387  char *id;
388  gboolean granted;
389  time_t last_granted;
390  gboolean standby;
391  GHashTable *state;
392 } pe_ticket_t;
393 
394 typedef struct pe_tag_s {
395  char *id;
397 } pe_tag_t;
398 
403 };
404 
409 };
410 
411 /* *INDENT-OFF* */
413  pe_order_none = 0x0, /* deleted */
414  pe_order_optional = 0x1, /* pure ordering, nothing implied */
415  pe_order_apply_first_non_migratable = 0x2, /* Only apply this constraint's ordering if first is not migratable. */
416 
417  pe_order_implies_first = 0x10, /* If 'then' is required, ensure 'first' is too */
418  pe_order_implies_then = 0x20, /* If 'first' is required, ensure 'then' is too */
419  pe_order_implies_first_master = 0x40, /* Imply 'first' is required when 'then' is required and then's rsc holds Master role. */
420 
421  /* first requires then to be both runnable and migrate runnable. */
423 
424  pe_order_runnable_left = 0x100, /* 'then' requires 'first' to be runnable */
425 
426  pe_order_pseudo_left = 0x200, /* 'then' can only be pseudo if 'first' is runnable */
427  pe_order_implies_then_on_node = 0x400, /* If 'first' is required on 'nodeX',
428  * ensure instances of 'then' on 'nodeX' are too.
429  * Only really useful if 'then' is a clone and 'first' is not
430  */
431  pe_order_probe = 0x800, /* If 'first->rsc' is
432  * - running but about to stop, ignore the constraint
433  * - otherwise, behave as runnable_left
434  */
435 
436  pe_order_restart = 0x1000, /* 'then' is runnable if 'first' is optional or runnable */
437  pe_order_stonith_stop = 0x2000, /* only applies if the action is non-pseudo */
438  pe_order_serialize_only = 0x4000, /* serialize */
439  pe_order_same_node = 0x8000, /* applies only if 'first' and 'then' are on same node */
440 
441  pe_order_implies_first_printed = 0x10000, /* Like ..implies_first but only ensures 'first' is printed, not mandatory */
442  pe_order_implies_then_printed = 0x20000, /* Like ..implies_then but only ensures 'then' is printed, not mandatory */
443 
444  pe_order_asymmetrical = 0x100000, /* Indicates asymmetrical one way ordering constraint. */
445  pe_order_load = 0x200000, /* Only relevant if... */
446  pe_order_one_or_more = 0x400000, /* 'then' is runnable only if one or more of its dependencies are too */
448 
449  pe_order_preserve = 0x1000000, /* Hack for breaking user ordering constraints with container resources */
450  pe_order_then_cancels_first = 0x2000000, // if 'then' becomes required, 'first' becomes optional
451  pe_order_trace = 0x4000000, /* test marker */
452 };
453 /* *INDENT-ON* */
454 
455 typedef struct pe_action_wrapper_s {
457  enum pe_link_state state;
460 
461 const char *rsc_printable_id(pe_resource_t *rsc);
462 gboolean cluster_status(pe_working_set_t * data_set);
464 void pe_free_working_set(pe_working_set_t *data_set);
466 void cleanup_calculations(pe_working_set_t * data_set);
467 void pe_reset_working_set(pe_working_set_t *data_set);
468 pe_resource_t *pe_find_resource(GListPtr rsc_list, const char *id_rh);
469 pe_resource_t *pe_find_resource_with_flags(GListPtr rsc_list, const char *id, enum pe_find flags);
470 pe_node_t *pe_find_node(GListPtr node_list, const char *uname);
471 pe_node_t *pe_find_node_id(GListPtr node_list, const char *id);
472 pe_node_t *pe_find_node_any(GListPtr node_list, const char *id, const char *uname);
473 GListPtr find_operations(const char *rsc, const char *node, gboolean active_filter,
474  pe_working_set_t * data_set);
475 int pe_bundle_replicas(const pe_resource_t *rsc);
476 #if ENABLE_VERSIONED_ATTRS
477 pe_rsc_action_details_t *pe_rsc_action_details(pe_action_t *action);
478 #endif
479 
487 static inline bool
488 pe_rsc_is_clone(pe_resource_t *rsc)
489 {
490  return rsc && (rsc->variant == pe_clone);
491 }
492 
500 static inline bool
501 pe_rsc_is_unique_clone(pe_resource_t *rsc)
502 {
503  return pe_rsc_is_clone(rsc) && is_set(rsc->flags, pe_rsc_unique);
504 }
505 
513 static inline bool
514 pe_rsc_is_anon_clone(pe_resource_t *rsc)
515 {
516  return pe_rsc_is_clone(rsc) && is_not_set(rsc->flags, pe_rsc_unique);
517 }
518 
526 static inline bool
527 pe_rsc_is_bundled(pe_resource_t *rsc)
528 {
529  return uber_parent(rsc)->parent != NULL;
530 }
531 
532 // Deprecated type aliases
533 typedef struct pe_action_s action_t;
535 typedef struct pe_node_s node_t;
536 typedef struct pe_resource_s resource_t;
537 typedef struct pe_tag_s tag_t;
538 typedef struct pe_ticket_s ticket_t;
540 
541 #ifdef __cplusplus
542 }
543 #endif
544 
545 #endif
GHashTable * tags
Definition: status.h:131
char uname[MAX_NAME]
Definition: internal.h:82
GListPtr nodes
Definition: status.h:108
GListPtr allocated_rsc
Definition: status.h:177
xmlNode * orig_xml
Definition: status.h:262
enum pe_quorum_policy no_quorum_policy
Definition: status.h:100
GHashTable * known_on
Definition: status.h:305
xmlNode * failed
Definition: status.h:116
xmlNode * ops_xml
Definition: status.h:263
GHashTable * attrs
Definition: status.h:179
gboolean unseen
Definition: status.h:163
gboolean fixed
Definition: status.h:186
int runnable_before
Definition: status.h:372
GListPtr dangling_migrations
Definition: status.h:316
pe_discover_e
Definition: status.h:405
GHashTable * state
Definition: status.h:391
int priority
Definition: status.h:338
pe_resource_t * pe_find_resource_with_flags(GListPtr rsc_list, const char *id, enum pe_find flags)
Definition: status.c:351
match base name of any clone instance
Definition: status.h:59
pe_resource_t * container
Definition: status.h:318
pe_node_t * partial_migration_source
Definition: status.h:303
void pe_free_working_set(pe_working_set_t *data_set)
Free a working set.
Definition: status.c:48
pe_graph_flags
Definition: status.h:225
struct crm_time_s crm_time_t
Definition: iso8601.h:41
match resource not running anywhere
Definition: status.h:58
int count
Definition: status.h:187
resource_alloc_functions_t * cmds
Definition: status.h:271
gboolean standby
Definition: status.h:390
pe_working_set_t * pe_new_working_set(void)
Create a new working set.
Definition: status.c:32
xmlNode * op_defaults
Definition: status.h:117
GListPtr rsc_tickets
Definition: status.h:298
match base name of anonymous clone instances
Definition: status.h:55
xmlNode * xml
Definition: status.h:261
pe_resource_t * rsc
Definition: status.h:340
gboolean exclusive_discover
Definition: status.h:290
pe_resource_t * remote_rsc
Definition: status.h:175
char * cancel_task
Definition: status.h:346
GHashTable * meta
Definition: status.h:311
resource_object_functions_t * fns
Definition: status.h:270
GHashTable * parameters
Definition: status.h:312
match resource ID or LRM history ID
Definition: status.h:54
GListPtr fillers
Definition: status.h:319
gboolean pending
Definition: status.h:161
GListPtr resources
Definition: status.h:109
char * id
Definition: status.h:395
enum pe_quorum_policy no_quorum_policy_t
Definition: status.h:539
pe_node_t * pe_find_node(GListPtr node_list, const char *uname)
Definition: status.c:397
xmlNode * op_entry
Definition: status.h:342
int max_valid_nodes
Definition: status.h:122
int id
Definition: status.h:337
GListPtr rsc_cons
Definition: status.h:295
pe_node_t * partial_migration_target
Definition: status.h:302
int migration_threshold
Definition: status.h:282
GHashTable * tickets
Definition: status.h:103
pe_node_t * allocated_to
Definition: status.h:301
pe_action_t * action
Definition: status.h:458
gboolean remote_was_fenced
Definition: status.h:170
char * pending_task
Definition: status.h:284
gboolean remote_requires_reset
Definition: status.h:169
GListPtr actions_before
Definition: status.h:377
action_fail_response
Definition: common.h:34
char * reason
Definition: status.h:347
pe_node_t * pe_find_node_id(GListPtr node_list, const char *id)
Definition: status.c:381
char * dc_uuid
Definition: status.h:92
void * action_details
Definition: status.h:383
int stonith_timeout
Definition: status.h:99
pe_action_flags
Definition: status.h:233
GHashTable * extra
Definition: status.h:355
gboolean remote_maintenance
Definition: status.h:171
gboolean is_dc
Definition: status.h:166
GListPtr placement_constraints
Definition: status.h:110
GListPtr find_operations(const char *rsc, const char *node, gboolean active_filter, pe_working_set_t *data_set)
Definition: unpack.c:3411
rsc_recovery_type
Definition: common.h:74
int weight
Definition: status.h:185
void pe_reset_working_set(pe_working_set_t *data_set)
Reset a working set to default state without freeing it.
Definition: status.c:300
guint remote_reconnect_ms
Definition: status.h:283
void cleanup_calculations(pe_working_set_t *data_set)
Reset working set to default state without freeing it or constraints.
Definition: status.c:241
pe_restart
Definition: status.h:47
struct pe_ticket_s pe_ticket_t
pe_resource_t * uber_parent(pe_resource_t *rsc)
Definition: complex.c:744
match only clone instances
Definition: status.h:56
gboolean unpacked
Definition: status.h:172
int failure_timeout
Definition: status.h:281
xmlNode * rsc_defaults
Definition: status.h:118
pe_obj_types
Definition: complex.h:15
int priority
Definition: status.h:278
char * task
Definition: status.h:344
GListPtr refs
Definition: status.h:396
int num_resources
Definition: status.h:174
GHashTable * meta
Definition: status.h:354
int blocked_resources
Definition: status.h:133
void set_working_set_defaults(pe_working_set_t *data_set)
Definition: status.c:330
const char * stonith_action
Definition: status.h:94
struct pe_node_shared_s * details
Definition: status.h:188
GListPtr running_on
Definition: status.h:304
pe_node_t * node
Definition: status.h:341
node_type
Definition: status.h:40
pe_find
Determine behavior of pe_find_resource_with_flags()
Definition: status.h:53
unsigned long long flags
Definition: status.h:286
const char * uname
Definition: status.h:154
GListPtr actions
Definition: status.h:115
GHashTable * config_hash
Definition: status.h:102
char * clone_name
Definition: status.h:260
ISO_8601 Date handling.
time_t last_granted
Definition: status.h:389
pe_link_state
Definition: status.h:399
GHashTable * utilization
Definition: status.h:313
rsc_start_requirement
Definition: common.h:80
GListPtr rsc_cons_lhs
Definition: status.h:294
gboolean standby
Definition: status.h:159
char * uuid
Definition: status.h:345
gboolean expected_up
Definition: status.h:165
enum pe_obj_types variant
Definition: status.h:268
xmlNode * input
Definition: status.h:88
gboolean granted
Definition: status.h:388
const char * placement_strategy
Definition: status.h:95
int rsc_discover_mode
Definition: status.h:189
pe_resource_t * pe_find_resource(GListPtr rsc_list, const char *id_rh)
Definition: status.c:345
GListPtr actions
Definition: status.h:297
GListPtr rsc_location
Definition: status.h:296
const char * id
Definition: status.h:153
char * id
Definition: status.h:387
pe_quorum_policy
Definition: status.h:33
GListPtr ordering_constraints
Definition: status.h:111
GListPtr colocation_constraints
Definition: status.h:112
gboolean rsc_discovery_enabled
Definition: status.h:168
GListPtr running_rsc
Definition: status.h:176
pe_node_t * dc_node
Definition: status.h:93
pe_ordering
Definition: status.h:412
#define pe_rsc_unique
Definition: status.h:198
const char * localhost
Definition: status.h:130
gboolean is_remote_node
Definition: status.h:289
pe_node_t * pending_node
Definition: status.h:321
struct pe_action_wrapper_s pe_action_wrapper_t
GListPtr children
Definition: status.h:315
void * variant_opaque
Definition: status.h:269
int sort_index
Definition: status.h:280
GList * param_check
Definition: status.h:136
GListPtr ticket_constraints
Definition: status.h:113
int disabled_resources
Definition: status.h:134
const char * rsc_printable_id(pe_resource_t *rsc)
Definition: utils.c:2097
gboolean cluster_status(pe_working_set_t *data_set)
Definition: status.c:68
GListPtr actions_after
Definition: status.h:378
GHashTable * utilization
Definition: status.h:180
gboolean shutdown
Definition: status.h:164
rsc_role_e
Definition: common.h:86
gboolean maintenance
Definition: status.h:167
GHashTable * digest_cache
cache of calculated resource digests
Definition: status.h:181
pe_working_set_t * cluster
Definition: status.h:265
struct resource_alloc_functions_s resource_alloc_functions_t
Definition: complex.h:48
GHashTable * singletons
Definition: status.h:106
unsigned long long flags
Definition: status.h:97
int stickiness
Definition: status.h:279
gboolean standby_onfail
Definition: status.h:160
struct pe_tag_s pe_tag_t
gboolean unclean
Definition: status.h:162
GList * GListPtr
Definition: crm.h:190
crm_time_t * now
Definition: status.h:89
GHashTable * template_rsc_sets
Definition: status.h:129
pe_node_t * pe_find_node_any(GListPtr node_list, const char *id, const char *uname)
Definition: status.c:369
gboolean online
Definition: status.h:158
pe_check_parameters
Definition: status.h:140
int pe_bundle_replicas(const pe_resource_t *rsc)
Get the number of configured replicas in a bundle.
Definition: container.c:1618
int required_runnable_before
Definition: status.h:375
GList * stop_needed
Definition: status.h:137
pe_resource_t * parent
Definition: status.h:266
enum crm_ais_msg_types type
Definition: internal.h:80
xmlNode * graph
Definition: status.h:127
char * id
Definition: status.h:259
GHashTable * allowed_nodes
Definition: status.h:306
match resource active on specified node
Definition: status.h:57