pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
complex.c
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 #include <crm_internal.h>
11 
12 #include <crm/pengine/rules.h>
13 #include <crm/pengine/internal.h>
14 #include <crm/msg_xml.h>
17 
18 #include "pe_status_private.h"
19 
20 void populate_hash(xmlNode * nvpair_list, GHashTable * hash, const char **attrs, int attrs_length);
21 
22 static pcmk_node_t *active_node(const pcmk_resource_t *rsc,
23  unsigned int *count_all,
24  unsigned int *count_clean);
25 
27  {
38  active_node,
40  },
41  {
49  group_free,
52  active_node,
54  },
55  {
63  clone_free,
66  active_node,
68  },
69  {
82  }
83 };
84 
85 static enum pe_obj_types
86 get_resource_type(const char *name)
87 {
88  if (pcmk__str_eq(name, XML_CIB_TAG_RESOURCE, pcmk__str_casei)) {
90 
91  } else if (pcmk__str_eq(name, XML_CIB_TAG_GROUP, pcmk__str_casei)) {
93 
94  } else if (pcmk__str_eq(name, XML_CIB_TAG_INCARNATION, pcmk__str_casei)) {
96 
97  } else if (pcmk__str_eq(name, PCMK_XE_PROMOTABLE_LEGACY, pcmk__str_casei)) {
98  // @COMPAT deprecated since 2.0.0
100 
101  } else if (pcmk__str_eq(name, XML_CIB_TAG_CONTAINER, pcmk__str_casei)) {
103  }
104 
106 }
107 
108 static void
109 dup_attr(gpointer key, gpointer value, gpointer user_data)
110 {
111  add_hash_param(user_data, key, value);
112 }
113 
114 static void
115 expand_parents_fixed_nvpairs(pcmk_resource_t *rsc,
116  pe_rule_eval_data_t *rule_data,
117  GHashTable *meta_hash, pcmk_scheduler_t *scheduler)
118 {
119  GHashTable *parent_orig_meta = pcmk__strkey_table(free, free);
120  pcmk_resource_t *p = rsc->parent;
121 
122  if (p == NULL) {
123  return ;
124  }
125 
126  /* Search all parent resources, get the fixed value of "meta_attributes" set only in the original xml, and stack it in the hash table. */
127  /* The fixed value of the lower parent resource takes precedence and is not overwritten. */
128  while(p != NULL) {
129  /* A hash table for comparison is generated, including the id-ref. */
131  parent_orig_meta, NULL, FALSE, scheduler);
132  p = p->parent;
133  }
134 
135  /* If there is a fixed value of "meta_attributes" of the parent resource, it will be processed. */
136  if (parent_orig_meta != NULL) {
137  GHashTableIter iter;
138  char *key = NULL;
139  char *value = NULL;
140 
141  g_hash_table_iter_init(&iter, parent_orig_meta);
142  while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) {
143  /* Parameters set in the original xml of the parent resource will also try to overwrite the child resource. */
144  /* Attributes that already exist in the child lease are not updated. */
145  dup_attr(key, value, meta_hash);
146  }
147  }
148 
149  if (parent_orig_meta != NULL) {
150  g_hash_table_destroy(parent_orig_meta);
151  }
152 
153  return ;
154 
155 }
156 void
157 get_meta_attributes(GHashTable * meta_hash, pcmk_resource_t * rsc,
159 {
160  pe_rsc_eval_data_t rsc_rule_data = {
162  .provider = crm_element_value(rsc->xml, XML_AGENT_ATTR_PROVIDER),
164  };
165 
166  pe_rule_eval_data_t rule_data = {
167  .node_hash = NULL,
168  .role = pcmk_role_unknown,
169  .now = scheduler->now,
170  .match_data = NULL,
171  .rsc_data = &rsc_rule_data,
172  .op_data = NULL
173  };
174 
175  if (node) {
176  rule_data.node_hash = node->details->attrs;
177  }
178 
179  for (xmlAttrPtr a = pcmk__xe_first_attr(rsc->xml); a != NULL; a = a->next) {
180  const char *prop_name = (const char *) a->name;
181  const char *prop_value = pcmk__xml_attr_value(a);
182 
183  add_hash_param(meta_hash, prop_name, prop_value);
184  }
185 
187  meta_hash, NULL, FALSE, scheduler);
188 
189  /* Set the "meta_attributes" explicitly set in the parent resource to the hash table of the child resource. */
190  /* If it is already explicitly set as a child, it will not be overwritten. */
191  if (rsc->parent != NULL) {
192  expand_parents_fixed_nvpairs(rsc, &rule_data, meta_hash, scheduler);
193  }
194 
195  /* check the defaults */
197  &rule_data, meta_hash, NULL, FALSE, scheduler);
198 
199  /* If there is "meta_attributes" that the parent resource has not explicitly set, set a value that is not set from rsc_default either. */
200  /* The values already set up to this point will not be overwritten. */
201  if (rsc->parent) {
202  g_hash_table_foreach(rsc->parent->meta, dup_attr, meta_hash);
203  }
204 }
205 
206 void
207 get_rsc_attributes(GHashTable *meta_hash, const pcmk_resource_t *rsc,
208  const pcmk_node_t *node, pcmk_scheduler_t *scheduler)
209 {
210  pe_rule_eval_data_t rule_data = {
211  .node_hash = NULL,
212  .role = pcmk_role_unknown,
213  .now = scheduler->now,
214  .match_data = NULL,
215  .rsc_data = NULL,
216  .op_data = NULL
217  };
218 
219  if (node) {
220  rule_data.node_hash = node->details->attrs;
221  }
222 
224  meta_hash, NULL, FALSE, scheduler);
225 
226  /* set anything else based on the parent */
227  if (rsc->parent != NULL) {
228  get_rsc_attributes(meta_hash, rsc->parent, node, scheduler);
229 
230  } else {
231  /* and finally check the defaults */
233  &rule_data, meta_hash, NULL, FALSE,
234  scheduler);
235  }
236 }
237 
238 static char *
239 template_op_key(xmlNode * op)
240 {
241  const char *name = crm_element_value(op, "name");
242  const char *role = crm_element_value(op, "role");
243  char *key = NULL;
244 
245  if ((role == NULL)
248  role = PCMK__ROLE_UNKNOWN;
249  }
250 
251  key = crm_strdup_printf("%s-%s", name, role);
252  return key;
253 }
254 
255 static gboolean
256 unpack_template(xmlNode *xml_obj, xmlNode **expanded_xml,
258 {
259  xmlNode *cib_resources = NULL;
260  xmlNode *template = NULL;
261  xmlNode *new_xml = NULL;
262  xmlNode *child_xml = NULL;
263  xmlNode *rsc_ops = NULL;
264  xmlNode *template_ops = NULL;
265  const char *template_ref = NULL;
266  const char *clone = NULL;
267  const char *id = NULL;
268 
269  if (xml_obj == NULL) {
270  pe_err("No resource object for template unpacking");
271  return FALSE;
272  }
273 
274  template_ref = crm_element_value(xml_obj, XML_CIB_TAG_RSC_TEMPLATE);
275  if (template_ref == NULL) {
276  return TRUE;
277  }
278 
279  id = ID(xml_obj);
280  if (id == NULL) {
281  pe_err("'%s' object must have a id", xml_obj->name);
282  return FALSE;
283  }
284 
285  if (pcmk__str_eq(template_ref, id, pcmk__str_none)) {
286  pe_err("The resource object '%s' should not reference itself", id);
287  return FALSE;
288  }
289 
290  cib_resources = get_xpath_object("//" XML_CIB_TAG_RESOURCES,
292  if (cib_resources == NULL) {
293  pe_err("No resources configured");
294  return FALSE;
295  }
296 
297  template = pcmk__xe_match(cib_resources, XML_CIB_TAG_RSC_TEMPLATE,
298  XML_ATTR_ID, template_ref);
299  if (template == NULL) {
300  pe_err("No template named '%s'", template_ref);
301  return FALSE;
302  }
303 
304  new_xml = copy_xml(template);
305  xmlNodeSetName(new_xml, xml_obj->name);
306  crm_xml_add(new_xml, XML_ATTR_ID, id);
307 
309  if(clone) {
310  crm_xml_add(new_xml, XML_RSC_ATTR_INCARNATION, clone);
311  }
312 
313  template_ops = find_xml_node(new_xml, "operations", FALSE);
314 
315  for (child_xml = pcmk__xe_first_child(xml_obj); child_xml != NULL;
316  child_xml = pcmk__xe_next(child_xml)) {
317  xmlNode *new_child = NULL;
318 
319  new_child = add_node_copy(new_xml, child_xml);
320 
321  if (pcmk__str_eq((const char *)new_child->name, "operations", pcmk__str_none)) {
322  rsc_ops = new_child;
323  }
324  }
325 
326  if (template_ops && rsc_ops) {
327  xmlNode *op = NULL;
328  GHashTable *rsc_ops_hash = pcmk__strkey_table(free, NULL);
329 
330  for (op = pcmk__xe_first_child(rsc_ops); op != NULL;
331  op = pcmk__xe_next(op)) {
332 
333  char *key = template_op_key(op);
334 
335  g_hash_table_insert(rsc_ops_hash, key, op);
336  }
337 
338  for (op = pcmk__xe_first_child(template_ops); op != NULL;
339  op = pcmk__xe_next(op)) {
340 
341  char *key = template_op_key(op);
342 
343  if (g_hash_table_lookup(rsc_ops_hash, key) == NULL) {
344  add_node_copy(rsc_ops, op);
345  }
346 
347  free(key);
348  }
349 
350  if (rsc_ops_hash) {
351  g_hash_table_destroy(rsc_ops_hash);
352  }
353 
354  free_xml(template_ops);
355  }
356 
357  /*free_xml(*expanded_xml); */
358  *expanded_xml = new_xml;
359 
360 #if 0 /* Disable multi-level templates for now */
361  if (!unpack_template(new_xml, expanded_xml, scheduler)) {
362  free_xml(*expanded_xml);
363  *expanded_xml = NULL;
364  return FALSE;
365  }
366 #endif
367 
368  return TRUE;
369 }
370 
371 static gboolean
372 add_template_rsc(xmlNode *xml_obj, pcmk_scheduler_t *scheduler)
373 {
374  const char *template_ref = NULL;
375  const char *id = NULL;
376 
377  if (xml_obj == NULL) {
378  pe_err("No resource object for processing resource list of template");
379  return FALSE;
380  }
381 
382  template_ref = crm_element_value(xml_obj, XML_CIB_TAG_RSC_TEMPLATE);
383  if (template_ref == NULL) {
384  return TRUE;
385  }
386 
387  id = ID(xml_obj);
388  if (id == NULL) {
389  pe_err("'%s' object must have a id", xml_obj->name);
390  return FALSE;
391  }
392 
393  if (pcmk__str_eq(template_ref, id, pcmk__str_none)) {
394  pe_err("The resource object '%s' should not reference itself", id);
395  return FALSE;
396  }
397 
398  if (add_tag_ref(scheduler->template_rsc_sets, template_ref, id) == FALSE) {
399  return FALSE;
400  }
401 
402  return TRUE;
403 }
404 
405 static bool
406 detect_promotable(pcmk_resource_t *rsc)
407 {
408  const char *promotable = g_hash_table_lookup(rsc->meta,
410 
411  if (crm_is_true(promotable)) {
412  return TRUE;
413  }
414 
415  // @COMPAT deprecated since 2.0.0
416  if (pcmk__xe_is(rsc->xml, PCMK_XE_PROMOTABLE_LEGACY)) {
417  /* @TODO in some future version, pe_warn_once() here,
418  * then drop support in even later version
419  */
420  g_hash_table_insert(rsc->meta, strdup(XML_RSC_ATTR_PROMOTABLE),
421  strdup(XML_BOOLEAN_TRUE));
422  return TRUE;
423  }
424  return FALSE;
425 }
426 
427 static void
428 free_params_table(gpointer data)
429 {
430  g_hash_table_destroy((GHashTable *) data);
431 }
432 
445 GHashTable *
448 {
449  GHashTable *params_on_node = NULL;
450 
451  /* A NULL node is used to request the resource's default parameters
452  * (not evaluated for node), but we always want something non-NULL
453  * as a hash table key.
454  */
455  const char *node_name = "";
456 
457  // Sanity check
458  if ((rsc == NULL) || (scheduler == NULL)) {
459  return NULL;
460  }
461  if ((node != NULL) && (node->details->uname != NULL)) {
462  node_name = node->details->uname;
463  }
464 
465  // Find the parameter table for given node
466  if (rsc->parameter_cache == NULL) {
467  rsc->parameter_cache = pcmk__strikey_table(free, free_params_table);
468  } else {
469  params_on_node = g_hash_table_lookup(rsc->parameter_cache, node_name);
470  }
471 
472  // If none exists yet, create one with parameters evaluated for node
473  if (params_on_node == NULL) {
474  params_on_node = pcmk__strkey_table(free, free);
475  get_rsc_attributes(params_on_node, rsc, node, scheduler);
476  g_hash_table_insert(rsc->parameter_cache, strdup(node_name),
477  params_on_node);
478  }
479  return params_on_node;
480 }
481 
490 static void
491 unpack_requires(pcmk_resource_t *rsc, const char *value, bool is_default)
492 {
493  if (pcmk__str_eq(value, PCMK__VALUE_NOTHING, pcmk__str_casei)) {
494 
495  } else if (pcmk__str_eq(value, PCMK__VALUE_QUORUM, pcmk__str_casei)) {
497 
498  } else if (pcmk__str_eq(value, PCMK__VALUE_FENCING, pcmk__str_casei)) {
501  pcmk__config_warn("%s requires fencing but fencing is disabled",
502  rsc->id);
503  }
504 
505  } else if (pcmk__str_eq(value, PCMK__VALUE_UNFENCING, pcmk__str_casei)) {
507  pcmk__config_warn("Resetting \"" XML_RSC_ATTR_REQUIRES "\" for %s "
508  "to \"" PCMK__VALUE_QUORUM "\" because fencing "
509  "devices cannot require unfencing", rsc->id);
510  unpack_requires(rsc, PCMK__VALUE_QUORUM, true);
511  return;
512 
513  } else if (!pcmk_is_set(rsc->cluster->flags,
515  pcmk__config_warn("Resetting \"" XML_RSC_ATTR_REQUIRES "\" for %s "
516  "to \"" PCMK__VALUE_QUORUM "\" because fencing "
517  "is disabled", rsc->id);
518  unpack_requires(rsc, PCMK__VALUE_QUORUM, true);
519  return;
520 
521  } else {
524  }
525 
526  } else {
527  const char *orig_value = value;
528 
530  value = PCMK__VALUE_QUORUM;
531 
532  } else if ((rsc->variant == pcmk_rsc_variant_primitive)
533  && xml_contains_remote_node(rsc->xml)) {
534  value = PCMK__VALUE_QUORUM;
535 
536  } else if (pcmk_is_set(rsc->cluster->flags,
538  value = PCMK__VALUE_UNFENCING;
539 
540  } else if (pcmk_is_set(rsc->cluster->flags,
542  value = PCMK__VALUE_FENCING;
543 
544  } else if (rsc->cluster->no_quorum_policy == pcmk_no_quorum_ignore) {
545  value = PCMK__VALUE_NOTHING;
546 
547  } else {
548  value = PCMK__VALUE_QUORUM;
549  }
550 
551  if (orig_value != NULL) {
552  pcmk__config_err("Resetting '" XML_RSC_ATTR_REQUIRES "' for %s "
553  "to '%s' because '%s' is not valid",
554  rsc->id, value, orig_value);
555  }
556  unpack_requires(rsc, value, true);
557  return;
558  }
559 
560  pe_rsc_trace(rsc, "\tRequired to start: %s%s", value,
561  (is_default? " (default)" : ""));
562 }
563 
564 #ifndef PCMK__COMPAT_2_0
565 static void
566 warn_about_deprecated_classes(pcmk_resource_t *rsc)
567 {
568  const char *std = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS);
569 
570  if (pcmk__str_eq(std, PCMK_RESOURCE_CLASS_UPSTART, pcmk__str_none)) {
572  "Support for Upstart resources (such as %s) is deprecated "
573  "and will be removed in a future release of Pacemaker",
574  rsc->id);
575 
576  } else if (pcmk__str_eq(std, PCMK_RESOURCE_CLASS_NAGIOS, pcmk__str_none)) {
578  "Support for Nagios resources (such as %s) is deprecated "
579  "and will be removed in a future release of Pacemaker",
580  rsc->id);
581  }
582 }
583 #endif
584 
602 int
603 pe__unpack_resource(xmlNode *xml_obj, pcmk_resource_t **rsc,
605 {
606  xmlNode *expanded_xml = NULL;
607  xmlNode *ops = NULL;
608  const char *value = NULL;
609  const char *id = NULL;
610  bool guest_node = false;
611  bool remote_node = false;
612 
613  pe_rule_eval_data_t rule_data = {
614  .node_hash = NULL,
615  .role = pcmk_role_unknown,
616  .now = NULL,
617  .match_data = NULL,
618  .rsc_data = NULL,
619  .op_data = NULL
620  };
621 
622  CRM_CHECK(rsc != NULL, return EINVAL);
623  CRM_CHECK((xml_obj != NULL) && (scheduler != NULL),
624  *rsc = NULL;
625  return EINVAL);
626 
627  rule_data.now = scheduler->now;
628 
629  crm_log_xml_trace(xml_obj, "[raw XML]");
630 
631  id = crm_element_value(xml_obj, XML_ATTR_ID);
632  if (id == NULL) {
633  pe_err("Ignoring <%s> configuration without " XML_ATTR_ID,
634  xml_obj->name);
635  return pcmk_rc_unpack_error;
636  }
637 
638  if (unpack_template(xml_obj, &expanded_xml, scheduler) == FALSE) {
639  return pcmk_rc_unpack_error;
640  }
641 
642  *rsc = calloc(1, sizeof(pcmk_resource_t));
643  if (*rsc == NULL) {
644  crm_crit("Unable to allocate memory for resource '%s'", id);
645  return ENOMEM;
646  }
647  (*rsc)->cluster = scheduler;
648 
649  if (expanded_xml) {
650  crm_log_xml_trace(expanded_xml, "[expanded XML]");
651  (*rsc)->xml = expanded_xml;
652  (*rsc)->orig_xml = xml_obj;
653 
654  } else {
655  (*rsc)->xml = xml_obj;
656  (*rsc)->orig_xml = NULL;
657  }
658 
659  /* Do not use xml_obj from here on, use (*rsc)->xml in case templates are involved */
660 
661  (*rsc)->parent = parent;
662 
663  ops = find_xml_node((*rsc)->xml, "operations", FALSE);
664  (*rsc)->ops_xml = expand_idref(ops, scheduler->input);
665 
666  (*rsc)->variant = get_resource_type((const char *) (*rsc)->xml->name);
667  if ((*rsc)->variant == pcmk_rsc_variant_unknown) {
668  pe_err("Ignoring resource '%s' of unknown type '%s'",
669  id, (*rsc)->xml->name);
670  common_free(*rsc);
671  *rsc = NULL;
672  return pcmk_rc_unpack_error;
673  }
674 
675 #ifndef PCMK__COMPAT_2_0
676  warn_about_deprecated_classes(*rsc);
677 #endif
678 
679  (*rsc)->meta = pcmk__strkey_table(free, free);
680  (*rsc)->allowed_nodes = pcmk__strkey_table(NULL, free);
681  (*rsc)->known_on = pcmk__strkey_table(NULL, free);
682 
683  value = crm_element_value((*rsc)->xml, XML_RSC_ATTR_INCARNATION);
684  if (value) {
685  (*rsc)->id = crm_strdup_printf("%s:%s", id, value);
686  add_hash_param((*rsc)->meta, XML_RSC_ATTR_INCARNATION, value);
687 
688  } else {
689  (*rsc)->id = strdup(id);
690  }
691 
692  (*rsc)->fns = &resource_class_functions[(*rsc)->variant];
693 
694  get_meta_attributes((*rsc)->meta, *rsc, NULL, scheduler);
695  (*rsc)->parameters = pe_rsc_params(*rsc, NULL, scheduler); // \deprecated
696 
697  (*rsc)->flags = 0;
699 
702  }
703 
704  (*rsc)->rsc_cons = NULL;
705  (*rsc)->rsc_tickets = NULL;
706  (*rsc)->actions = NULL;
707  (*rsc)->role = pcmk_role_stopped;
708  (*rsc)->next_role = pcmk_role_unknown;
709 
710  (*rsc)->recovery_type = pcmk_multiply_active_restart;
711  (*rsc)->stickiness = 0;
712  (*rsc)->migration_threshold = INFINITY;
713  (*rsc)->failure_timeout = 0;
714 
715  value = g_hash_table_lookup((*rsc)->meta, XML_CIB_ATTR_PRIORITY);
716  (*rsc)->priority = char2score(value);
717 
718  value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_CRITICAL);
719  if ((value == NULL) || crm_is_true(value)) {
721  }
722 
723  value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_NOTIFY);
724  if (crm_is_true(value)) {
726  }
727 
728  if (xml_contains_remote_node((*rsc)->xml)) {
729  (*rsc)->is_remote_node = TRUE;
730  if (g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_CONTAINER)) {
731  guest_node = true;
732  } else {
733  remote_node = true;
734  }
735  }
736 
737  value = g_hash_table_lookup((*rsc)->meta, XML_OP_ATTR_ALLOW_MIGRATE);
738  if (crm_is_true(value)) {
740  } else if ((value == NULL) && remote_node) {
741  /* By default, we want remote nodes to be able
742  * to float around the cluster without having to stop all the
743  * resources within the remote-node before moving. Allowing
744  * migration support enables this feature. If this ever causes
745  * problems, migration support can be explicitly turned off with
746  * allow-migrate=false.
747  */
749  }
750 
751  value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_MANAGED);
752  if (value != NULL && !pcmk__str_eq("default", value, pcmk__str_casei)) {
753  if (crm_is_true(value)) {
755  } else {
757  }
758  }
759 
760  value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_MAINTENANCE);
761  if (crm_is_true(value)) {
764  }
768  }
769 
770  if (pe_rsc_is_clone(pe__const_top_resource(*rsc, false))) {
771  value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_UNIQUE);
772  if (crm_is_true(value)) {
774  }
775  if (detect_promotable(*rsc)) {
777  }
778  } else {
780  }
781 
782  value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_RESTART);
783  if (pcmk__str_eq(value, "restart", pcmk__str_casei)) {
784  (*rsc)->restart_type = pe_restart_restart;
785  pe_rsc_trace((*rsc), "%s dependency restart handling: restart",
786  (*rsc)->id);
788  "Support for restart-type is deprecated and will be removed in a future release");
789 
790  } else {
791  (*rsc)->restart_type = pe_restart_ignore;
792  pe_rsc_trace((*rsc), "%s dependency restart handling: ignore",
793  (*rsc)->id);
794  }
795 
796  value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_MULTIPLE);
797  if (pcmk__str_eq(value, "stop_only", pcmk__str_casei)) {
798  (*rsc)->recovery_type = pcmk_multiply_active_stop;
799  pe_rsc_trace((*rsc), "%s multiple running resource recovery: stop only",
800  (*rsc)->id);
801 
802  } else if (pcmk__str_eq(value, "block", pcmk__str_casei)) {
803  (*rsc)->recovery_type = pcmk_multiply_active_block;
804  pe_rsc_trace((*rsc), "%s multiple running resource recovery: block",
805  (*rsc)->id);
806 
807  } else if (pcmk__str_eq(value, "stop_unexpected", pcmk__str_casei)) {
808  (*rsc)->recovery_type = pcmk_multiply_active_unexpected;
809  pe_rsc_trace((*rsc), "%s multiple running resource recovery: "
810  "stop unexpected instances",
811  (*rsc)->id);
812 
813  } else { // "stop_start"
814  if (!pcmk__str_eq(value, "stop_start",
816  pe_warn("%s is not a valid value for " XML_RSC_ATTR_MULTIPLE
817  ", using default of \"stop_start\"", value);
818  }
819  (*rsc)->recovery_type = pcmk_multiply_active_restart;
820  pe_rsc_trace((*rsc), "%s multiple running resource recovery: "
821  "stop/start", (*rsc)->id);
822  }
823 
824  value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_STICKINESS);
825  if (value != NULL && !pcmk__str_eq("default", value, pcmk__str_casei)) {
826  (*rsc)->stickiness = char2score(value);
827  }
828 
829  value = g_hash_table_lookup((*rsc)->meta, PCMK_META_MIGRATION_THRESHOLD);
830  if (value != NULL && !pcmk__str_eq("default", value, pcmk__str_casei)) {
831  (*rsc)->migration_threshold = char2score(value);
832  if ((*rsc)->migration_threshold < 0) {
833  /* @TODO We use 1 here to preserve previous behavior, but this
834  * should probably use the default (INFINITY) or 0 (to disable)
835  * instead.
836  */
839  " must be non-negative, using 1 instead");
840  (*rsc)->migration_threshold = 1;
841  }
842  }
843 
844  if (pcmk__str_eq(crm_element_value((*rsc)->xml, XML_AGENT_ATTR_CLASS),
848  }
849 
850  value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_REQUIRES);
851  unpack_requires(*rsc, value, false);
852 
853  value = g_hash_table_lookup((*rsc)->meta, PCMK_META_FAILURE_TIMEOUT);
854  if (value != NULL) {
855  // Stored as seconds
856  (*rsc)->failure_timeout = (int) (crm_parse_interval_spec(value) / 1000);
857  }
858 
859  if (remote_node) {
860  GHashTable *params = pe_rsc_params(*rsc, NULL, scheduler);
861 
862  /* Grabbing the value now means that any rules based on node attributes
863  * will evaluate to false, so such rules should not be used with
864  * reconnect_interval.
865  *
866  * @TODO Evaluate per node before using
867  */
868  value = g_hash_table_lookup(params, XML_REMOTE_ATTR_RECONNECT_INTERVAL);
869  if (value) {
870  /* reconnect delay works by setting failure_timeout and preventing the
871  * connection from starting until the failure is cleared. */
872  (*rsc)->remote_reconnect_ms = crm_parse_interval_spec(value);
873  /* we want to override any default failure_timeout in use when remote
874  * reconnect_interval is in use. */
875  (*rsc)->failure_timeout = (*rsc)->remote_reconnect_ms / 1000;
876  }
877  }
878 
879  get_target_role(*rsc, &((*rsc)->next_role));
880  pe_rsc_trace((*rsc), "%s desired next state: %s", (*rsc)->id,
881  (*rsc)->next_role != pcmk_role_unknown? role2text((*rsc)->next_role) : "default");
882 
883  if ((*rsc)->fns->unpack(*rsc, scheduler) == FALSE) {
884  (*rsc)->fns->free(*rsc);
885  *rsc = NULL;
886  return pcmk_rc_unpack_error;
887  }
888 
890  // This tag must stay exactly the same because it is tested elsewhere
891  resource_location(*rsc, NULL, 0, "symmetric_default", scheduler);
892  } else if (guest_node) {
893  /* remote resources tied to a container resource must always be allowed
894  * to opt-in to the cluster. Whether the connection resource is actually
895  * allowed to be placed on a node is dependent on the container resource */
896  resource_location(*rsc, NULL, 0, "remote_connection_default",
897  scheduler);
898  }
899 
900  pe_rsc_trace((*rsc), "%s action notification: %s", (*rsc)->id,
901  pcmk_is_set((*rsc)->flags, pcmk_rsc_notify)? "required" : "not required");
902 
903  (*rsc)->utilization = pcmk__strkey_table(free, free);
904 
905  pe__unpack_dataset_nvpairs((*rsc)->xml, XML_TAG_UTILIZATION, &rule_data,
906  (*rsc)->utilization, NULL, FALSE, scheduler);
907 
908  if (expanded_xml) {
909  if (add_template_rsc(xml_obj, scheduler) == FALSE) {
910  (*rsc)->fns->free(*rsc);
911  *rsc = NULL;
912  return pcmk_rc_unpack_error;
913  }
914  }
915  return pcmk_rc_ok;
916 }
917 
918 gboolean
920 {
921  pcmk_resource_t *parent = child;
922 
923  if (parent == NULL || rsc == NULL) {
924  return FALSE;
925  }
926  while (parent->parent != NULL) {
927  if (parent->parent == rsc) {
928  return TRUE;
929  }
930  parent = parent->parent;
931  }
932  return FALSE;
933 }
934 
937 {
938  pcmk_resource_t *parent = rsc;
939 
940  if (parent == NULL) {
941  return NULL;
942  }
943  while ((parent->parent != NULL)
944  && (parent->parent->variant != pcmk_rsc_variant_bundle)) {
945  parent = parent->parent;
946  }
947  return parent;
948 }
949 
961 const pcmk_resource_t *
962 pe__const_top_resource(const pcmk_resource_t *rsc, bool include_bundle)
963 {
964  const pcmk_resource_t *parent = rsc;
965 
966  if (parent == NULL) {
967  return NULL;
968  }
969  while (parent->parent != NULL) {
970  if (!include_bundle
971  && (parent->parent->variant == pcmk_rsc_variant_bundle)) {
972  break;
973  }
974  parent = parent->parent;
975  }
976  return parent;
977 }
978 
979 void
981 {
982  if (rsc == NULL) {
983  return;
984  }
985 
986  pe_rsc_trace(rsc, "Freeing %s %d", rsc->id, rsc->variant);
987 
988  g_list_free(rsc->rsc_cons);
989  g_list_free(rsc->rsc_cons_lhs);
990  g_list_free(rsc->rsc_tickets);
991  g_list_free(rsc->dangling_migrations);
992 
993  if (rsc->parameter_cache != NULL) {
994  g_hash_table_destroy(rsc->parameter_cache);
995  }
996  if (rsc->meta != NULL) {
997  g_hash_table_destroy(rsc->meta);
998  }
999  if (rsc->utilization != NULL) {
1000  g_hash_table_destroy(rsc->utilization);
1001  }
1002 
1003  if ((rsc->parent == NULL)
1004  && pcmk_is_set(rsc->flags, pcmk_rsc_removed)) {
1005 
1006  free_xml(rsc->xml);
1007  rsc->xml = NULL;
1008  free_xml(rsc->orig_xml);
1009  rsc->orig_xml = NULL;
1010 
1011  /* if rsc->orig_xml, then rsc->xml is an expanded xml from a template */
1012  } else if (rsc->orig_xml) {
1013  free_xml(rsc->xml);
1014  rsc->xml = NULL;
1015  }
1016  if (rsc->running_on) {
1017  g_list_free(rsc->running_on);
1018  rsc->running_on = NULL;
1019  }
1020  if (rsc->known_on) {
1021  g_hash_table_destroy(rsc->known_on);
1022  rsc->known_on = NULL;
1023  }
1024  if (rsc->actions) {
1025  g_list_free(rsc->actions);
1026  rsc->actions = NULL;
1027  }
1028  if (rsc->allowed_nodes) {
1029  g_hash_table_destroy(rsc->allowed_nodes);
1030  rsc->allowed_nodes = NULL;
1031  }
1032  g_list_free(rsc->fillers);
1033  g_list_free(rsc->rsc_location);
1034  pe_rsc_trace(rsc, "Resource freed");
1035  free(rsc->id);
1036  free(rsc->clone_name);
1037  free(rsc->allocated_to);
1038  free(rsc->variant_opaque);
1039  free(rsc->pending_task);
1040  free(rsc);
1041 }
1042 
1057 bool
1059  pcmk_node_t **active, unsigned int *count_all,
1060  unsigned int *count_clean)
1061 {
1062  bool keep_looking = false;
1063  bool is_happy = false;
1064 
1065  CRM_CHECK((rsc != NULL) && (node != NULL) && (active != NULL),
1066  return false);
1067 
1068  is_happy = node->details->online && !node->details->unclean;
1069 
1070  if (count_all != NULL) {
1071  ++*count_all;
1072  }
1073  if ((count_clean != NULL) && is_happy) {
1074  ++*count_clean;
1075  }
1076  if ((count_all != NULL) || (count_clean != NULL)) {
1077  keep_looking = true; // We're counting, so go through entire list
1078  }
1079 
1080  if (rsc->partial_migration_source != NULL) {
1081  if (node->details == rsc->partial_migration_source->details) {
1082  *active = node; // This is the migration source
1083  } else {
1084  keep_looking = true;
1085  }
1086  } else if (!pcmk_is_set(rsc->flags, pcmk_rsc_needs_fencing)) {
1087  if (is_happy && ((*active == NULL) || !(*active)->details->online
1088  || (*active)->details->unclean)) {
1089  *active = node; // This is the first clean node
1090  } else {
1091  keep_looking = true;
1092  }
1093  }
1094  if (*active == NULL) {
1095  *active = node; // This is the first node checked
1096  }
1097  return keep_looking;
1098 }
1099 
1100 // Shared implementation of pcmk_rsc_methods_t:active_node()
1101 static pcmk_node_t *
1102 active_node(const pcmk_resource_t *rsc, unsigned int *count_all,
1103  unsigned int *count_clean)
1104 {
1105  pcmk_node_t *active = NULL;
1106 
1107  if (count_all != NULL) {
1108  *count_all = 0;
1109  }
1110  if (count_clean != NULL) {
1111  *count_clean = 0;
1112  }
1113  if (rsc == NULL) {
1114  return NULL;
1115  }
1116  for (GList *iter = rsc->running_on; iter != NULL; iter = iter->next) {
1117  if (!pe__count_active_node(rsc, (pcmk_node_t *) iter->data, &active,
1118  count_all, count_clean)) {
1119  break; // Don't waste time iterating if we don't have to
1120  }
1121  }
1122  return active;
1123 }
1124 
1138 pcmk_node_t *
1139 pe__find_active_requires(const pcmk_resource_t *rsc, unsigned int *count)
1140 {
1141  if (rsc == NULL) {
1142  if (count != NULL) {
1143  *count = 0;
1144  }
1145  return NULL;
1146 
1147  } else if (pcmk_is_set(rsc->flags, pcmk_rsc_needs_fencing)) {
1148  return rsc->fns->active_node(rsc, count, NULL);
1149 
1150  } else {
1151  return rsc->fns->active_node(rsc, NULL, count);
1152  }
1153 }
1154 
1155 void
1157 {
1158  if (rsc->children != NULL) {
1159  for (GList *item = rsc->children; item != NULL; item = item->next) {
1160  ((pcmk_resource_t *) item->data)->fns->count(item->data);
1161  }
1162 
1163  } else if (!pcmk_is_set(rsc->flags, pcmk_rsc_removed)
1164  || (rsc->role > pcmk_role_stopped)) {
1165  rsc->cluster->ninstances++;
1166  if (pe__resource_is_disabled(rsc)) {
1167  rsc->cluster->disabled_resources++;
1168  }
1169  if (pcmk_is_set(rsc->flags, pcmk_rsc_blocked)) {
1170  rsc->cluster->blocked_resources++;
1171  }
1172  }
1173 }
1174 
1183 void
1184 pe__set_next_role(pcmk_resource_t *rsc, enum rsc_role_e role, const char *why)
1185 {
1186  CRM_ASSERT((rsc != NULL) && (why != NULL));
1187  if (rsc->next_role != role) {
1188  pe_rsc_trace(rsc, "Resetting next role for %s from %s to %s (%s)",
1189  rsc->id, role2text(rsc->next_role), role2text(role), why);
1190  rsc->next_role = role;
1191  }
1192 }
gboolean native_active(pcmk_resource_t *rsc, gboolean all)
Definition: native.c:351
#define LOG_TRACE
Definition: logging.h:38
void pe__count_bundle(pcmk_resource_t *rsc)
Definition: bundle.c:2045
#define CRM_CHECK(expr, failure_action)
Definition: logging.h:238
Whether resource has clone notifications enabled.
Definition: resources.h:115
xmlNode * orig_xml
Original resource configuration, if using template.
Definition: resources.h:407
enum pe_quorum_policy no_quorum_policy
Response to loss of quorum.
Definition: scheduler.h:186
GHashTable * known_on
Nodes where resource has been probed (key is node ID, not name)
Definition: resources.h:463
pcmk_scheduler_t * cluster
Cluster that resource is part of.
Definition: resources.h:412
GHashTable * attrs
Node attributes.
Definition: nodes.h:115
unsigned int pe__clone_max_per_node(const pcmk_resource_t *rsc)
Definition: clone.c:1510
GList * rsc_tickets
Definition: resources.h:448
#define crm_crit(fmt, args...)
Definition: logging.h:380
char data[0]
Definition: cpg.c:55
pcmk_resource_t * uber_parent(pcmk_resource_t *rsc)
Definition: complex.c:936
#define INFINITY
Definition: crm.h:98
GList * rsc_cons
Definition: resources.h:445
#define PCMK__VALUE_FENCING
xmlNode * pcmk__xe_match(const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
Definition: xml.c:429
void pe__free_bundle(pcmk_resource_t *rsc)
Definition: bundle.c:1984
#define XML_EXPR_ATTR_TYPE
Definition: msg_xml.h:350
#define XML_CIB_TAG_CONTAINER
Definition: msg_xml.h:238
#define PCMK__ROLE_STARTED
Stopped.
Definition: roles.h:29
const char * name
Definition: cib.c:26
bool pcmk__strcase_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
Definition: strings.c:933
Whether cluster is symmetric (via symmetric-cluster property)
Definition: scheduler.h:74
enum rsc_role_e role
Resource&#39;s current role.
Definition: resources.h:468
#define XML_TAG_UTILIZATION
Definition: msg_xml.h:232
#define pcmk__config_warn(fmt...)
GList * children
Resource&#39;s child resources, if any.
Definition: resources.h:475
Whether resource can be started or promoted only on quorate nodes.
Definition: resources.h:187
xmlNode * xml
Resource configuration (possibly expanded from template)
Definition: resources.h:404
#define XML_RSC_ATTR_INCARNATION
Definition: msg_xml.h:246
enum rsc_role_e next_role
Resource&#39;s scheduled next role.
Definition: resources.h:469
gboolean get_target_role(const pcmk_resource_t *rsc, enum rsc_role_e *role)
Definition: utils.c:411
int char2score(const char *score)
Get the integer value of a score string.
Definition: scores.c:36
#define pcmk__config_err(fmt...)
xmlNode * find_xml_node(const xmlNode *root, const char *search_path, gboolean must_find)
Definition: xml.c:384
Do nothing to resource.
Definition: resources.h:79
pcmk_node_t * pe__find_active_requires(const pcmk_resource_t *rsc, unsigned int *count)
Definition: complex.c:1139
GHashTable * meta
Resource&#39;s meta-attributes.
Definition: resources.h:471
#define PCMK__VALUE_QUORUM
gboolean is_parent(pcmk_resource_t *child, pcmk_resource_t *rsc)
Definition: complex.c:919
Whether resource, its node, or entire cluster is in maintenance mode.
Definition: resources.h:181
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
Definition: nvpair.c:302
#define pe__set_working_set_flags(scheduler, flags_to_set)
Definition: internal.h:52
#define PCMK__VALUE_UNFENCING
enum rsc_role_e native_resource_state(const pcmk_resource_t *rsc, gboolean current)
Definition: native.c:1093
#define XML_CIB_TAG_RSC_TEMPLATE
Definition: msg_xml.h:240
#define XML_RSC_ATTR_STICKINESS
Definition: msg_xml.h:252
Group resource.
Definition: resources.h:35
GList * rsc_cons_lhs
Definition: resources.h:444
unsigned int pe__bundle_max_per_node(const pcmk_resource_t *rsc)
Definition: bundle.c:2212
#define PCMK_META_FAILURE_TIMEOUT
Definition: msg_xml.h:68
bool pe__count_active_node(const pcmk_resource_t *rsc, pcmk_node_t *node, pcmk_node_t **active, unsigned int *count_all, unsigned int *count_clean)
Definition: complex.c:1058
Implementation of pcmk_scheduler_t.
Definition: scheduler.h:172
char * pending_task
Pending action in history, if any.
Definition: resources.h:428
int pe__unpack_resource(xmlNode *xml_obj, pcmk_resource_t **rsc, pcmk_resource_t *parent, pcmk_scheduler_t *scheduler)
Definition: complex.c:603
xmlNode * get_xpath_object(const char *xpath, xmlNode *xml_obj, int error_level)
Definition: xpath.c:211
unsigned int pe__group_max_per_node(const pcmk_resource_t *rsc)
Definition: group.c:535
gboolean clone_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler)
Definition: clone.c:325
int ninstances
Total number of resource instances.
Definition: scheduler.h:224
#define pe__set_resource_flags(resource, flags_to_set)
Definition: internal.h:64
#define XML_CIB_ATTR_PRIORITY
Definition: msg_xml.h:286
xmlNode * copy_xml(xmlNode *src_node)
Definition: xml.c:789
#define XML_TAG_ATTR_SETS
Definition: msg_xml.h:227
gboolean native_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler)
Definition: native.c:206
#define XML_CIB_TAG_RESOURCES
Definition: msg_xml.h:205
void pe__print_bundle(pcmk_resource_t *rsc, const char *pre_text, long options, void *print_data)
Definition: bundle.c:1882
#define XML_RSC_ATTR_PROMOTABLE
Definition: msg_xml.h:247
const char * role2text(enum rsc_role_e role)
Definition: common.c:458
gboolean group_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler)
Definition: group.c:180
Stop on all and leave stopped.
Definition: resources.h:78
#define pe_warn(fmt...)
Definition: internal.h:44
pcmk_resource_t * parent
Resource&#39;s parent resource, if any.
Definition: resources.h:413
GList * dangling_migrations
Definition: resources.h:478
Whether any resource provides or requires unfencing (via CIB resources)
Definition: scheduler.h:86
#define PCMK_RESOURCE_CLASS_UPSTART
Definition: agents.h:36
gboolean clone_active(pcmk_resource_t *rsc, gboolean all)
Definition: clone.c:442
#define XML_RSC_ATTR_REQUIRES
Definition: msg_xml.h:254
Bundle resource.
Definition: resources.h:37
#define XML_RSC_ATTR_CRITICAL
Definition: msg_xml.h:264
Implementation of pcmk_resource_t.
Definition: resources.h:399
gboolean pe__bundle_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc, gboolean check_parent)
Definition: bundle.c:2069
gboolean pe__clone_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc, gboolean check_parent)
Definition: clone.c:1254
#define XML_RSC_ATTR_CONTAINER
Definition: msg_xml.h:255
#define PCMK__ROLE_UNPROMOTED_LEGACY
Primitive resource.
Definition: resources.h:34
#define XML_ATTR_ID
Definition: msg_xml.h:156
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
Definition: nvpair.c:447
#define XML_CIB_TAG_RESOURCE
Definition: msg_xml.h:235
#define XML_BOOLEAN_TRUE
Definition: msg_xml.h:167
void resource_location(pcmk_resource_t *rsc, const pcmk_node_t *node, int score, const char *tag, pcmk_scheduler_t *scheduler)
Definition: utils.c:360
xmlNode * rsc_defaults
Configured resource defaults.
Definition: scheduler.h:207
unsigned int pe__primitive_max_per_node(const pcmk_resource_t *rsc)
Definition: native.c:1449
#define pe_warn_once(pe_wo_bit, fmt...)
Definition: internal.h:142
#define PCMK__ROLE_UNPROMOTED
#define PCMK_RESOURCE_CLASS_STONITH
Definition: agents.h:31
bool xml_contains_remote_node(xmlNode *xml)
Definition: remote.c:84
GHashTable * pe_rsc_params(pcmk_resource_t *rsc, const pcmk_node_t *node, pcmk_scheduler_t *scheduler)
Get a table of resource parameters.
Definition: complex.c:446
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
Definition: util.h:99
xmlNode * add_node_copy(xmlNode *new_parent, xmlNode *xml_node)
Definition: xml.c:622
int blocked_resources
Number of blocked resources in cluster.
Definition: scheduler.h:219
enum rsc_role_e clone_resource_state(const pcmk_resource_t *rsc, gboolean current)
Definition: clone.c:1214
struct pe_node_shared_s * details
Basic node information.
Definition: nodes.h:134
xmlNode * expand_idref(xmlNode *input, xmlNode *top)
Definition: xml.c:2555
#define XML_AGENT_ATTR_PROVIDER
Definition: msg_xml.h:281
pe_obj_types
Resource variants supported by Pacemaker.
Definition: resources.h:31
unsigned long long flags
Group of enum pcmk_rsc_flags.
Definition: resources.h:429
const char * uname
Node name in cluster.
Definition: nodes.h:68
#define XML_TAG_META_SETS
Definition: msg_xml.h:228
rsc_role_e
Definition: roles.h:27
char * clone_name
Resource instance ID in history.
Definition: resources.h:401
gboolean add_tag_ref(GHashTable *tags, const char *tag_name, const char *obj_ref)
Definition: utils.c:617
void group_free(pcmk_resource_t *rsc)
Definition: group.c:456
void native_free(pcmk_resource_t *rsc)
Definition: native.c:1086
#define XML_RSC_ATTR_MANAGED
Definition: msg_xml.h:248
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, pcmk_scheduler_t *scheduler)
Definition: utils.c:707
GList * actions
Definition: resources.h:447
void get_meta_attributes(GHashTable *meta_hash, pcmk_resource_t *rsc, pcmk_node_t *node, pcmk_scheduler_t *scheduler)
Definition: complex.c:157
void common_free(pcmk_resource_t *rsc)
Definition: complex.c:980
GHashTable * utilization
Resource&#39;s utilization attributes.
Definition: resources.h:473
enum rsc_role_e pe__bundle_resource_state(const pcmk_resource_t *rsc, gboolean current)
Definition: bundle.c:2018
void pe__count_common(pcmk_resource_t *rsc)
Definition: complex.c:1156
void group_print(pcmk_resource_t *rsc, const char *pre_text, long options, void *print_data)
Definition: group.c:290
void free_xml(xmlNode *child)
Definition: xml.c:783
Whether resource is blocked from further action.
Definition: resources.h:109
Implementation of pcmk_node_t.
Definition: nodes.h:130
enum pe_obj_types variant
Resource variant.
Definition: resources.h:414
xmlNode * input
CIB XML.
Definition: scheduler.h:175
gboolean group_active(pcmk_resource_t *rsc, gboolean all)
Definition: group.c:236
#define XML_REMOTE_ATTR_RECONNECT_INTERVAL
Definition: msg_xml.h:266
Stop unexpected instances.
Definition: resources.h:80
#define XML_RSC_ATTR_NOTIFY
Definition: msg_xml.h:251
void populate_hash(xmlNode *nvpair_list, GHashTable *hash, const char **attrs, int attrs_length)
#define XML_RSC_ATTR_UNIQUE
Definition: msg_xml.h:250
Whether resource has "critical" meta-attribute enabled.
Definition: resources.h:148
GList * fillers
Resources contained by this one, if any.
Definition: resources.h:481
char * native_parameter(pcmk_resource_t *rsc, pcmk_node_t *node, gboolean create, const char *name, pcmk_scheduler_t *scheduler)
Definition: native.c:329
pcmk_resource_t * native_find_rsc(pcmk_resource_t *rsc, const char *id, const pcmk_node_t *node, int flags)
Definition: native.c:275
Whether resource has not yet been assigned to a node.
Definition: resources.h:127
const pcmk_resource_t * pe__const_top_resource(const pcmk_resource_t *rsc, bool include_bundle)
Definition: complex.c:962
gboolean pe__native_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc, gboolean check_parent)
Definition: native.c:1425
void clone_print(pcmk_resource_t *rsc, const char *pre_text, long options, void *print_data)
Definition: clone.c:593
pcmk_rsc_methods_t resource_class_functions[]
Definition: complex.c:26
#define XML_CIB_TAG_INCARNATION
Definition: msg_xml.h:237
Whether resource requires fencing before recovery if on unclean node.
Definition: resources.h:190
gboolean pe__unpack_bundle(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler)
Definition: bundle.c:984
const char * standard
Definition: common.h:69
Whether resource&#39;s class is "stonith".
Definition: resources.h:121
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
Definition: strings.c:608
#define PCMK__ROLE_UNKNOWN
#define XML_RSC_ATTR_MAINTENANCE
Definition: msg_xml.h:257
gboolean pe__bundle_active(pcmk_resource_t *rsc, gboolean all)
Definition: bundle.c:1319
crm_time_t * now
Definition: common.h:82
void add_hash_param(GHashTable *hash, const char *name, const char *value)
Definition: common.c:508
pcmk_rsc_methods_t * fns
Resource object methods.
Definition: resources.h:416
#define PCMK_META_MIGRATION_THRESHOLD
Definition: msg_xml.h:69
Whether fencing is enabled (via stonith-enabled property)
Definition: scheduler.h:80
void * variant_opaque
Variant-specific (and private) data.
Definition: resources.h:415
pcmk_scheduler_t * scheduler
#define CRM_ASSERT(expr)
Definition: results.h:42
GHashTable * node_hash
Definition: common.h:80
char guint crm_parse_interval_spec(const char *input)
Parse milliseconds from a Pacemaker interval specification.
Definition: utils.c:271
int disabled_resources
Number of disabled resources in cluster.
Definition: scheduler.h:220
Whether resource is allowed to live-migrate.
Definition: resources.h:172
#define PCMK_XE_PROMOTABLE_LEGACY
Definition: msg_xml.h:42
Stop on all, start on desired.
Definition: resources.h:77
pcmk_node_t *(* active_node)(const pcmk_resource_t *rsc, unsigned int *count_all, unsigned int *count_clean)
Find a node (and optionally count all) where resource is active.
Definition: resources.h:384
bool pe__resource_is_disabled(const pcmk_resource_t *rsc)
Definition: utils.c:725
pcmk_node_t * allocated_to
Node resource is assigned to.
Definition: resources.h:451
GList * rsc_location
Definition: resources.h:446
#define XML_RSC_ATTR_MULTIPLE
Definition: msg_xml.h:253
#define pe__clear_resource_flags(resource, flags_to_clear)
Definition: internal.h:70
Resource object methods.
Definition: resources.h:266
GList * running_on
Nodes where resource may be active.
Definition: resources.h:460
#define XML_RSC_ATTR_RESTART
Definition: msg_xml.h:243
#define PCMK__VALUE_NOTHING
void clone_free(pcmk_resource_t *rsc)
Definition: clone.c:1180
#define crm_log_xml_trace(xml, text)
Definition: logging.h:395
GHashTable * parameter_cache
Definition: resources.h:495
enum rsc_role_e group_resource_state(const pcmk_resource_t *rsc, gboolean current)
Definition: group.c:477
gboolean crm_is_true(const char *s)
Definition: strings.c:416
Whether resource can be promoted and demoted.
Definition: resources.h:124
void pe__set_next_role(pcmk_resource_t *rsc, enum rsc_role_e role, const char *why)
Definition: complex.c:1184
Whether cluster has a fencing resource (via CIB resources)
Definition: scheduler.h:83
#define XML_CIB_TAG_GROUP
Definition: msg_xml.h:236
Resource role is unknown.
Definition: roles.h:28
pcmk_node_t * pe__bundle_active_node(const pcmk_resource_t *rsc, unsigned int *count_all, unsigned int *count_clean)
Definition: bundle.c:2129
#define pe_rsc_trace(rsc, fmt, args...)
Definition: internal.h:37
#define PCMK_RESOURCE_CLASS_NAGIOS
Definition: agents.h:34
unsigned long long flags
Group of enum pcmk_scheduler_flags.
Definition: scheduler.h:183
#define ID(x)
Definition: msg_xml.h:474
#define pe_err(fmt...)
Definition: internal.h:39
const char * parent
Definition: cib.c:27
pcmk_node_t * native_location(const pcmk_resource_t *rsc, GList **list, int current)
Definition: native.c:1116
Clone resource.
Definition: resources.h:36
Whether resource is managed.
Definition: resources.h:106
Whether resource can be started or promoted only on unfenced nodes.
Definition: resources.h:193
gboolean pe__group_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc, gboolean check_parent)
Definition: group.c:496
gboolean unclean
Whether node requires fencing.
Definition: nodes.h:76
void get_rsc_attributes(GHashTable *meta_hash, const pcmk_resource_t *rsc, const pcmk_node_t *node, pcmk_scheduler_t *scheduler)
Definition: complex.c:207
Whether cluster is in maintenance mode (via maintenance-mode property)
Definition: scheduler.h:77
Whether resource has been removed from the configuration.
Definition: resources.h:103
crm_time_t * now
Current time for evaluation purposes.
Definition: scheduler.h:176
GHashTable * template_rsc_sets
Mappings of template ID to resource ID.
Definition: scheduler.h:213
gboolean online
Whether online.
Definition: nodes.h:72
#define XML_OP_ATTR_ALLOW_MIGRATE
Definition: msg_xml.h:270
Whether resource is not an anonymous clone instance.
Definition: resources.h:118
void native_print(pcmk_resource_t *rsc, const char *pre_text, long options, void *print_data)
Definition: native.c:931
Unknown resource variant.
Definition: resources.h:33
pcmk_node_t * partial_migration_source
The source node, if migrate_to completed but migrate_from has not.
Definition: resources.h:457
GHashTable * pcmk__strikey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
Definition: strings.c:646
#define XML_AGENT_ATTR_CLASS
Definition: msg_xml.h:280
char * id
Resource ID in configuration.
Definition: resources.h:400
GHashTable * allowed_nodes
Nodes where resource may run (key is node ID, not name)
Definition: resources.h:466