pacemaker  1.1.17-b36b869ca8
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 
75 # define pe_flag_startup_probes 0x00010000ULL
76 # define pe_flag_have_status 0x00020000ULL
77 # define pe_flag_have_remote_nodes 0x00040000ULL
78 
79 # define pe_flag_quick_location 0x00100000ULL
80 # define pe_flag_sanitized 0x00200000ULL
81 
82 typedef struct pe_working_set_s {
83  xmlNode *input;
85 
86  /* options extracted from the input */
87  char *dc_uuid;
89  const char *stonith_action;
90  const char *placement_strategy;
91 
92  unsigned long long flags;
93 
97 
98  GHashTable *config_hash;
99  GHashTable *tickets;
100  GHashTable *singletons; /* Actions for which there can be only one - ie. fence nodeX */
101 
108 
110  xmlNode *failed;
111  xmlNode *op_defaults;
112  xmlNode *rsc_defaults;
113 
114  /* stats */
117  int order_id;
119 
120  /* final output */
121  xmlNode *graph;
122 
123  GHashTable *template_rsc_sets;
124  const char *localhost;
125  GHashTable *tags;
126 
129 
131 
133  const char *id;
134  const char *uname;
135 
136  /* @TODO convert these flags (and the ones at the end) into a bitfield */
137  gboolean online;
138  gboolean standby;
139  gboolean standby_onfail;
140  gboolean pending;
141  gboolean unclean;
142  gboolean unseen;
143  gboolean shutdown;
144  gboolean expected_up;
145  gboolean is_dc;
146 
148  GListPtr running_rsc; /* resource_t* */
149  GListPtr allocated_rsc; /* resource_t* */
150 
152 
153  GHashTable *attrs; /* char* => char* */
155 
156  GHashTable *utilization;
157 
159  GHashTable *digest_cache;
160 
161  gboolean maintenance;
165  gboolean remote_maintenance; /* what the remote-rsc is thinking */
166  gboolean unpacked;
167 };
168 
169 struct node_s {
170  int weight;
171  gboolean fixed;
172  int count;
175 };
176 
177 # include <crm/pengine/complex.h>
178 
179 # define pe_rsc_orphan 0x00000001ULL
180 # define pe_rsc_managed 0x00000002ULL
181 # define pe_rsc_block 0x00000004ULL /* Further operations are prohibited due to failure policy */
182 # define pe_rsc_orphan_container_filler 0x00000008ULL
183 
184 # define pe_rsc_notify 0x00000010ULL
185 # define pe_rsc_unique 0x00000020ULL
186 # define pe_rsc_fence_device 0x00000040ULL
187 
188 # define pe_rsc_provisional 0x00000100ULL
189 # define pe_rsc_allocating 0x00000200ULL
190 # define pe_rsc_merging 0x00000400ULL
191 # define pe_rsc_munging 0x00000800ULL
192 
193 # define pe_rsc_try_reload 0x00001000ULL
194 # define pe_rsc_reload 0x00002000ULL
195 
196 # define pe_rsc_allow_remote_remotes 0x00004000ULL
197 
198 # define pe_rsc_failed 0x00010000ULL
199 # define pe_rsc_shutdown 0x00020000ULL
200 # define pe_rsc_runnable 0x00040000ULL
201 # define pe_rsc_start_pending 0x00080000ULL
202 
203 # define pe_rsc_starting 0x00100000ULL
204 # define pe_rsc_stopping 0x00200000ULL
205 # define pe_rsc_migrating 0x00400000ULL
206 # define pe_rsc_allow_migrate 0x00800000ULL
207 
208 # define pe_rsc_failure_ignored 0x01000000ULL
209 # define pe_rsc_unexpectedly_running 0x02000000ULL
210 # define pe_rsc_maintenance 0x04000000ULL
211 
212 # define pe_rsc_needs_quorum 0x10000000ULL
213 # define pe_rsc_needs_fencing 0x20000000ULL
214 # define pe_rsc_needs_unfencing 0x40000000ULL
215 # define pe_rsc_have_unfencing 0x80000000ULL /* obsolete (not set or used by cluster) */
216 
218  pe_graph_none = 0x00000,
221  pe_graph_disable = 0x00004,
222 };
223 
224 /* *INDENT-OFF* */
226  pe_action_pseudo = 0x00001,
230 
232  pe_action_failure_is_fatal = 0x00020, /* no longer used, here for API compatibility */
235 
236  pe_action_dumped = 0x00100,
238  pe_action_clear = 0x00400,
239  pe_action_dangle = 0x00800,
240 
241  /* This action requires one or more of its dependencies to be runnable.
242  * We use this to clear the runnable flag before checking dependencies.
243  */
245 
248 };
249 /* *INDENT-ON* */
250 
251 struct resource_s {
252  char *id;
253  char *clone_name;
254  xmlNode *xml;
255  xmlNode *orig_xml;
256  xmlNode *ops_xml;
257 
260  enum pe_obj_types variant;
263 
264  enum rsc_recovery_type recovery_type;
265  enum pe_restart restart_type;
266 
267  int priority;
273 
274  gboolean is_remote_node;
275 
276  unsigned long long flags;
277 
278  GListPtr rsc_cons_lhs; /* rsc_colocation_t* */
279  GListPtr rsc_cons; /* rsc_colocation_t* */
280  GListPtr rsc_location; /* rsc_to_node_t* */
281  GListPtr actions; /* action_t* */
282  GListPtr rsc_tickets; /* rsc_ticket* */
283 
285  GListPtr running_on; /* node_t* */
286  GHashTable *known_on; /* node_t* */
287  GHashTable *allowed_nodes; /* node_t* */
288 
289  enum rsc_role_e role;
290  enum rsc_role_e next_role;
291 
292  GHashTable *meta;
293  GHashTable *parameters;
294  GHashTable *utilization;
295 
296  GListPtr children; /* resource_t* */
298 
301 
304 
306 
307  const char *isolation_wrapper;
310 
312 #ifdef ENABLE_VERSIONED_ATTRS
313 
314  xmlNode *versioned_parameters;
315 #endif
316 };
317 
318 struct pe_action_s {
319  int id;
320  int priority;
321 
324  xmlNode *op_entry;
325 
326  char *task;
327  char *uuid;
328  char *cancel_task;
329 
332  enum action_fail_response on_fail;
333  enum rsc_role_e fail_role;
334 
339 
341 
342  GHashTable *meta;
343  GHashTable *extra;
344 
345  /*
346  * These two varables are associated with the constraint logic
347  * that involves first having one or more actions runnable before
348  * then allowing this action to execute.
349  *
350  * These varables are used with features such as 'clone-min' which
351  * requires at minimum X number of cloned instances to be running
352  * before an order dependency can run. Another option that uses
353  * this is 'require-all=false' in ordering constrants. This option
354  * says "only require one instance of a resource to start before
355  * allowing dependencies to start" -- basically, require-all=false is
356  * the same as clone-min=1.
357  */
358 
359  /* current number of known runnable actions in the before list. */
361  /* the number of "before" runnable actions required for this action
362  * to be considered runnable */
364 
365  GListPtr actions_before; /* action_wrapper_t* */
366  GListPtr actions_after; /* action_wrapper_t* */
367 };
368 
369 struct ticket_s {
370  char *id;
371  gboolean granted;
372  time_t last_granted;
373  gboolean standby;
374  GHashTable *state;
375 };
376 
377 typedef struct tag_s {
378  char *id;
380 } tag_t;
381 
386 };
387 
388 /* *INDENT-OFF* */
390  pe_order_none = 0x0, /* deleted */
391  pe_order_optional = 0x1, /* pure ordering, nothing implied */
392  pe_order_apply_first_non_migratable = 0x2, /* Only apply this constraint's ordering if first is not migratable. */
393 
394  pe_order_implies_first = 0x10, /* If 'then' is required, ensure 'first' is too */
395  pe_order_implies_then = 0x20, /* If 'first' is required, ensure 'then' is too */
396  pe_order_implies_first_master = 0x40, /* Imply 'first' is required when 'then' is required and then's rsc holds Master role. */
397 
398  /* first requires then to be both runnable and migrate runnable. */
400 
401  pe_order_runnable_left = 0x100, /* 'then' requires 'first' to be runnable */
402 
403  pe_order_pseudo_left = 0x200, /* 'then' can only be pseudo if 'first' is runnable */
404  pe_order_implies_then_on_node = 0x400, /* If 'first' is required on 'nodeX',
405  * ensure instances of 'then' on 'nodeX' are too.
406  * Only really useful if 'then' is a clone and 'first' is not
407  */
408 
409  pe_order_restart = 0x1000, /* 'then' is runnable if 'first' is optional or runnable */
410  pe_order_stonith_stop = 0x2000, /* only applies if the action is non-pseudo */
411  pe_order_serialize_only = 0x4000, /* serialize */
412  pe_order_same_node = 0x8000, /* applies only if 'first' and 'then' are on same node */
413 
414  pe_order_implies_first_printed = 0x10000, /* Like ..implies_first but only ensures 'first' is printed, not mandatory */
415  pe_order_implies_then_printed = 0x20000, /* Like ..implies_then but only ensures 'then' is printed, not mandatory */
416 
417  pe_order_asymmetrical = 0x100000, /* Indicates asymmetrical one way ordering constraint. */
418  pe_order_load = 0x200000, /* Only relevant if... */
419  pe_order_one_or_more = 0x400000, /* 'then' is runnable only if one or more of its dependencies are too */
421 
422  pe_order_preserve = 0x1000000, /* Hack for breaking user ordering constraints with container resources */
423  pe_order_trace = 0x4000000, /* test marker */
424 };
425 /* *INDENT-ON* */
426 
430  enum pe_link_state state;
432 };
433 
434 const char *rsc_printable_id(resource_t *rsc);
435 gboolean cluster_status(pe_working_set_t * data_set);
437 void cleanup_calculations(pe_working_set_t * data_set);
438 resource_t *pe_find_resource(GListPtr rsc_list, const char *id_rh);
439 node_t *pe_find_node(GListPtr node_list, const char *uname);
440 node_t *pe_find_node_id(GListPtr node_list, const char *id);
441 node_t *pe_find_node_any(GListPtr node_list, const char *id, const char *uname);
442 GListPtr find_operations(const char *rsc, const char *node, gboolean active_filter,
443  pe_working_set_t * data_set);
444 
452 static inline bool
453 pe_rsc_is_clone(resource_t *rsc)
454 {
455  return rsc && ((rsc->variant == pe_clone) || (rsc->variant == pe_master));
456 }
457 
465 static inline bool
466 pe_rsc_is_unique_clone(resource_t *rsc)
467 {
468  return pe_rsc_is_clone(rsc) && is_set(rsc->flags, pe_rsc_unique);
469 }
470 
478 static inline bool
479 pe_rsc_is_anon_clone(resource_t *rsc)
480 {
481  return pe_rsc_is_clone(rsc) && is_not_set(rsc->flags, pe_rsc_unique);
482 }
483 
484 #endif
GHashTable * tags
Definition: status.h:125
GListPtr nodes
Definition: status.h:102
const char * uname
Definition: status.h:134
int count
Definition: status.h:172
xmlNode * xml
Definition: status.h:254
xmlNode * failed
Definition: status.h:110
GHashTable * utilization
Definition: status.h:294
int runnable_before
Definition: status.h:360
int priority
Definition: status.h:320
int default_resource_stickiness
Definition: status.h:95
const char * id
Definition: status.h:133
int weight
Definition: status.h:170
int sort_index
Definition: status.h:269
pe_graph_flags
Definition: status.h:217
struct crm_time_s crm_time_t
Definition: iso8601.h:37
time_t last_granted
Definition: status.h:372
xmlNode * op_defaults
Definition: status.h:111
gboolean exclusive_discover
Definition: status.h:308
GListPtr rsc_location
Definition: status.h:280
char * cancel_task
Definition: status.h:328
GListPtr running_rsc
Definition: status.h:148
enum pe_obj_types variant
Definition: status.h:260
gboolean pending
Definition: status.h:140
node_t * partial_migration_source
Definition: status.h:300
gboolean fixed
Definition: status.h:171
GListPtr resources
Definition: status.h:103
node_t * pe_find_node(GListPtr node_list, const char *uname)
Definition: status.c:298
no_quorum_policy_t no_quorum_policy
Definition: status.h:96
char * clone_name
Definition: status.h:253
xmlNode * orig_xml
Definition: status.h:255
xmlNode * op_entry
Definition: status.h:324
int max_valid_nodes
Definition: status.h:116
int id
Definition: status.h:319
resource_t * remote_rsc
Definition: status.h:151
action_t * pre_notify
Definition: status.h:335
GHashTable * tickets
Definition: status.h:99
node_t * dc_node
Definition: status.h:88
GListPtr children
Definition: status.h:296
GListPtr actions_before
Definition: status.h:365
action_fail_response
Definition: common.h:29
char * dc_uuid
Definition: status.h:87
gboolean is_remote_node
Definition: status.h:274
int stonith_timeout
Definition: status.h:94
gboolean standby
Definition: status.h:138
pe_action_flags
Definition: status.h:225
GHashTable * extra
Definition: status.h:343
char * id
Definition: status.h:252
GHashTable * parameters
Definition: status.h:293
const char * isolation_wrapper
Definition: status.h:307
GListPtr placement_constraints
Definition: status.h:104
GHashTable * utilization
Definition: status.h:156
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:3452
rsc_recovery_type
Definition: common.h:69
struct node_shared_s * details
Definition: status.h:173
pe_working_set_t * cluster
Definition: status.h:311
void cleanup_calculations(pe_working_set_t *data_set)
Definition: status.c:181
GListPtr rsc_cons_lhs
Definition: status.h:278
gboolean unclean
Definition: status.h:141
pe_restart
Definition: status.h:46
int effective_priority
Definition: status.h:271
char * pending_task
Definition: status.h:305
xmlNode * rsc_defaults
Definition: status.h:112
pe_obj_types
Definition: complex.h:30
node_t * partial_migration_target
Definition: status.h:299
action_t * post_notified
Definition: status.h:338
resource_object_functions_t * fns
Definition: status.h:261
char * task
Definition: status.h:326
enum no_quorum_policy_e no_quorum_policy_t
resource_t * container
Definition: status.h:302
GHashTable * allowed_nodes
Definition: status.h:287
void * variant_opaque
Definition: status.h:259
GHashTable * digest_cache
Definition: status.h:159
GListPtr rsc_cons
Definition: status.h:279
GHashTable * meta
Definition: status.h:342
int blocked_resources
Definition: status.h:127
void set_working_set_defaults(pe_working_set_t *data_set)
Definition: status.c:234
GListPtr refs
Definition: status.h:379
gboolean unpacked
Definition: status.h:166
const char * stonith_action
Definition: status.h:89
action_t * pre_notified
Definition: status.h:336
node_type
Definition: status.h:40
pe_find
Definition: status.h:51
int migration_threshold
Definition: status.h:272
GListPtr actions
Definition: status.h:109
GHashTable * config_hash
Definition: status.h:98
action_t * post_notify
Definition: status.h:337
ISO_8601 Date handling.
gboolean is_dc
Definition: status.h:145
unsigned long long flags
Definition: status.h:276
pe_link_state
Definition: status.h:382
rsc_start_requirement
Definition: common.h:75
resource_t * parent
Definition: status.h:258
no_quorum_policy_e
Definition: status.h:33
char * uuid
Definition: status.h:327
GListPtr dangling_migrations
Definition: status.h:297
xmlNode * input
Definition: status.h:83
GListPtr fillers
Definition: status.h:303
GListPtr rsc_tickets
Definition: status.h:282
const char * placement_strategy
Definition: status.h:90
gboolean unseen
Definition: status.h:142
int failure_timeout
Definition: status.h:270
int remote_reconnect_interval
Definition: status.h:309
gboolean remote_maintenance
Definition: status.h:165
GListPtr ordering_constraints
Definition: status.h:105
node_t * node
Definition: status.h:323
GListPtr colocation_constraints
Definition: status.h:106
action_t * action
Definition: status.h:431
int stickiness
Definition: status.h:268
GListPtr actions
Definition: status.h:281
gboolean maintenance
Definition: status.h:161
pe_ordering
Definition: status.h:389
#define pe_rsc_unique
Definition: status.h:185
const char * localhost
Definition: status.h:124
GHashTable * meta
Definition: status.h:292
node_t * pe_find_node_any(GListPtr node_list, const char *id, const char *uname)
Definition: status.c:270
gboolean standby_onfail
Definition: status.h:139
int seen_count
Definition: status.h:340
GListPtr ticket_constraints
Definition: status.h:107
int disabled_resources
Definition: status.h:128
gboolean cluster_status(pe_working_set_t *data_set)
Definition: status.c:51
GHashTable * attrs
Definition: status.h:153
gboolean online
Definition: status.h:137
gboolean shutdown
Definition: status.h:143
gboolean rsc_discovery_enabled
Definition: status.h:162
GListPtr actions_after
Definition: status.h:366
gboolean remote_requires_reset
Definition: status.h:163
char * id
Definition: status.h:378
node_t * allocated_to
Definition: status.h:284
rsc_role_e
Definition: common.h:81
node_t * pe_find_node_id(GListPtr node_list, const char *id)
Definition: status.c:282
GHashTable * known_on
Definition: status.h:286
gboolean standby
Definition: status.h:373
Definition: status.h:377
struct resource_alloc_functions_s resource_alloc_functions_t
Definition: complex.h:65
gboolean expected_up
Definition: status.h:144
int rsc_discover_mode
Definition: status.h:174
gboolean granted
Definition: status.h:371
Definition: status.h:169
gboolean remote_was_fenced
Definition: status.h:164
int num_resources
Definition: status.h:147
resource_t * rsc
Definition: status.h:322
GHashTable * singletons
Definition: status.h:100
unsigned long long flags
Definition: status.h:92
resource_alloc_functions_t * cmds
Definition: status.h:262
xmlNode * ops_xml
Definition: status.h:256
resource_t * pe_find_resource(GListPtr rsc_list, const char *id_rh)
Definition: status.c:252
char * id
Definition: status.h:370
GList * GListPtr
Definition: crm.h:202
crm_time_t * now
Definition: status.h:84
struct pe_working_set_s pe_working_set_t
GHashTable * template_rsc_sets
Definition: status.h:123
const char * rsc_printable_id(resource_t *rsc)
Definition: utils.c:1829
GHashTable * state
Definition: status.h:374
int required_runnable_before
Definition: status.h:363
GListPtr allocated_rsc
Definition: status.h:149
enum crm_ais_msg_types type
Definition: internal.h:51
int priority
Definition: status.h:267
xmlNode * graph
Definition: status.h:121
GListPtr running_on
Definition: status.h:285