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