pacemaker  1.1.18-1a4ef7d180
Scalable High-Availability cluster resource manager
status.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004 Andrew Beekhof <andrew@beekhof.net>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This software is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 #ifndef PENGINE_STATUS__H
19 # define PENGINE_STATUS__H
20 
21 # include <glib.h>
22 # include <stdbool.h>
23 # include <crm/common/iso8601.h>
24 # include <crm/pengine/common.h>
25 
26 typedef struct node_s pe_node_t;
27 typedef struct node_s node_t;
28 typedef struct pe_action_s action_t;
29 typedef struct pe_action_s pe_action_t;
30 typedef struct resource_s resource_t;
31 typedef struct ticket_s ticket_t;
32 
33 typedef enum no_quorum_policy_e {
39 
40 enum node_type {
44 };
45 
46 enum pe_restart {
49 };
50 
51 enum pe_find {
52  pe_find_renamed = 0x001,
53  pe_find_anon = 0x002,
54  pe_find_clone = 0x004,
55  pe_find_current = 0x008,
57 };
58 
59 # define pe_flag_have_quorum 0x00000001ULL
60 # define pe_flag_symmetric_cluster 0x00000002ULL
61 # define pe_flag_is_managed_default 0x00000004ULL
62 # define pe_flag_maintenance_mode 0x00000008ULL
63 
64 # define pe_flag_stonith_enabled 0x00000010ULL
65 # define pe_flag_have_stonith_resource 0x00000020ULL
66 # define pe_flag_enable_unfencing 0x00000040ULL
67 # define pe_flag_concurrent_fencing 0x00000080ULL
68 
69 # define pe_flag_stop_rsc_orphans 0x00000100ULL
70 # define pe_flag_stop_action_orphans 0x00000200ULL
71 # define pe_flag_stop_everything 0x00000400ULL
72 
73 # define pe_flag_start_failure_fatal 0x00001000ULL
74 # define pe_flag_remove_after_stop 0x00002000ULL
75 # define pe_flag_startup_fencing 0x00004000ULL
76 
77 # define pe_flag_startup_probes 0x00010000ULL
78 # define pe_flag_have_status 0x00020000ULL
79 # define pe_flag_have_remote_nodes 0x00040000ULL
80 
81 # define pe_flag_quick_location 0x00100000ULL
82 # define pe_flag_sanitized 0x00200000ULL
83 
84 typedef struct pe_working_set_s {
85  xmlNode *input;
87 
88  /* options extracted from the input */
89  char *dc_uuid;
91  const char *stonith_action;
92  const char *placement_strategy;
93 
94  unsigned long long flags;
95 
99 
100  GHashTable *config_hash;
101  GHashTable *tickets;
102 
103  // Actions for which there can be only one (e.g. fence nodeX)
104  GHashTable *singletons;
105 
112 
114  xmlNode *failed;
115  xmlNode *op_defaults;
116  xmlNode *rsc_defaults;
117 
118  /* stats */
121  int order_id;
123 
124  /* final output */
125  xmlNode *graph;
126 
127  GHashTable *template_rsc_sets;
128  const char *localhost;
129  GHashTable *tags;
130 
133 
135 
137  const char *id;
138  const char *uname;
139 
140  /* @TODO convert these flags (and the ones at the end) into a bitfield */
141  gboolean online;
142  gboolean standby;
143  gboolean standby_onfail;
144  gboolean pending;
145  gboolean unclean;
146  gboolean unseen;
147  gboolean shutdown;
148  gboolean expected_up;
149  gboolean is_dc;
150 
152  GListPtr running_rsc; /* resource_t* */
153  GListPtr allocated_rsc; /* resource_t* */
154 
156 
157  GHashTable *attrs; /* char* => char* */
159 
160  GHashTable *utilization;
161 
163  GHashTable *digest_cache;
164 
165  gboolean maintenance;
169  gboolean remote_maintenance; /* what the remote-rsc is thinking */
170  gboolean unpacked;
171 };
172 
173 struct node_s {
174  int weight;
175  gboolean fixed;
176  int count;
179 };
180 
181 # include <crm/pengine/complex.h>
182 
183 # define pe_rsc_orphan 0x00000001ULL
184 # define pe_rsc_managed 0x00000002ULL
185 # define pe_rsc_block 0x00000004ULL
186 # define pe_rsc_orphan_container_filler 0x00000008ULL
187 
188 # define pe_rsc_notify 0x00000010ULL
189 # define pe_rsc_unique 0x00000020ULL
190 # define pe_rsc_fence_device 0x00000040ULL
191 
192 # define pe_rsc_provisional 0x00000100ULL
193 # define pe_rsc_allocating 0x00000200ULL
194 # define pe_rsc_merging 0x00000400ULL
195 # define pe_rsc_munging 0x00000800ULL
196 
197 # define pe_rsc_try_reload 0x00001000ULL
198 # define pe_rsc_reload 0x00002000ULL
199 # define pe_rsc_allow_remote_remotes 0x00004000ULL
200 
201 # define pe_rsc_failed 0x00010000ULL
202 # define pe_rsc_shutdown 0x00020000ULL
203 # define pe_rsc_runnable 0x00040000ULL
204 # define pe_rsc_start_pending 0x00080000ULL
205 
206 # define pe_rsc_starting 0x00100000ULL
207 # define pe_rsc_stopping 0x00200000ULL
208 # define pe_rsc_migrating 0x00400000ULL
209 # define pe_rsc_allow_migrate 0x00800000ULL
210 
211 # define pe_rsc_failure_ignored 0x01000000ULL
212 # define pe_rsc_unexpectedly_running 0x02000000ULL
213 # define pe_rsc_maintenance 0x04000000ULL
214 # define pe_rsc_is_container 0x08000000ULL
215 
216 # define pe_rsc_needs_quorum 0x10000000ULL
217 # define pe_rsc_needs_fencing 0x20000000ULL
218 # define pe_rsc_needs_unfencing 0x40000000ULL
219 # define pe_rsc_have_unfencing 0x80000000ULL // obsolete (not set or used by cluster)
220 
222  pe_graph_none = 0x00000,
225  pe_graph_disable = 0x00004,
226 };
227 
228 /* *INDENT-OFF* */
230  pe_action_pseudo = 0x00001,
234 
236  pe_action_failure_is_fatal = 0x00020, /* no longer used, here for API compatibility */
239 
240  pe_action_dumped = 0x00100,
242  pe_action_clear = 0x00400,
243  pe_action_dangle = 0x00800,
244 
245  /* This action requires one or more of its dependencies to be runnable.
246  * We use this to clear the runnable flag before checking dependencies.
247  */
249 
252 };
253 /* *INDENT-ON* */
254 
255 struct resource_s {
256  char *id;
257  char *clone_name;
258  xmlNode *xml;
259  xmlNode *orig_xml;
260  xmlNode *ops_xml;
261 
264  enum pe_obj_types variant;
267 
268  enum rsc_recovery_type recovery_type;
269  enum pe_restart restart_type;
270 
271  int priority;
277 
278  gboolean is_remote_node;
279 
280  unsigned long long flags;
281 
282  GListPtr rsc_cons_lhs; /* rsc_colocation_t* */
283  GListPtr rsc_cons; /* rsc_colocation_t* */
284  GListPtr rsc_location; /* rsc_to_node_t* */
285  GListPtr actions; /* action_t* */
286  GListPtr rsc_tickets; /* rsc_ticket* */
287 
289  GListPtr running_on; /* node_t* */
290  GHashTable *known_on; /* node_t* */
291  GHashTable *allowed_nodes; /* node_t* */
292 
293  enum rsc_role_e role;
294  enum rsc_role_e next_role;
295 
296  GHashTable *meta;
297  GHashTable *parameters;
298  GHashTable *utilization;
299 
300  GListPtr children; /* resource_t* */
302 
305 
308 
310 
311  const char *isolation_wrapper;
314 
316 
317 #if ENABLE_VERSIONED_ATTRS
318  xmlNode *versioned_parameters;
319 #endif
320 };
321 
322 #if ENABLE_VERSIONED_ATTRS
323 // Used as action->action_details if action->rsc is not NULL
324 typedef struct pe_rsc_action_details_s {
325  xmlNode *versioned_parameters;
326  xmlNode *versioned_meta;
327 } pe_rsc_action_details_t;
328 #endif
329 
330 struct pe_action_s {
331  int id;
332  int priority;
333 
336  xmlNode *op_entry;
337 
338  char *task;
339  char *uuid;
340  char *cancel_task;
341 
344  enum action_fail_response on_fail;
345  enum rsc_role_e fail_role;
346 
351 
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; /* action_wrapper_t* */
378  GListPtr actions_after; /* 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  char *reason;
386 };
387 
388 struct ticket_s {
389  char *id;
390  gboolean granted;
391  time_t last_granted;
392  gboolean standby;
393  GHashTable *state;
394 };
395 
396 typedef struct tag_s {
397  char *id;
399 } tag_t;
400 
405 };
406 
411 };
412 
413 /* *INDENT-OFF* */
415  pe_order_none = 0x0, /* deleted */
416  pe_order_optional = 0x1, /* pure ordering, nothing implied */
417  pe_order_apply_first_non_migratable = 0x2, /* Only apply this constraint's ordering if first is not migratable. */
418 
419  pe_order_implies_first = 0x10, /* If 'then' is required, ensure 'first' is too */
420  pe_order_implies_then = 0x20, /* If 'first' is required, ensure 'then' is too */
421  pe_order_implies_first_master = 0x40, /* Imply 'first' is required when 'then' is required and then's rsc holds Master role. */
422 
423  /* first requires then to be both runnable and migrate runnable. */
425 
426  pe_order_runnable_left = 0x100, /* 'then' requires 'first' to be runnable */
427 
428  pe_order_pseudo_left = 0x200, /* 'then' can only be pseudo if 'first' is runnable */
429  pe_order_implies_then_on_node = 0x400, /* If 'first' is required on 'nodeX',
430  * ensure instances of 'then' on 'nodeX' are too.
431  * Only really useful if 'then' is a clone and 'first' is not
432  */
433  pe_order_probe = 0x800, /* If 'first->rsc' is
434  * - running but about to stop, ignore the constraint
435  * - otherwise, behave as runnable_left
436  */
437 
438  pe_order_restart = 0x1000, /* 'then' is runnable if 'first' is optional or runnable */
439  pe_order_stonith_stop = 0x2000, /* only applies if the action is non-pseudo */
440  pe_order_serialize_only = 0x4000, /* serialize */
441  pe_order_same_node = 0x8000, /* applies only if 'first' and 'then' are on same node */
442 
443  pe_order_implies_first_printed = 0x10000, /* Like ..implies_first but only ensures 'first' is printed, not mandatory */
444  pe_order_implies_then_printed = 0x20000, /* Like ..implies_then but only ensures 'then' is printed, not mandatory */
445 
446  pe_order_asymmetrical = 0x100000, /* Indicates asymmetrical one way ordering constraint. */
447  pe_order_load = 0x200000, /* Only relevant if... */
448  pe_order_one_or_more = 0x400000, /* 'then' is runnable only if one or more of its dependencies are too */
450 
451  pe_order_preserve = 0x1000000, /* Hack for breaking user ordering constraints with container resources */
452  pe_order_then_cancels_first = 0x2000000, // if 'then' becomes required, 'first' becomes optional
453  pe_order_trace = 0x4000000, /* test marker */
454 };
455 /* *INDENT-ON* */
456 
460  enum pe_link_state state;
462 };
463 
464 const char *rsc_printable_id(resource_t *rsc);
465 gboolean cluster_status(pe_working_set_t * data_set);
467 void cleanup_calculations(pe_working_set_t * data_set);
468 resource_t *pe_find_resource(GListPtr rsc_list, const char *id_rh);
469 resource_t *pe_find_resource_with_flags(GListPtr rsc_list, const char *id, enum pe_find flags);
470 node_t *pe_find_node(GListPtr node_list, const char *uname);
471 node_t *pe_find_node_id(GListPtr node_list, const char *id);
472 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 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(resource_t *rsc)
489 {
490  return rsc && ((rsc->variant == pe_clone) || (rsc->variant == pe_master));
491 }
492 
500 static inline bool
501 pe_rsc_is_unique_clone(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(resource_t *rsc)
515 {
516  return pe_rsc_is_clone(rsc) && is_not_set(rsc->flags, pe_rsc_unique);
517 }
518 
519 #endif
GHashTable * tags
Definition: status.h:129
GListPtr nodes
Definition: status.h:106
const char * uname
Definition: status.h:138
int count
Definition: status.h:176
xmlNode * xml
Definition: status.h:258
xmlNode * failed
Definition: status.h:114
GHashTable * utilization
Definition: status.h:298
int runnable_before
Definition: status.h:372
pe_discover_e
Definition: status.h:407
int priority
Definition: status.h:332
int default_resource_stickiness
Definition: status.h:97
const char * id
Definition: status.h:137
int weight
Definition: status.h:174
int sort_index
Definition: status.h:273
pe_graph_flags
Definition: status.h:221
struct crm_time_s crm_time_t
Definition: iso8601.h:37
time_t last_granted
Definition: status.h:391
xmlNode * op_defaults
Definition: status.h:115
gboolean exclusive_discover
Definition: status.h:312
GListPtr rsc_location
Definition: status.h:284
char * cancel_task
Definition: status.h:340
GListPtr running_rsc
Definition: status.h:152
enum pe_obj_types variant
Definition: status.h:264
gboolean pending
Definition: status.h:144
node_t * partial_migration_source
Definition: status.h:304
gboolean fixed
Definition: status.h:175
GListPtr resources
Definition: status.h:107
node_t * pe_find_node(GListPtr node_list, const char *uname)
Definition: status.c:301
no_quorum_policy_t no_quorum_policy
Definition: status.h:98
char * clone_name
Definition: status.h:257
xmlNode * orig_xml
Definition: status.h:259
xmlNode * op_entry
Definition: status.h:336
int max_valid_nodes
Definition: status.h:120
int id
Definition: status.h:331
resource_t * remote_rsc
Definition: status.h:155
action_t * pre_notify
Definition: status.h:347
GHashTable * tickets
Definition: status.h:101
node_t * dc_node
Definition: status.h:90
GListPtr children
Definition: status.h:300
GListPtr actions_before
Definition: status.h:377
action_fail_response
Definition: common.h:29
char * reason
Definition: status.h:385
char * dc_uuid
Definition: status.h:89
void * action_details
Definition: status.h:383
gboolean is_remote_node
Definition: status.h:278
int stonith_timeout
Definition: status.h:96
gboolean standby
Definition: status.h:142
pe_action_flags
Definition: status.h:229
GHashTable * extra
Definition: status.h:355
char * id
Definition: status.h:256
GHashTable * parameters
Definition: status.h:297
const char * isolation_wrapper
Definition: status.h:311
GListPtr placement_constraints
Definition: status.h:108
GHashTable * utilization
Definition: status.h:160
char uname[MAX_NAME]
Definition: internal.h:53
struct tag_s tag_t
GListPtr find_operations(const char *rsc, const char *node, gboolean active_filter, pe_working_set_t *data_set)
Definition: unpack.c:3420
rsc_recovery_type
Definition: common.h:69
struct node_shared_s * details
Definition: status.h:177
pe_working_set_t * cluster
Definition: status.h:315
void cleanup_calculations(pe_working_set_t *data_set)
Definition: status.c:179
GListPtr rsc_cons_lhs
Definition: status.h:282
gboolean unclean
Definition: status.h:145
pe_restart
Definition: status.h:46
int effective_priority
Definition: status.h:275
char * pending_task
Definition: status.h:309
xmlNode * rsc_defaults
Definition: status.h:116
pe_obj_types
Definition: complex.h:30
node_t * partial_migration_target
Definition: status.h:303
action_t * post_notified
Definition: status.h:350
resource_object_functions_t * fns
Definition: status.h:265
char * task
Definition: status.h:338
enum no_quorum_policy_e no_quorum_policy_t
resource_t * container
Definition: status.h:306
GHashTable * allowed_nodes
Definition: status.h:291
void * variant_opaque
Definition: status.h:263
GHashTable * digest_cache
Definition: status.h:163
GListPtr rsc_cons
Definition: status.h:283
GHashTable * meta
Definition: status.h:354
int blocked_resources
Definition: status.h:131
void set_working_set_defaults(pe_working_set_t *data_set)
Definition: status.c:232
GListPtr refs
Definition: status.h:398
gboolean unpacked
Definition: status.h:170
const char * stonith_action
Definition: status.h:91
action_t * pre_notified
Definition: status.h:348
node_type
Definition: status.h:40
pe_find
Definition: status.h:51
int migration_threshold
Definition: status.h:276
GListPtr actions
Definition: status.h:113
GHashTable * config_hash
Definition: status.h:100
action_t * post_notify
Definition: status.h:349
ISO_8601 Date handling.
gboolean is_dc
Definition: status.h:149
unsigned long long flags
Definition: status.h:280
pe_link_state
Definition: status.h:401
rsc_start_requirement
Definition: common.h:75
resource_t * parent
Definition: status.h:262
no_quorum_policy_e
Definition: status.h:33
char * uuid
Definition: status.h:339
GListPtr dangling_migrations
Definition: status.h:301
xmlNode * input
Definition: status.h:85
GListPtr fillers
Definition: status.h:307
GListPtr rsc_tickets
Definition: status.h:286
const char * placement_strategy
Definition: status.h:92
gboolean unseen
Definition: status.h:146
int failure_timeout
Definition: status.h:274
int pe_bundle_replicas(const resource_t *rsc)
Get the number of configured replicas in a bundle.
Definition: container.c:1448
int remote_reconnect_interval
Definition: status.h:313
gboolean remote_maintenance
Definition: status.h:169
GListPtr ordering_constraints
Definition: status.h:109
node_t * node
Definition: status.h:335
GListPtr colocation_constraints
Definition: status.h:110
action_t * action
Definition: status.h:461
int stickiness
Definition: status.h:272
GListPtr actions
Definition: status.h:285
gboolean maintenance
Definition: status.h:165
pe_ordering
Definition: status.h:414
#define pe_rsc_unique
Definition: status.h:189
const char * localhost
Definition: status.h:128
GHashTable * meta
Definition: status.h:296
node_t * pe_find_node_any(GListPtr node_list, const char *id, const char *uname)
Definition: status.c:273
gboolean standby_onfail
Definition: status.h:143
int seen_count
Definition: status.h:352
GListPtr ticket_constraints
Definition: status.h:111
int disabled_resources
Definition: status.h:132
gboolean cluster_status(pe_working_set_t *data_set)
Definition: status.c:51
GHashTable * attrs
Definition: status.h:157
gboolean online
Definition: status.h:141
resource_t * pe_find_resource_with_flags(GListPtr rsc_list, const char *id, enum pe_find flags)
Definition: status.c:255
gboolean shutdown
Definition: status.h:147
gboolean rsc_discovery_enabled
Definition: status.h:166
GListPtr actions_after
Definition: status.h:378
gboolean remote_requires_reset
Definition: status.h:167
char * id
Definition: status.h:397
node_t * allocated_to
Definition: status.h:288
rsc_role_e
Definition: common.h:81
node_t * pe_find_node_id(GListPtr node_list, const char *id)
Definition: status.c:285
GHashTable * known_on
Definition: status.h:290
gboolean standby
Definition: status.h:392
Definition: status.h:396
struct resource_alloc_functions_s resource_alloc_functions_t
Definition: complex.h:65
gboolean expected_up
Definition: status.h:148
int rsc_discover_mode
Definition: status.h:178
gboolean granted
Definition: status.h:390
Definition: status.h:173
gboolean remote_was_fenced
Definition: status.h:168
int num_resources
Definition: status.h:151
resource_t * rsc
Definition: status.h:334
GHashTable * singletons
Definition: status.h:104
unsigned long long flags
Definition: status.h:94
resource_alloc_functions_t * cmds
Definition: status.h:266
xmlNode * ops_xml
Definition: status.h:260
resource_t * pe_find_resource(GListPtr rsc_list, const char *id_rh)
Definition: status.c:249
char * id
Definition: status.h:389
GList * GListPtr
Definition: crm.h:218
crm_time_t * now
Definition: status.h:86
struct pe_working_set_s pe_working_set_t
GHashTable * template_rsc_sets
Definition: status.h:127
const char * rsc_printable_id(resource_t *rsc)
Definition: utils.c:2082
GHashTable * state
Definition: status.h:393
int required_runnable_before
Definition: status.h:375
GListPtr allocated_rsc
Definition: status.h:153
enum crm_ais_msg_types type
Definition: internal.h:51
int priority
Definition: status.h:271
xmlNode * graph
Definition: status.h:125
GListPtr running_on
Definition: status.h:289