pacemaker  1.1.18-36d2962a86
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_clone = 0x004,
54  pe_find_current = 0x008,
56 };
57 
58 # define pe_flag_have_quorum 0x00000001ULL
59 # define pe_flag_symmetric_cluster 0x00000002ULL
60 # define pe_flag_is_managed_default 0x00000004ULL
61 # define pe_flag_maintenance_mode 0x00000008ULL
62 
63 # define pe_flag_stonith_enabled 0x00000010ULL
64 # define pe_flag_have_stonith_resource 0x00000020ULL
65 # define pe_flag_enable_unfencing 0x00000040ULL
66 # define pe_flag_concurrent_fencing 0x00000080ULL
67 
68 # define pe_flag_stop_rsc_orphans 0x00000100ULL
69 # define pe_flag_stop_action_orphans 0x00000200ULL
70 # define pe_flag_stop_everything 0x00000400ULL
71 
72 # define pe_flag_start_failure_fatal 0x00001000ULL
73 # define pe_flag_remove_after_stop 0x00002000ULL
74 # define pe_flag_startup_fencing 0x00004000ULL
75 
76 # define pe_flag_startup_probes 0x00010000ULL
77 # define pe_flag_have_status 0x00020000ULL
78 # define pe_flag_have_remote_nodes 0x00040000ULL
79 
80 # define pe_flag_quick_location 0x00100000ULL
81 # define pe_flag_sanitized 0x00200000ULL
82 
83 typedef struct pe_working_set_s {
84  xmlNode *input;
86 
87  /* options extracted from the input */
88  char *dc_uuid;
90  const char *stonith_action;
91  const char *placement_strategy;
92 
93  unsigned long long flags;
94 
98 
99  GHashTable *config_hash;
100  GHashTable *tickets;
101 
102  // Actions for which there can be only one (e.g. fence nodeX)
103  GHashTable *singletons;
104 
111 
113  xmlNode *failed;
114  xmlNode *op_defaults;
115  xmlNode *rsc_defaults;
116 
117  /* stats */
120  int order_id;
122 
123  /* final output */
124  xmlNode *graph;
125 
126  GHashTable *template_rsc_sets;
127  const char *localhost;
128  GHashTable *tags;
129 
132 
134 
136  const char *id;
137  const char *uname;
138 
139  /* @TODO convert these flags (and the ones at the end) into a bitfield */
140  gboolean online;
141  gboolean standby;
142  gboolean standby_onfail;
143  gboolean pending;
144  gboolean unclean;
145  gboolean unseen;
146  gboolean shutdown;
147  gboolean expected_up;
148  gboolean is_dc;
149 
151  GListPtr running_rsc; /* resource_t* */
152  GListPtr allocated_rsc; /* resource_t* */
153 
155 
156  GHashTable *attrs; /* char* => char* */
158 
159  GHashTable *utilization;
160 
162  GHashTable *digest_cache;
163 
164  gboolean maintenance;
168  gboolean remote_maintenance; /* what the remote-rsc is thinking */
169  gboolean unpacked;
170 };
171 
172 struct node_s {
173  int weight;
174  gboolean fixed;
175  int count;
178 };
179 
180 # include <crm/pengine/complex.h>
181 
182 # define pe_rsc_orphan 0x00000001ULL
183 # define pe_rsc_managed 0x00000002ULL
184 # define pe_rsc_block 0x00000004ULL
185 # define pe_rsc_orphan_container_filler 0x00000008ULL
186 
187 # define pe_rsc_notify 0x00000010ULL
188 # define pe_rsc_unique 0x00000020ULL
189 # define pe_rsc_fence_device 0x00000040ULL
190 
191 # define pe_rsc_provisional 0x00000100ULL
192 # define pe_rsc_allocating 0x00000200ULL
193 # define pe_rsc_merging 0x00000400ULL
194 # define pe_rsc_munging 0x00000800ULL
195 
196 # define pe_rsc_try_reload 0x00001000ULL
197 # define pe_rsc_reload 0x00002000ULL
198 # define pe_rsc_allow_remote_remotes 0x00004000ULL
199 
200 # define pe_rsc_failed 0x00010000ULL
201 # define pe_rsc_shutdown 0x00020000ULL
202 # define pe_rsc_runnable 0x00040000ULL
203 # define pe_rsc_start_pending 0x00080000ULL
204 
205 # define pe_rsc_starting 0x00100000ULL
206 # define pe_rsc_stopping 0x00200000ULL
207 # define pe_rsc_migrating 0x00400000ULL
208 # define pe_rsc_allow_migrate 0x00800000ULL
209 
210 # define pe_rsc_failure_ignored 0x01000000ULL
211 # define pe_rsc_unexpectedly_running 0x02000000ULL
212 # define pe_rsc_maintenance 0x04000000ULL
213 
214 # define pe_rsc_needs_quorum 0x10000000ULL
215 # define pe_rsc_needs_fencing 0x20000000ULL
216 # define pe_rsc_needs_unfencing 0x40000000ULL
217 # define pe_rsc_have_unfencing 0x80000000ULL // obsolete (not set or used by cluster)
218 
220  pe_graph_none = 0x00000,
223  pe_graph_disable = 0x00004,
224 };
225 
226 /* *INDENT-OFF* */
228  pe_action_pseudo = 0x00001,
232 
234  pe_action_failure_is_fatal = 0x00020, /* no longer used, here for API compatibility */
237 
238  pe_action_dumped = 0x00100,
240  pe_action_clear = 0x00400,
241  pe_action_dangle = 0x00800,
242 
243  /* This action requires one or more of its dependencies to be runnable.
244  * We use this to clear the runnable flag before checking dependencies.
245  */
247 
250 };
251 /* *INDENT-ON* */
252 
253 struct resource_s {
254  char *id;
255  char *clone_name;
256  xmlNode *xml;
257  xmlNode *orig_xml;
258  xmlNode *ops_xml;
259 
262  enum pe_obj_types variant;
265 
266  enum rsc_recovery_type recovery_type;
267  enum pe_restart restart_type;
268 
269  int priority;
275 
276  gboolean is_remote_node;
277 
278  unsigned long long flags;
279 
280  GListPtr rsc_cons_lhs; /* rsc_colocation_t* */
281  GListPtr rsc_cons; /* rsc_colocation_t* */
282  GListPtr rsc_location; /* rsc_to_node_t* */
283  GListPtr actions; /* action_t* */
284  GListPtr rsc_tickets; /* rsc_ticket* */
285 
287  GListPtr running_on; /* node_t* */
288  GHashTable *known_on; /* node_t* */
289  GHashTable *allowed_nodes; /* node_t* */
290 
291  enum rsc_role_e role;
292  enum rsc_role_e next_role;
293 
294  GHashTable *meta;
295  GHashTable *parameters;
296  GHashTable *utilization;
297 
298  GListPtr children; /* resource_t* */
300 
303 
306 
308 
309  const char *isolation_wrapper;
312 
314 
315 #if ENABLE_VERSIONED_ATTRS
316  xmlNode *versioned_parameters;
317 #endif
318 };
319 
320 #if ENABLE_VERSIONED_ATTRS
321 // Used as action->action_details if action->rsc is not NULL
322 typedef struct pe_rsc_action_details_s {
323  xmlNode *versioned_parameters;
324  xmlNode *versioned_meta;
325 } pe_rsc_action_details_t;
326 #endif
327 
328 struct pe_action_s {
329  int id;
330  int priority;
331 
334  xmlNode *op_entry;
335 
336  char *task;
337  char *uuid;
338  char *cancel_task;
339 
342  enum action_fail_response on_fail;
343  enum rsc_role_e fail_role;
344 
349 
351 
352  GHashTable *meta;
353  GHashTable *extra;
354 
355  /*
356  * These two varables are associated with the constraint logic
357  * that involves first having one or more actions runnable before
358  * then allowing this action to execute.
359  *
360  * These varables are used with features such as 'clone-min' which
361  * requires at minimum X number of cloned instances to be running
362  * before an order dependency can run. Another option that uses
363  * this is 'require-all=false' in ordering constrants. This option
364  * says "only require one instance of a resource to start before
365  * allowing dependencies to start" -- basically, require-all=false is
366  * the same as clone-min=1.
367  */
368 
369  /* current number of known runnable actions in the before list. */
371  /* the number of "before" runnable actions required for this action
372  * to be considered runnable */
374 
375  GListPtr actions_before; /* action_wrapper_t* */
376  GListPtr actions_after; /* action_wrapper_t* */
377 
378  /* Some of the above fields could be moved to the details,
379  * except for API backward compatibility.
380  */
381  void *action_details; // varies by type of action
382 
383  char *reason;
384 };
385 
386 struct ticket_s {
387  char *id;
388  gboolean granted;
389  time_t last_granted;
390  gboolean standby;
391  GHashTable *state;
392 };
393 
394 typedef struct tag_s {
395  char *id;
397 } 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 
432  pe_order_restart = 0x1000, /* 'then' is runnable if 'first' is optional or runnable */
433  pe_order_stonith_stop = 0x2000, /* only applies if the action is non-pseudo */
434  pe_order_serialize_only = 0x4000, /* serialize */
435  pe_order_same_node = 0x8000, /* applies only if 'first' and 'then' are on same node */
436 
437  pe_order_implies_first_printed = 0x10000, /* Like ..implies_first but only ensures 'first' is printed, not mandatory */
438  pe_order_implies_then_printed = 0x20000, /* Like ..implies_then but only ensures 'then' is printed, not mandatory */
439 
440  pe_order_asymmetrical = 0x100000, /* Indicates asymmetrical one way ordering constraint. */
441  pe_order_load = 0x200000, /* Only relevant if... */
442  pe_order_one_or_more = 0x400000, /* 'then' is runnable only if one or more of its dependencies are too */
444 
445  pe_order_preserve = 0x1000000, /* Hack for breaking user ordering constraints with container resources */
446  pe_order_then_cancels_first = 0x2000000, // if 'then' becomes required, 'first' becomes optional
447  pe_order_trace = 0x4000000, /* test marker */
448 };
449 /* *INDENT-ON* */
450 
454  enum pe_link_state state;
456 };
457 
458 const char *rsc_printable_id(resource_t *rsc);
459 gboolean cluster_status(pe_working_set_t * data_set);
461 void cleanup_calculations(pe_working_set_t * data_set);
462 resource_t *pe_find_resource(GListPtr rsc_list, const char *id_rh);
463 node_t *pe_find_node(GListPtr node_list, const char *uname);
464 node_t *pe_find_node_id(GListPtr node_list, const char *id);
465 node_t *pe_find_node_any(GListPtr node_list, const char *id, const char *uname);
466 GListPtr find_operations(const char *rsc, const char *node, gboolean active_filter,
467  pe_working_set_t * data_set);
468 int pe_bundle_replicas(const resource_t *rsc);
469 #if ENABLE_VERSIONED_ATTRS
470 pe_rsc_action_details_t *pe_rsc_action_details(pe_action_t *action);
471 #endif
472 
480 static inline bool
481 pe_rsc_is_clone(resource_t *rsc)
482 {
483  return rsc && ((rsc->variant == pe_clone) || (rsc->variant == pe_master));
484 }
485 
493 static inline bool
494 pe_rsc_is_unique_clone(resource_t *rsc)
495 {
496  return pe_rsc_is_clone(rsc) && is_set(rsc->flags, pe_rsc_unique);
497 }
498 
506 static inline bool
507 pe_rsc_is_anon_clone(resource_t *rsc)
508 {
509  return pe_rsc_is_clone(rsc) && is_not_set(rsc->flags, pe_rsc_unique);
510 }
511 
512 #endif
GHashTable * tags
Definition: status.h:128
GListPtr nodes
Definition: status.h:105
const char * uname
Definition: status.h:137
int count
Definition: status.h:175
xmlNode * xml
Definition: status.h:256
xmlNode * failed
Definition: status.h:113
GHashTable * utilization
Definition: status.h:296
int runnable_before
Definition: status.h:370
pe_discover_e
Definition: status.h:405
int priority
Definition: status.h:330
int default_resource_stickiness
Definition: status.h:96
const char * id
Definition: status.h:136
int weight
Definition: status.h:173
int sort_index
Definition: status.h:271
pe_graph_flags
Definition: status.h:219
struct crm_time_s crm_time_t
Definition: iso8601.h:37
time_t last_granted
Definition: status.h:389
xmlNode * op_defaults
Definition: status.h:114
gboolean exclusive_discover
Definition: status.h:310
GListPtr rsc_location
Definition: status.h:282
char * cancel_task
Definition: status.h:338
GListPtr running_rsc
Definition: status.h:151
enum pe_obj_types variant
Definition: status.h:262
gboolean pending
Definition: status.h:143
node_t * partial_migration_source
Definition: status.h:302
gboolean fixed
Definition: status.h:174
GListPtr resources
Definition: status.h:106
node_t * pe_find_node(GListPtr node_list, const char *uname)
Definition: status.c:295
no_quorum_policy_t no_quorum_policy
Definition: status.h:97
char * clone_name
Definition: status.h:255
xmlNode * orig_xml
Definition: status.h:257
xmlNode * op_entry
Definition: status.h:334
int max_valid_nodes
Definition: status.h:119
int id
Definition: status.h:329
resource_t * remote_rsc
Definition: status.h:154
action_t * pre_notify
Definition: status.h:345
GHashTable * tickets
Definition: status.h:100
node_t * dc_node
Definition: status.h:89
GListPtr children
Definition: status.h:298
GListPtr actions_before
Definition: status.h:375
action_fail_response
Definition: common.h:29
char * reason
Definition: status.h:383
char * dc_uuid
Definition: status.h:88
void * action_details
Definition: status.h:381
gboolean is_remote_node
Definition: status.h:276
int stonith_timeout
Definition: status.h:95
gboolean standby
Definition: status.h:141
pe_action_flags
Definition: status.h:227
GHashTable * extra
Definition: status.h:353
char * id
Definition: status.h:254
GHashTable * parameters
Definition: status.h:295
const char * isolation_wrapper
Definition: status.h:309
GListPtr placement_constraints
Definition: status.h:107
GHashTable * utilization
Definition: status.h:159
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:3389
rsc_recovery_type
Definition: common.h:69
struct node_shared_s * details
Definition: status.h:176
pe_working_set_t * cluster
Definition: status.h:313
void cleanup_calculations(pe_working_set_t *data_set)
Definition: status.c:179
GListPtr rsc_cons_lhs
Definition: status.h:280
gboolean unclean
Definition: status.h:144
pe_restart
Definition: status.h:46
int effective_priority
Definition: status.h:273
char * pending_task
Definition: status.h:307
xmlNode * rsc_defaults
Definition: status.h:115
pe_obj_types
Definition: complex.h:30
node_t * partial_migration_target
Definition: status.h:301
action_t * post_notified
Definition: status.h:348
resource_object_functions_t * fns
Definition: status.h:263
char * task
Definition: status.h:336
enum no_quorum_policy_e no_quorum_policy_t
resource_t * container
Definition: status.h:304
GHashTable * allowed_nodes
Definition: status.h:289
void * variant_opaque
Definition: status.h:261
GHashTable * digest_cache
Definition: status.h:162
GListPtr rsc_cons
Definition: status.h:281
GHashTable * meta
Definition: status.h:352
int blocked_resources
Definition: status.h:130
void set_working_set_defaults(pe_working_set_t *data_set)
Definition: status.c:232
GListPtr refs
Definition: status.h:396
gboolean unpacked
Definition: status.h:169
const char * stonith_action
Definition: status.h:90
action_t * pre_notified
Definition: status.h:346
node_type
Definition: status.h:40
pe_find
Definition: status.h:51
int migration_threshold
Definition: status.h:274
GListPtr actions
Definition: status.h:112
GHashTable * config_hash
Definition: status.h:99
action_t * post_notify
Definition: status.h:347
ISO_8601 Date handling.
gboolean is_dc
Definition: status.h:148
unsigned long long flags
Definition: status.h:278
pe_link_state
Definition: status.h:399
rsc_start_requirement
Definition: common.h:75
resource_t * parent
Definition: status.h:260
no_quorum_policy_e
Definition: status.h:33
char * uuid
Definition: status.h:337
GListPtr dangling_migrations
Definition: status.h:299
xmlNode * input
Definition: status.h:84
GListPtr fillers
Definition: status.h:305
GListPtr rsc_tickets
Definition: status.h:284
const char * placement_strategy
Definition: status.h:91
gboolean unseen
Definition: status.h:145
int failure_timeout
Definition: status.h:272
int pe_bundle_replicas(const resource_t *rsc)
Get the number of configured replicas in a bundle.
Definition: container.c:1334
int remote_reconnect_interval
Definition: status.h:311
gboolean remote_maintenance
Definition: status.h:168
GListPtr ordering_constraints
Definition: status.h:108
node_t * node
Definition: status.h:333
GListPtr colocation_constraints
Definition: status.h:109
action_t * action
Definition: status.h:455
int stickiness
Definition: status.h:270
GListPtr actions
Definition: status.h:283
gboolean maintenance
Definition: status.h:164
pe_ordering
Definition: status.h:412
#define pe_rsc_unique
Definition: status.h:188
const char * localhost
Definition: status.h:127
GHashTable * meta
Definition: status.h:294
node_t * pe_find_node_any(GListPtr node_list, const char *id, const char *uname)
Definition: status.c:267
gboolean standby_onfail
Definition: status.h:142
int seen_count
Definition: status.h:350
GListPtr ticket_constraints
Definition: status.h:110
int disabled_resources
Definition: status.h:131
gboolean cluster_status(pe_working_set_t *data_set)
Definition: status.c:51
GHashTable * attrs
Definition: status.h:156
gboolean online
Definition: status.h:140
gboolean shutdown
Definition: status.h:146
gboolean rsc_discovery_enabled
Definition: status.h:165
GListPtr actions_after
Definition: status.h:376
gboolean remote_requires_reset
Definition: status.h:166
char * id
Definition: status.h:395
node_t * allocated_to
Definition: status.h:286
rsc_role_e
Definition: common.h:81
node_t * pe_find_node_id(GListPtr node_list, const char *id)
Definition: status.c:279
GHashTable * known_on
Definition: status.h:288
gboolean standby
Definition: status.h:390
Definition: status.h:394
struct resource_alloc_functions_s resource_alloc_functions_t
Definition: complex.h:65
gboolean expected_up
Definition: status.h:147
int rsc_discover_mode
Definition: status.h:177
gboolean granted
Definition: status.h:388
Definition: status.h:172
gboolean remote_was_fenced
Definition: status.h:167
int num_resources
Definition: status.h:150
resource_t * rsc
Definition: status.h:332
GHashTable * singletons
Definition: status.h:103
unsigned long long flags
Definition: status.h:93
resource_alloc_functions_t * cmds
Definition: status.h:264
xmlNode * ops_xml
Definition: status.h:258
resource_t * pe_find_resource(GListPtr rsc_list, const char *id_rh)
Definition: status.c:249
char * id
Definition: status.h:387
GList * GListPtr
Definition: crm.h:218
crm_time_t * now
Definition: status.h:85
struct pe_working_set_s pe_working_set_t
GHashTable * template_rsc_sets
Definition: status.h:126
const char * rsc_printable_id(resource_t *rsc)
Definition: utils.c:2062
GHashTable * state
Definition: status.h:391
int required_runnable_before
Definition: status.h:373
GListPtr allocated_rsc
Definition: status.h:152
enum crm_ais_msg_types type
Definition: internal.h:51
int priority
Definition: status.h:269
xmlNode * graph
Definition: status.h:124
GListPtr running_on
Definition: status.h:287