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