pacemaker  2.1.6-802a72226b
Scalable High-Availability cluster resource manager
internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2023 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU Lesser General Public License
7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8  */
9 
10 #ifndef PE_INTERNAL__H
11 # define PE_INTERNAL__H
12 
13 # include <stdint.h>
14 # include <string.h>
15 # include <crm/msg_xml.h>
16 # include <crm/pengine/status.h>
18 # include <crm/common/internal.h>
21 
22 const char *pe__resource_description(const pe_resource_t *rsc, uint32_t show_opts);
23 
25  // Whether instances should be started sequentially
26  pe__clone_ordered = (1 << 0),
27 
28  // Whether promotion scores have been added
30 
31  // Whether promotion constraints have been added
33 };
34 
35 bool pe__clone_is_ordered(const pe_resource_t *clone);
36 int pe__set_clone_flag(pe_resource_t *clone, enum pe__clone_flags flag);
37 
38 
40  pe__group_ordered = (1 << 0), // Members start sequentially
41  pe__group_colocated = (1 << 1), // Members must be on same node
42 };
43 
44 bool pe__group_flag_is_set(const pe_resource_t *group, uint32_t flags);
46 
47 
48 # define pe_rsc_info(rsc, fmt, args...) crm_log_tag(LOG_INFO, rsc ? rsc->id : "<NULL>", fmt, ##args)
49 # define pe_rsc_debug(rsc, fmt, args...) crm_log_tag(LOG_DEBUG, rsc ? rsc->id : "<NULL>", fmt, ##args)
50 # define pe_rsc_trace(rsc, fmt, args...) crm_log_tag(LOG_TRACE, rsc ? rsc->id : "<NULL>", fmt, ##args)
51 
52 # define pe_err(fmt...) do { \
53  was_processing_error = TRUE; \
54  pcmk__config_err(fmt); \
55  } while (0)
56 
57 # define pe_warn(fmt...) do { \
58  was_processing_warning = TRUE; \
59  pcmk__config_warn(fmt); \
60  } while (0)
61 
62 # define pe_proc_err(fmt...) { was_processing_error = TRUE; crm_err(fmt); }
63 # define pe_proc_warn(fmt...) { was_processing_warning = TRUE; crm_warn(fmt); }
64 
65 #define pe__set_working_set_flags(working_set, flags_to_set) do { \
66  (working_set)->flags = pcmk__set_flags_as(__func__, __LINE__, \
67  LOG_TRACE, "Working set", crm_system_name, \
68  (working_set)->flags, (flags_to_set), #flags_to_set); \
69  } while (0)
70 
71 #define pe__clear_working_set_flags(working_set, flags_to_clear) do { \
72  (working_set)->flags = pcmk__clear_flags_as(__func__, __LINE__, \
73  LOG_TRACE, "Working set", crm_system_name, \
74  (working_set)->flags, (flags_to_clear), #flags_to_clear); \
75  } while (0)
76 
77 #define pe__set_resource_flags(resource, flags_to_set) do { \
78  (resource)->flags = pcmk__set_flags_as(__func__, __LINE__, \
79  LOG_TRACE, "Resource", (resource)->id, (resource)->flags, \
80  (flags_to_set), #flags_to_set); \
81  } while (0)
82 
83 #define pe__clear_resource_flags(resource, flags_to_clear) do { \
84  (resource)->flags = pcmk__clear_flags_as(__func__, __LINE__, \
85  LOG_TRACE, "Resource", (resource)->id, (resource)->flags, \
86  (flags_to_clear), #flags_to_clear); \
87  } while (0)
88 
89 #define pe__set_action_flags(action, flags_to_set) do { \
90  (action)->flags = pcmk__set_flags_as(__func__, __LINE__, \
91  LOG_TRACE, \
92  "Action", (action)->uuid, \
93  (action)->flags, \
94  (flags_to_set), \
95  #flags_to_set); \
96  } while (0)
97 
98 #define pe__clear_action_flags(action, flags_to_clear) do { \
99  (action)->flags = pcmk__clear_flags_as(__func__, __LINE__, \
100  LOG_TRACE, \
101  "Action", (action)->uuid, \
102  (action)->flags, \
103  (flags_to_clear), \
104  #flags_to_clear); \
105  } while (0)
106 
107 #define pe__set_raw_action_flags(action_flags, action_name, flags_to_set) do { \
108  action_flags = pcmk__set_flags_as(__func__, __LINE__, \
109  LOG_TRACE, "Action", action_name, \
110  (action_flags), \
111  (flags_to_set), #flags_to_set); \
112  } while (0)
113 
114 #define pe__clear_raw_action_flags(action_flags, action_name, flags_to_clear) do { \
115  action_flags = pcmk__clear_flags_as(__func__, __LINE__, \
116  LOG_TRACE, \
117  "Action", action_name, \
118  (action_flags), \
119  (flags_to_clear), \
120  #flags_to_clear); \
121  } while (0)
122 
123 #define pe__set_action_flags_as(function, line, action, flags_to_set) do { \
124  (action)->flags = pcmk__set_flags_as((function), (line), \
125  LOG_TRACE, \
126  "Action", (action)->uuid, \
127  (action)->flags, \
128  (flags_to_set), \
129  #flags_to_set); \
130  } while (0)
131 
132 #define pe__clear_action_flags_as(function, line, action, flags_to_clear) do { \
133  (action)->flags = pcmk__clear_flags_as((function), (line), \
134  LOG_TRACE, \
135  "Action", (action)->uuid, \
136  (action)->flags, \
137  (flags_to_clear), \
138  #flags_to_clear); \
139  } while (0)
140 
141 #define pe__set_order_flags(order_flags, flags_to_set) do { \
142  order_flags = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE, \
143  "Ordering", "constraint", \
144  order_flags, (flags_to_set), \
145  #flags_to_set); \
146  } while (0)
147 
148 #define pe__clear_order_flags(order_flags, flags_to_clear) do { \
149  order_flags = pcmk__clear_flags_as(__func__, __LINE__, LOG_TRACE, \
150  "Ordering", "constraint", \
151  order_flags, (flags_to_clear), \
152  #flags_to_clear); \
153  } while (0)
154 
155 // Some warnings we don't want to print every transition
156 
158  pe_wo_blind = (1 << 0),
159  pe_wo_restart_type = (1 << 1),
160  pe_wo_role_after = (1 << 2),
161  pe_wo_poweroff = (1 << 3),
162  pe_wo_require_all = (1 << 4),
163  pe_wo_order_score = (1 << 5),
165  pe_wo_remove_after = (1 << 7),
166  pe_wo_ping_node = (1 << 8),
167  pe_wo_order_inst = (1 << 9),
168  pe_wo_coloc_inst = (1 << 10),
169  pe_wo_group_order = (1 << 11),
170  pe_wo_group_coloc = (1 << 12),
171  pe_wo_upstart = (1 << 13),
172  pe_wo_nagios = (1 << 14),
173 };
174 
175 extern uint32_t pe_wo;
176 
177 #define pe_warn_once(pe_wo_bit, fmt...) do { \
178  if (!pcmk_is_set(pe_wo, pe_wo_bit)) { \
179  if (pe_wo_bit == pe_wo_blind) { \
180  crm_warn(fmt); \
181  } else { \
182  pe_warn(fmt); \
183  } \
184  pe_wo = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE, \
185  "Warn-once", "logging", pe_wo, \
186  (pe_wo_bit), #pe_wo_bit); \
187  } \
188  } while (0);
189 
190 
192  char *id; // Constraint XML ID
193  pe_resource_t *rsc_lh; // Resource being located
194  enum rsc_role_e role_filter; // Role to locate
195  enum pe_discover_e discover_mode; // Resource discovery
196  GList *node_list_rh; // List of pe_node_t*
198 
199 typedef struct pe__order_constraint_s {
200  int id;
201  uint32_t flags; // Group of enum pe_ordering flags
202 
203  void *lh_opaque;
207 
208  void *rh_opaque;
213 
215  bool include_bundle);
216 
217 int pe__clone_max(const pe_resource_t *clone);
218 int pe__clone_node_max(const pe_resource_t *clone);
219 int pe__clone_promoted_max(const pe_resource_t *clone);
224  pe_action_t *start, pe_action_t *started,
225  pe_action_t *stop, pe_action_t *stopped);
226 
227 
228 pe_action_t *pe__new_rsc_pseudo_action(pe_resource_t *rsc, const char *task,
229  bool optional, bool runnable);
230 
231 void pe__create_promotable_pseudo_ops(pe_resource_t *clone, bool any_promoting,
232  bool any_demoting);
233 
234 bool pe_can_fence(const pe_working_set_t *data_set, const pe_node_t *node);
235 
236 void add_hash_param(GHashTable * hash, const char *name, const char *value);
237 
238 char *native_parameter(pe_resource_t * rsc, pe_node_t * node, gboolean create, const char *name,
240 pe_node_t *native_location(const pe_resource_t *rsc, GList **list, int current);
241 
242 void pe_metadata(pcmk__output_t *out);
243 void verify_pe_options(GHashTable * options);
244 
245 void native_add_running(pe_resource_t * rsc, pe_node_t * node, pe_working_set_t * data_set, gboolean failed);
246 
251 
252 pe_resource_t *native_find_rsc(pe_resource_t *rsc, const char *id, const pe_node_t *node,
253  int flags);
254 
255 gboolean native_active(pe_resource_t * rsc, gboolean all);
256 gboolean group_active(pe_resource_t * rsc, gboolean all);
257 gboolean clone_active(pe_resource_t * rsc, gboolean all);
258 gboolean pe__bundle_active(pe_resource_t *rsc, gboolean all);
259 
261 void native_print(pe_resource_t *rsc, const char *pre_text, long options,
262  void *print_data);
263 
265 void group_print(pe_resource_t *rsc, const char *pre_text, long options,
266  void *print_data);
267 
269 void clone_print(pe_resource_t *rsc, const char *pre_text, long options,
270  void *print_data);
271 
273 void pe__print_bundle(pe_resource_t *rsc, const char *pre_text, long options,
274  void *print_data);
275 
276 gchar *pcmk__native_output_string(const pe_resource_t *rsc, const char *name,
277  const pe_node_t *node, uint32_t show_opts,
278  const char *target_role, bool show_nodes);
279 
280 int pe__name_and_nvpairs_xml(pcmk__output_t *out, bool is_list, const char *tag_name
281  , size_t pairs_count, ...);
282 char *pe__node_display_name(pe_node_t *node, bool print_detail);
283 
284 
285 // Clone notifications (pe_notif.c)
287  pe_resource_t *rsc,
288  pe_action_t *stonith_op);
289 
290 
291 static inline const char *
292 pe__rsc_bool_str(const pe_resource_t *rsc, uint64_t rsc_flag)
293 {
294  return pcmk__btoa(pcmk_is_set(rsc->flags, rsc_flag));
295 }
296 
297 int pe__clone_xml(pcmk__output_t *out, va_list args);
298 int pe__clone_default(pcmk__output_t *out, va_list args);
299 int pe__group_xml(pcmk__output_t *out, va_list args);
300 int pe__group_default(pcmk__output_t *out, va_list args);
301 int pe__bundle_xml(pcmk__output_t *out, va_list args);
302 int pe__bundle_html(pcmk__output_t *out, va_list args);
303 int pe__bundle_text(pcmk__output_t *out, va_list args);
304 int pe__node_html(pcmk__output_t *out, va_list args);
305 int pe__node_text(pcmk__output_t *out, va_list args);
306 int pe__node_xml(pcmk__output_t *out, va_list args);
307 int pe__resource_xml(pcmk__output_t *out, va_list args);
308 int pe__resource_html(pcmk__output_t *out, va_list args);
309 int pe__resource_text(pcmk__output_t *out, va_list args);
310 
311 void native_free(pe_resource_t * rsc);
312 void group_free(pe_resource_t * rsc);
313 void clone_free(pe_resource_t * rsc);
314 void pe__free_bundle(pe_resource_t *rsc);
315 
316 enum rsc_role_e native_resource_state(const pe_resource_t * rsc, gboolean current);
317 enum rsc_role_e group_resource_state(const pe_resource_t * rsc, gboolean current);
318 enum rsc_role_e clone_resource_state(const pe_resource_t * rsc, gboolean current);
320  gboolean current);
321 
324 
325 void common_free(pe_resource_t * rsc);
326 
327 pe_node_t *pe__copy_node(const pe_node_t *this_node);
329 
330 /* Failure handling utilities (from failcounts.c) */
331 
332 // bit flags for fail count handling options
334  pe_fc_default = (1 << 0),
335  pe_fc_effective = (1 << 1), // don't count expired failures
336  pe_fc_fillers = (1 << 2), // if container, include filler failures in count
337 };
338 
339 int pe_get_failcount(const pe_node_t *node, pe_resource_t *rsc,
340  time_t *last_failure, uint32_t flags,
341  const xmlNode *xml_op);
342 
344  const char *reason,
346 
347 /* Functions for finding/counting a resource's active nodes */
348 
349 bool pe__count_active_node(const pe_resource_t *rsc, pe_node_t *node,
350  pe_node_t **active, unsigned int *count_all,
351  unsigned int *count_clean);
352 
354  unsigned int *count);
355 
356 static inline pe_node_t *
357 pe__current_node(const pe_resource_t *rsc)
358 {
359  return (rsc == NULL)? NULL : rsc->fns->active_node(rsc, NULL, NULL);
360 }
361 
362 
363 /* Binary like operators for lists of nodes */
364 extern void node_list_exclude(GHashTable * list, GList *list2, gboolean merge_scores);
365 
366 GHashTable *pe__node_list2table(const GList *list);
367 
368 static inline gpointer
369 pe_hash_table_lookup(GHashTable * hash, gconstpointer key)
370 {
371  if (hash) {
372  return g_hash_table_lookup(hash, key);
373  }
374  return NULL;
375 }
376 
377 extern pe_action_t *get_pseudo_op(const char *name, pe_working_set_t * data_set);
378 extern gboolean order_actions(pe_action_t * lh_action, pe_action_t * rh_action, enum pe_ordering order);
379 
380 void pe__show_node_weights_as(const char *file, const char *function,
381  int line, bool to_log, const pe_resource_t *rsc,
382  const char *comment, GHashTable *nodes,
384 
385 #define pe__show_node_weights(level, rsc, text, nodes, data_set) \
386  pe__show_node_weights_as(__FILE__, __func__, __LINE__, \
387  (level), (rsc), (text), (nodes), (data_set))
388 
389 xmlNode *find_rsc_op_entry(const pe_resource_t *rsc, const char *key);
390 
391 pe_action_t *custom_action(pe_resource_t *rsc, char *key, const char *task,
392  const pe_node_t *on_node, gboolean optional,
393  gboolean foo, pe_working_set_t *data_set);
394 
395 # define delete_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_DELETE, 0)
396 # define delete_action(rsc, node, optional) custom_action( \
397  rsc, delete_key(rsc), CRMD_ACTION_DELETE, node, \
398  optional, TRUE, rsc->cluster);
399 
400 # define stopped_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_STOPPED, 0)
401 # define stopped_action(rsc, node, optional) custom_action( \
402  rsc, stopped_key(rsc), CRMD_ACTION_STOPPED, node, \
403  optional, TRUE, rsc->cluster);
404 
405 # define stop_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_STOP, 0)
406 # define stop_action(rsc, node, optional) custom_action( \
407  rsc, stop_key(rsc), CRMD_ACTION_STOP, node, \
408  optional, TRUE, rsc->cluster);
409 
410 # define reload_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_RELOAD_AGENT, 0)
411 # define start_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_START, 0)
412 # define start_action(rsc, node, optional) custom_action( \
413  rsc, start_key(rsc), CRMD_ACTION_START, node, \
414  optional, TRUE, rsc->cluster)
415 
416 # define started_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_STARTED, 0)
417 # define started_action(rsc, node, optional) custom_action( \
418  rsc, started_key(rsc), CRMD_ACTION_STARTED, node, \
419  optional, TRUE, rsc->cluster)
420 
421 # define promote_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_PROMOTE, 0)
422 # define promote_action(rsc, node, optional) custom_action( \
423  rsc, promote_key(rsc), CRMD_ACTION_PROMOTE, node, \
424  optional, TRUE, rsc->cluster)
425 
426 # define promoted_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_PROMOTED, 0)
427 # define promoted_action(rsc, node, optional) custom_action( \
428  rsc, promoted_key(rsc), CRMD_ACTION_PROMOTED, node, \
429  optional, TRUE, rsc->cluster)
430 
431 # define demote_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_DEMOTE, 0)
432 # define demote_action(rsc, node, optional) custom_action( \
433  rsc, demote_key(rsc), CRMD_ACTION_DEMOTE, node, \
434  optional, TRUE, rsc->cluster)
435 
436 # define demoted_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_DEMOTED, 0)
437 # define demoted_action(rsc, node, optional) custom_action( \
438  rsc, demoted_key(rsc), CRMD_ACTION_DEMOTED, node, \
439  optional, TRUE, rsc->cluster)
440 
441 extern int pe_get_configured_timeout(pe_resource_t *rsc, const char *action,
443 
444 pe_action_t *find_first_action(const GList *input, const char *uuid,
445  const char *task, const pe_node_t *on_node);
446 
447 enum action_tasks get_complex_task(const pe_resource_t *rsc, const char *name);
448 
449 extern GList *find_actions(GList *input, const char *key, const pe_node_t *on_node);
450 GList *find_actions_exact(GList *input, const char *key,
451  const pe_node_t *on_node);
452 GList *pe__resource_actions(const pe_resource_t *rsc, const pe_node_t *node,
453  const char *task, bool require_node);
454 
455 extern void pe_free_action(pe_action_t * action);
456 
457 void resource_location(pe_resource_t *rsc, const pe_node_t *node, int score,
458  const char *tag, pe_working_set_t *data_set);
459 
460 extern int pe__is_newer_op(const xmlNode *xml_a, const xmlNode *xml_b,
461  bool same_node_default);
462 extern gint sort_op_by_callid(gconstpointer a, gconstpointer b);
463 gboolean get_target_role(const pe_resource_t *rsc, enum rsc_role_e *role);
464 void pe__set_next_role(pe_resource_t *rsc, enum rsc_role_e role,
465  const char *why);
466 
468  const char *sub_id);
469 
470 extern void destroy_ticket(gpointer data);
471 extern pe_ticket_t *ticket_new(const char *ticket_id, pe_working_set_t * data_set);
472 
473 // Resources for manipulating resource names
474 const char *pe_base_name_end(const char *id);
475 char *clone_strip(const char *last_rsc_id);
476 char *clone_zero(const char *last_rsc_id);
477 
478 static inline bool
479 pe_base_name_eq(const pe_resource_t *rsc, const char *id)
480 {
481  if (id && rsc && rsc->id) {
482  // Number of characters in rsc->id before any clone suffix
483  size_t base_len = pe_base_name_end(rsc->id) - rsc->id + 1;
484 
485  return (strlen(id) == base_len) && !strncmp(id, rsc->id, base_len);
486  }
487  return false;
488 }
489 
490 int pe__target_rc_from_xml(const xmlNode *xml_op);
491 
492 gint pe__cmp_node_name(gconstpointer a, gconstpointer b);
493 bool is_set_recursive(const pe_resource_t *rsc, long long flag, bool any);
494 
505 };
506 
507 typedef struct op_digest_cache_s {
509  xmlNode *params_all;
510  xmlNode *params_secure;
511  xmlNode *params_restart;
516 
518  guint *interval_ms,
519  const pe_node_t *node,
520  const xmlNode *xml_op,
521  GHashTable *overrides,
522  bool calc_secure,
524 
525 void pe__free_digests(gpointer ptr);
526 
528  const xmlNode *xml_op,
529  pe_node_t *node,
531 
532 pe_action_t *pe_fence_op(pe_node_t *node, const char *op, bool optional,
533  const char *reason, bool priority_delay,
535 void trigger_unfencing(pe_resource_t *rsc, pe_node_t *node,
536  const char *reason, pe_action_t *dependency,
538 
539 char *pe__action2reason(const pe_action_t *action, enum pe_action_flags flag);
540 void pe_action_set_reason(pe_action_t *action, const char *reason, bool overwrite);
541 void pe__add_action_expected_result(pe_action_t *action, int expected_result);
542 
546 
547 gboolean add_tag_ref(GHashTable * tags, const char * tag_name, const char * obj_ref);
548 
550 void print_rscs_brief(GList *rsc_list, const char * pre_text, long options,
551  void * print_data, gboolean print_all);
552 int pe__rscs_brief_output(pcmk__output_t *out, GList *rsc_list, unsigned int options);
553 void pe_fence_node(pe_working_set_t * data_set, pe_node_t * node, const char *reason, bool priority_delay);
554 
555 pe_node_t *pe_create_node(const char *id, const char *uname, const char *type,
556  const char *score, pe_working_set_t * data_set);
557 
559 void common_print(pe_resource_t *rsc, const char *pre_text, const char *name,
560  const pe_node_t *node, long options, void *print_data);
562  const char *name, const pe_node_t *node,
563  unsigned int options);
565  const char *name, const pe_node_t *node,
566  unsigned int options);
567 
568 GList *pe__bundle_containers(const pe_resource_t *bundle);
569 
570 int pe__bundle_max(const pe_resource_t *rsc);
571 int pe__bundle_max_per_node(const pe_resource_t *rsc);
572 
574  const pe_node_t *node);
578  xmlNode *xml, const char *field);
579 const char *pe_node_attribute_calculated(const pe_node_t *node,
580  const char *name,
581  const pe_resource_t *rsc);
582 const char *pe_node_attribute_raw(const pe_node_t *node, const char *name);
583 bool pe__is_universal_clone(const pe_resource_t *rsc,
584  const pe_working_set_t *data_set);
585 void pe__add_param_check(const xmlNode *rsc_op, pe_resource_t *rsc,
586  pe_node_t *node, enum pe_check_parameters,
589  void (*cb)(pe_resource_t*, pe_node_t*,
590  const xmlNode*,
591  enum pe_check_parameters));
593 
594 bool pe__shutdown_requested(const pe_node_t *node);
595 void pe__update_recheck_time(time_t recheck, pe_working_set_t *data_set);
596 
604 
605 void pe__unpack_dataset_nvpairs(const xmlNode *xml_obj, const char *set_name,
606  const pe_rule_eval_data_t *rule_data,
607  GHashTable *hash, const char *always_first,
608  gboolean overwrite, pe_working_set_t *data_set);
609 
610 bool pe__resource_is_disabled(const pe_resource_t *rsc);
612  const pe_node_t *node,
614 
615 GList *pe__rscs_with_tag(pe_working_set_t *data_set, const char *tag_name);
616 GList *pe__unames_with_tag(pe_working_set_t *data_set, const char *tag_name);
617 bool pe__rsc_has_tag(pe_working_set_t *data_set, const char *rsc, const char *tag);
618 bool pe__uname_has_tag(pe_working_set_t *data_set, const char *node, const char *tag);
619 
620 bool pe__rsc_running_on_only(const pe_resource_t *rsc, const pe_node_t *node);
621 bool pe__rsc_running_on_any(pe_resource_t *rsc, GList *node_list);
622 GList *pe__filter_rsc_list(GList *rscs, GList *filter);
623 GList * pe__build_node_name_list(pe_working_set_t *data_set, const char *s);
624 GList * pe__build_rsc_list(pe_working_set_t *data_set, const char *s);
625 
626 bool pcmk__rsc_filtered_by_node(pe_resource_t *rsc, GList *only_node);
627 
628 gboolean pe__bundle_is_filtered(const pe_resource_t *rsc, GList *only_rsc,
629  gboolean check_parent);
630 gboolean pe__clone_is_filtered(const pe_resource_t *rsc, GList *only_rsc,
631  gboolean check_parent);
632 gboolean pe__group_is_filtered(const pe_resource_t *rsc, GList *only_rsc,
633  gboolean check_parent);
634 gboolean pe__native_is_filtered(const pe_resource_t *rsc, GList *only_rsc,
635  gboolean check_parent);
636 
637 xmlNode *pe__failed_probe_for_rsc(const pe_resource_t *rsc, const char *name);
638 
639 const char *pe__clone_child_id(const pe_resource_t *rsc);
640 
641 int pe__sum_node_health_scores(const pe_node_t *node, int base_health);
642 int pe__node_health(pe_node_t *node);
643 
644 static inline enum pcmk__health_strategy
645 pe__health_strategy(pe_working_set_t *data_set)
646 {
649 }
650 
651 static inline int
652 pe__health_score(const char *option, pe_working_set_t *data_set)
653 {
654  return char2score(pe_pref(data_set->config_hash, option));
655 }
656 
667 static inline const char *
668 pe__node_name(const pe_node_t *node)
669 {
670  if (node == NULL) {
671  return "unspecified node";
672 
673  } else if (node->details->uname != NULL) {
674  return node->details->uname;
675 
676  } else if (node->details->id != NULL) {
677  return node->details->id;
678 
679  } else {
680  return "unidentified node";
681  }
682 }
683 
693 static inline bool
694 pe__same_node(const pe_node_t *node1, const pe_node_t *node2)
695 {
696  return (node1 != NULL) && (node2 != NULL)
697  && (node1->details == node2->details);
698 }
699 
708 static inline const char *
709 pe__xe_history_key(const xmlNode *xml)
710 {
711  if (xml == NULL) {
712  return NULL;
713  } else {
714  /* @COMPAT Pacemaker <= 1.1.5 did not add the key, and used the ID
715  * instead. Checking for that allows us to process old saved CIBs,
716  * including some regression tests.
717  */
718  const char *key = crm_element_value(xml, XML_LRM_ATTR_TASK_KEY);
719 
720  return pcmk__str_empty(key)? ID(xml) : key;
721  }
722 }
723 
724 #endif
int pe__node_health(pe_node_t *node)
Definition: pe_health.c:114
gboolean get_target_role(const pe_resource_t *rsc, enum rsc_role_e *role)
Definition: utils.c:449
void verify_pe_options(GHashTable *options)
Definition: common.c:297
xmlNode * find_rsc_op_entry(const pe_resource_t *rsc, const char *key)
Definition: pe_actions.c:145
pe_action_t * lh_action
Definition: internal.h:205
enum rsc_role_e role_filter
Definition: internal.h:194
void pe__clear_resource_flags_recursive(pe_resource_t *rsc, uint64_t flags)
Definition: utils.c:589
const char * pe_node_attribute_calculated(const pe_node_t *node, const char *name, const pe_resource_t *rsc)
Definition: common.c:518
void group_free(pe_resource_t *rsc)
Definition: group.c:453
char data[0]
Definition: cpg.c:55
gboolean pe__bundle_is_filtered(const pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
Definition: bundle.c:1872
void group_print(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
Definition: group.c:289
pe_check_parameters
Definition: pe_types.h:218
const char * name
Definition: cib.c:24
GList * pe__build_rsc_list(pe_working_set_t *data_set, const char *s)
Definition: utils.c:863
void pe__foreach_param_check(pe_working_set_t *data_set, void(*cb)(pe_resource_t *, pe_node_t *, const xmlNode *, enum pe_check_parameters))
Definition: remote.c:249
void pe__free_clone_notification_data(pe_resource_t *clone)
Definition: clone.c:1418
void pe__update_recheck_time(time_t recheck, pe_working_set_t *data_set)
Definition: utils.c:715
gint pe__cmp_node_name(gconstpointer a, gconstpointer b)
Definition: utils.c:185
void pe__free_bundle(pe_resource_t *rsc)
Definition: bundle.c:1787
int pe__clone_promoted_max(const pe_resource_t *clone)
Definition: clone.c:96
GList * find_actions(GList *input, const char *key, const pe_node_t *on_node)
Definition: pe_actions.c:1327
int pe__target_rc_from_xml(const xmlNode *xml_op)
Definition: unpack.c:4011
enum rsc_role_e pe__bundle_resource_state(const pe_resource_t *rsc, gboolean current)
Definition: bundle.c:1821
struct op_digest_cache_s op_digest_cache_t
void pe__count_common(pe_resource_t *rsc)
Definition: complex.c:1138
gboolean group_active(pe_resource_t *rsc, gboolean all)
Definition: group.c:235
int pe__is_newer_op(const xmlNode *xml_a, const xmlNode *xml_b, bool same_node_default)
Definition: pe_actions.c:1497
int pe__group_default(pcmk__output_t *out, va_list args)
Definition: group.c:398
pe_action_t * find_first_action(const GList *input, const char *uuid, const char *task, const pe_node_t *on_node)
Definition: pe_actions.c:1298
int char2score(const char *score)
Get the integer value of a score string.
Definition: scores.c:36
pe_node_t * native_location(const pe_resource_t *rsc, GList **list, int current)
Definition: native.c:1093
int pe__set_clone_flag(pe_resource_t *clone, enum pe__clone_flags flag)
Definition: clone.c:1308
resource_object_functions_t * fns
Definition: pe_types.h:358
pe_node_t * pe__copy_node(const pe_node_t *this_node)
Definition: utils.c:89
int pe__clone_default(pcmk__output_t *out, va_list args)
Definition: clone.c:884
void print_rscs_brief(GList *rsc_list, const char *pre_text, long options, void *print_data, gboolean print_all)
Definition: native.c:1229
void node_list_exclude(GHashTable *list, GList *list2, gboolean merge_scores)
Definition: utils.c:108
gint sort_op_by_callid(gconstpointer a, gconstpointer b)
Definition: pe_actions.c:1630
bool pe__resource_is_disabled(const pe_resource_t *rsc)
Definition: utils.c:755
gboolean pe__native_is_filtered(const pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
Definition: native.c:1401
const pe_resource_t * pe__const_top_resource(const pe_resource_t *rsc, bool include_bundle)
Definition: complex.c:947
time_t get_effective_time(pe_working_set_t *data_set)
Definition: utils.c:434
const char * pe_pref(GHashTable *options, const char *name)
Definition: common.c:303
pe_action_t * rh_action
Definition: internal.h:210
xmlNode * params_restart
Definition: internal.h:511
pe_action_t * pe__new_rsc_pseudo_action(pe_resource_t *rsc, const char *task, bool optional, bool runnable)
Definition: pe_actions.c:1650
enum crm_ais_msg_types type
Definition: cpg.c:48
pe_resource_t * rsc_lh
Definition: internal.h:193
bool pe__rsc_running_on_any(pe_resource_t *rsc, GList *node_list)
Definition: utils.c:791
void resource_location(pe_resource_t *rsc, const pe_node_t *node, int score, const char *tag, pe_working_set_t *data_set)
Definition: utils.c:398
enum pcmk__health_strategy pcmk__parse_health_strategy(const char *value)
Definition: health.c:41
int pe__resource_text(pcmk__output_t *out, va_list args)
Definition: native.c:1040
const char * pe__resource_description(const pe_resource_t *rsc, uint32_t show_opts)
Definition: pe_output.c:19
void pe__print_bundle(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
Definition: bundle.c:1685
pe_discover_e
Definition: pe_types.h:499
bool pe__bundle_needs_remote_name(pe_resource_t *rsc)
Definition: bundle.c:725
int pe__clone_max(const pe_resource_t *clone)
Definition: clone.c:62
bool pe__shutdown_requested(const pe_node_t *node)
Definition: utils.c:700
gboolean pe__unpack_bundle(pe_resource_t *rsc, pe_working_set_t *data_set)
Definition: bundle.c:789
char * pe__node_display_name(pe_node_t *node, bool print_detail)
Definition: pe_output.c:515
int pe__bundle_html(pcmk__output_t *out, va_list args)
Definition: bundle.c:1410
const char * action
Definition: pcmk_fence.c:30
bool pe__uname_has_tag(pe_working_set_t *data_set, const char *node, const char *tag)
Definition: tags.c:99
void native_free(pe_resource_t *rsc)
Definition: native.c:1063
GList * pe__rscs_with_tag(pe_working_set_t *data_set, const char *tag_name)
Definition: tags.c:20
void trigger_unfencing(pe_resource_t *rsc, pe_node_t *node, const char *reason, pe_action_t *dependency, pe_working_set_t *data_set)
Definition: utils.c:616
void clone_free(pe_resource_t *rsc)
Definition: clone.c:1169
pe_node_t *(* active_node)(const pe_resource_t *rsc, unsigned int *count_all, unsigned int *count_clean)
Definition: pe_types.h:73
GList * pe__filter_rsc_list(GList *rscs, GList *filter)
Definition: utils.c:811
#define XML_LRM_ATTR_TASK_KEY
Definition: msg_xml.h:316
enum rsc_role_e group_resource_state(const pe_resource_t *rsc, gboolean current)
Definition: group.c:474
GList * pe__bundle_containers(const pe_resource_t *bundle)
Definition: bundle.c:1916
void pe__set_resource_flags_recursive(pe_resource_t *rsc, uint64_t flags)
Definition: utils.c:607
pe_resource_t * pe__find_bundle_replica(const pe_resource_t *bundle, const pe_node_t *node)
Definition: bundle.c:1175
enum rsc_role_e clone_resource_state(const pe_resource_t *rsc, gboolean current)
Definition: clone.c:1203
enum pe_discover_e discover_mode
Definition: internal.h:195
Formatted output for pacemaker tools.
void pe_action_set_reason(pe_action_t *action, const char *reason, bool overwrite)
Definition: pe_actions.c:1449
pe_action_flags
Definition: pe_types.h:316
bool pe_can_fence(const pe_working_set_t *data_set, const pe_node_t *node)
Definition: utils.c:36
int pe__rscs_brief_output(pcmk__output_t *out, GList *rsc_list, unsigned int options)
struct pe__order_constraint_s pe__ordering_t
int pe__bundle_text(pcmk__output_t *out, va_list args)
Definition: bundle.c:1543
pe_action_t * get_pseudo_op(const char *name, pe_working_set_t *data_set)
Definition: pe_actions.c:979
int pe__clone_node_max(const pe_resource_t *clone)
Definition: clone.c:79
gboolean clone_active(pe_resource_t *rsc, gboolean all)
Definition: clone.c:442
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
Definition: nvpair.c:496
pe__clone_flags
Definition: internal.h:24
const char * pe_node_attribute_raw(const pe_node_t *node, const char *name)
Definition: common.c:558
char * digest_all_calc
Definition: internal.h:512
char * clone_strip(const char *last_rsc_id)
Definition: unpack.c:1658
int pe__name_and_nvpairs_xml(pcmk__output_t *out, bool is_list, const char *tag_name, size_t pairs_count,...)
Definition: pe_output.c:568
void pe__add_action_expected_result(pe_action_t *action, int expected_result)
Definition: pe_actions.c:1676
bool pe__rsc_has_tag(pe_working_set_t *data_set, const char *rsc, const char *tag)
Definition: tags.c:84
pe_ticket_t * ticket_new(const char *ticket_id, pe_working_set_t *data_set)
Definition: utils.c:547
char * native_parameter(pe_resource_t *rsc, pe_node_t *node, gboolean create, const char *name, pe_working_set_t *data_set)
Definition: native.c:319
enum rsc_digest_cmp_val rc
Definition: internal.h:508
void pe_fence_node(pe_working_set_t *data_set, pe_node_t *node, const char *reason, bool priority_delay)
Schedule a fence action for a node.
Definition: unpack.c:113
int pe__clone_xml(pcmk__output_t *out, va_list args)
Definition: clone.c:814
char * digest_secure_calc
Definition: internal.h:513
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
Definition: util.h:121
pe_action_t * pe__clear_failcount(pe_resource_t *rsc, const pe_node_t *node, const char *reason, pe_working_set_t *data_set)
Schedule a controller operation to clear a fail count.
Definition: failcounts.c:388
int pe__clone_promoted_node_max(const pe_resource_t *clone)
Definition: clone.c:113
struct pe_node_shared_s * details
Definition: pe_types.h:268
void pe_metadata(pcmk__output_t *out)
Definition: common.c:284
void pe__create_promotable_pseudo_ops(pe_resource_t *clone, bool any_promoting, bool any_demoting)
Definition: clone.c:1331
void common_free(pe_resource_t *rsc)
Definition: complex.c:964
gboolean order_actions(pe_action_t *lh_action, pe_action_t *rh_action, enum pe_ordering order)
Definition: utils.c:488
unsigned long long flags
Definition: pe_types.h:373
const char * uname
Definition: pe_types.h:232
pe_working_set_t * data_set
GHashTable * config_hash
Definition: pe_types.h:174
gboolean add_tag_ref(GHashTable *tags, const char *tag_name, const char *obj_ref)
Definition: utils.c:651
bool pe__rsc_running_on_only(const pe_resource_t *rsc, const pe_node_t *node)
Definition: utils.c:784
pe_resource_t * lh_rsc
Definition: internal.h:204
const char * pe__clone_child_id(const pe_resource_t *rsc)
Definition: clone.c:1273
gchar * pcmk__native_output_string(const pe_resource_t *rsc, const char *name, const pe_node_t *node, uint32_t show_opts, const char *target_role, bool show_nodes)
Definition: native.c:545
enum rsc_role_e native_resource_state(const pe_resource_t *rsc, gboolean current)
Definition: native.c:1070
void clone_print(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
Definition: clone.c:590
GHashTable * pe__node_list2table(const GList *list)
Definition: utils.c:156
void pe__add_param_check(const xmlNode *rsc_op, pe_resource_t *rsc, pe_node_t *node, enum pe_check_parameters, pe_working_set_t *data_set)
Definition: remote.c:222
void pe__create_clone_notif_pseudo_ops(pe_resource_t *clone, pe_action_t *start, pe_action_t *started, pe_action_t *stop, pe_action_t *stopped)
Definition: clone.c:1448
bool pe__is_universal_clone(const pe_resource_t *rsc, const pe_working_set_t *data_set)
Definition: clone.c:1229
void native_print(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
Definition: native.c:911
pe_node_t node1
bool is_set_recursive(const pe_resource_t *rsc, long long flag, bool any)
Definition: clone.c:555
pe_resource_t * find_clone_instance(const pe_resource_t *rsc, const char *sub_id)
Definition: clone.c:226
void pe__free_digests(gpointer ptr)
Definition: pe_digest.c:34
void pe__register_messages(pcmk__output_t *out)
Definition: pe_output.c:3106
int pe_get_configured_timeout(pe_resource_t *rsc, const char *action, pe_working_set_t *data_set)
Definition: pe_actions.c:1218
#define PCMK__OPT_NODE_HEALTH_STRATEGY
pe_node_t node2
xmlNode * params_all
Definition: internal.h:509
pe_warn_once_e
Definition: internal.h:157
void pe__free_param_checks(pe_working_set_t *data_set)
Definition: remote.c:264
const char * id
Definition: pe_types.h:231
const char * pe__add_bundle_remote_name(pe_resource_t *rsc, pe_working_set_t *data_set, xmlNode *xml, const char *field)
Definition: bundle.c:743
gboolean native_active(pe_resource_t *rsc, gboolean all)
Definition: native.c:341
int pe__resource_xml(pcmk__output_t *out, va_list args)
Definition: native.c:934
bool pe__count_active_node(const pe_resource_t *rsc, pe_node_t *node, pe_node_t **active, unsigned int *count_all, unsigned int *count_clean)
Definition: complex.c:1040
GList * pe__build_node_name_list(pe_working_set_t *data_set, const char *s)
Definition: utils.c:831
pe__group_flags
Definition: internal.h:39
uint32_t pe_wo
Definition: unpack.c:85
pe_resource_t * pe__last_group_member(const pe_resource_t *group)
Definition: group.c:37
int pe__bundle_xml(pcmk__output_t *out, va_list args)
Definition: bundle.c:1259
void pe__show_node_weights_as(const char *file, const char *function, int line, bool to_log, const pe_resource_t *rsc, const char *comment, GHashTable *nodes, pe_working_set_t *data_set)
Definition: utils.c:289
char * pe__action2reason(const pe_action_t *action, enum pe_action_flags flag)
Definition: pe_actions.c:1426
Cluster status and scheduling.
pe_action_t * pe__clear_resource_history(pe_resource_t *rsc, const pe_node_t *node, pe_working_set_t *data_set)
Definition: pe_actions.c:1476
bool pcmk__rsc_filtered_by_node(pe_resource_t *rsc, GList *only_node)
Definition: utils.c:805
pe_resource_t * native_find_rsc(pe_resource_t *rsc, const char *id, const pe_node_t *node, int flags)
Definition: native.c:265
int pe__node_text(pcmk__output_t *out, va_list args)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
Definition: common.c:500
gboolean clone_unpack(pe_resource_t *rsc, pe_working_set_t *data_set)
Definition: clone.c:295
bool pe__clone_is_ordered(const pe_resource_t *clone)
Definition: clone.c:1289
xmlNode * input
void pe__set_next_role(pe_resource_t *rsc, enum rsc_role_e role, const char *why)
Definition: complex.c:1166
char * clone_zero(const char *last_rsc_id)
Definition: unpack.c:1680
gboolean pe__clone_is_filtered(const pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
Definition: clone.c:1243
int pe__node_xml(pcmk__output_t *out, va_list args)
int pe__group_xml(pcmk__output_t *out, va_list args)
Definition: group.c:340
This structure contains everything that makes up a single output formatter.
int pe__bundle_max(const pe_resource_t *rsc)
Definition: bundle.c:35
xmlNode * params_secure
Definition: internal.h:510
void pe__clear_resource_flags_on_all(pe_working_set_t *data_set, uint64_t flag)
Definition: utils.c:598
void native_add_running(pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set, gboolean failed)
Definition: native.c:89
int pe__bundle_max_per_node(const pe_resource_t *rsc)
Definition: bundle.c:52
pcmk__health_strategy
char uname[MAX_NAME]
Definition: cpg.c:50
int pe__resource_html(pcmk__output_t *out, va_list args)
Definition: native.c:1016
gboolean pe__group_is_filtered(const pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
Definition: group.c:493
rsc_role_e
Possible roles that a resource can be in.
Definition: common.h:92
pe_node_t * pe_create_node(const char *id, const char *uname, const char *type, const char *score, pe_working_set_t *data_set)
Definition: unpack.c:399
void destroy_ticket(gpointer data)
Definition: utils.c:535
pe_resource_t * rh_rsc
Definition: internal.h:209
int pe__node_html(pcmk__output_t *out, va_list args)
int pe__common_output_text(pcmk__output_t *out, const pe_resource_t *rsc, const char *name, const pe_node_t *node, unsigned int options)
void pe__create_clone_notifications(pe_resource_t *clone)
Definition: clone.c:1399
enum action_tasks get_complex_task(const pe_resource_t *rsc, const char *name)
Definition: pe_actions.c:1265
void pe__unpack_dataset_nvpairs(const xmlNode *xml_obj, const char *set_name, const pe_rule_eval_data_t *rule_data, GHashTable *hash, const char *always_first, gboolean overwrite, pe_working_set_t *data_set)
Definition: utils.c:737
GList * find_actions_exact(GList *input, const char *key, const pe_node_t *on_node)
Definition: pe_actions.c:1361
op_digest_cache_t * pe__calculate_digests(pe_resource_t *rsc, const char *task, guint *interval_ms, const pe_node_t *node, const xmlNode *xml_op, GHashTable *overrides, bool calc_secure, pe_working_set_t *data_set)
Definition: pe_digest.c:298
pe_node_t * pe__find_active_requires(const pe_resource_t *rsc, unsigned int *count)
Definition: complex.c:1121
#define ID(x)
Definition: msg_xml.h:480
bool pe__group_flag_is_set(const pe_resource_t *group, uint32_t flags)
Definition: group.c:57
GList * pe__resource_actions(const pe_resource_t *rsc, const pe_node_t *node, const char *task, bool require_node)
Find all actions of given type for a resource.
Definition: pe_actions.c:1400
int pe__common_output_html(pcmk__output_t *out, const pe_resource_t *rsc, const char *name, const pe_node_t *node, unsigned int options)
pe_fc_flags_e
Definition: internal.h:333
GList * pe__unames_with_tag(pe_working_set_t *data_set, const char *tag_name)
Definition: tags.c:51
gboolean native_unpack(pe_resource_t *rsc, pe_working_set_t *data_set)
Definition: native.c:199
int pe_get_failcount(const pe_node_t *node, pe_resource_t *rsc, time_t *last_failure, uint32_t flags, const xmlNode *xml_op)
Definition: failcounts.c:275
pe_action_t * custom_action(pe_resource_t *rsc, char *key, const char *task, const pe_node_t *on_node, gboolean optional, gboolean foo, pe_working_set_t *data_set)
Create or update an action object.
Definition: pe_actions.c:942
op_digest_cache_t * rsc_action_digest_cmp(pe_resource_t *rsc, const xmlNode *xml_op, pe_node_t *node, pe_working_set_t *data_set)
Definition: pe_digest.c:381
void pe__order_notifs_after_fencing(const pe_action_t *action, pe_resource_t *rsc, pe_action_t *stonith_op)
Definition: pe_notif.c:981
const char * pe_base_name_end(const char *id)
Definition: unpack.c:1618
int pe__sum_node_health_scores(const pe_node_t *node, int base_health)
Definition: pe_health.c:96
struct pe__location_constraint_s pe__location_t
void common_print(pe_resource_t *rsc, const char *pre_text, const char *name, const pe_node_t *node, long options, void *print_data)
Definition: native.c:791
char * digest_restart_calc
Definition: internal.h:514
void pe__count_bundle(pe_resource_t *rsc)
Definition: bundle.c:1848
pe_ordering
Definition: pe_types.h:506
uint64_t flags
Definition: remote.c:215
action_tasks
Definition: common.h:61
pe_action_t * pe_fence_op(pe_node_t *node, const char *op, bool optional, const char *reason, bool priority_delay, pe_working_set_t *data_set)
Definition: pe_actions.c:1084
void pe_free_action(pe_action_t *action)
Definition: pe_actions.c:1196
rsc_digest_cmp_val
Definition: internal.h:495
xmlNode * pe__failed_probe_for_rsc(const pe_resource_t *rsc, const char *name)
Definition: utils.c:896
gboolean pe__bundle_active(pe_resource_t *rsc, gboolean all)
Definition: bundle.c:1127
char * id
Definition: pe_types.h:347
gboolean group_unpack(pe_resource_t *rsc, pe_working_set_t *data_set)
Definition: group.c:180