root/lib/pacemaker/pcmk_sched_resource.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. pcmk__colocated_resources

   1 /*
   2  * Copyright 2014-2021 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 General Public License version 2
   7  * or later (GPLv2+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #include <crm_internal.h>
  11 #include <crm/msg_xml.h>
  12 #include <pacemaker-internal.h>
  13 
  14 #include "libpacemaker_private.h"
  15 
  16 // Shared implementation of resource_alloc_functions_t:colocated_resources()
  17 GList *
  18 pcmk__colocated_resources(pe_resource_t *rsc, pe_resource_t *orig_rsc,
     /* [previous][next][first][last][top][bottom][index][help] */
  19                           GList *colocated_rscs)
  20 {
  21     GList *gIter = NULL;
  22 
  23     if (orig_rsc == NULL) {
  24         orig_rsc = rsc;
  25     }
  26 
  27     if ((rsc == NULL) || (g_list_find(colocated_rscs, rsc) != NULL)) {
  28         return colocated_rscs;
  29     }
  30 
  31     pe_rsc_trace(orig_rsc, "%s is in colocation chain with %s",
  32                  rsc->id, orig_rsc->id);
  33     colocated_rscs = g_list_append(colocated_rscs, rsc);
  34 
  35     // Follow colocations where this resource is the dependent resource
  36     for (gIter = rsc->rsc_cons; gIter != NULL; gIter = gIter->next) {
  37         pcmk__colocation_t *constraint = (pcmk__colocation_t *) gIter->data;
  38         pe_resource_t *primary = constraint->primary;
  39 
  40         if (primary == orig_rsc) {
  41             continue; // Break colocation loop
  42         }
  43 
  44         if ((constraint->score == INFINITY) &&
  45             (pcmk__colocation_affects(rsc, primary, constraint,
  46                                       true) == pcmk__coloc_affects_location)) {
  47 
  48             colocated_rscs = primary->cmds->colocated_resources(primary,
  49                                                                 orig_rsc,
  50                                                                 colocated_rscs);
  51         }
  52     }
  53 
  54     // Follow colocations where this resource is the primary resource
  55     for (gIter = rsc->rsc_cons_lhs; gIter != NULL; gIter = gIter->next) {
  56         pcmk__colocation_t *constraint = (pcmk__colocation_t *) gIter->data;
  57         pe_resource_t *dependent = constraint->dependent;
  58 
  59         if (dependent == orig_rsc) {
  60             continue; // Break colocation loop
  61         }
  62 
  63         if (pe_rsc_is_clone(rsc) && !pe_rsc_is_clone(dependent)) {
  64             continue; // We can't be sure whether dependent will be colocated
  65         }
  66 
  67         if ((constraint->score == INFINITY) &&
  68             (pcmk__colocation_affects(dependent, rsc, constraint,
  69                                       true) == pcmk__coloc_affects_location)) {
  70 
  71             colocated_rscs = dependent->cmds->colocated_resources(dependent,
  72                                                                   orig_rsc,
  73                                                                   colocated_rscs);
  74         }
  75     }
  76 
  77     return colocated_rscs;
  78 }

/* [previous][next][first][last][top][bottom][index][help] */