root/lib/pacemaker/pcmk_sched_messages.c

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

DEFINITIONS

This source file includes following definitions.
  1. log_resource_details
  2. log_all_actions
  3. pcmk__schedule_actions

   1 /*
   2  * Copyright 2004-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 
  12 #include <sys/param.h>
  13 
  14 #include <crm/crm.h>
  15 #include <crm/cib.h>
  16 #include <crm/msg_xml.h>
  17 #include <crm/common/xml.h>
  18 
  19 #include <glib.h>
  20 
  21 #include <crm/pengine/status.h>
  22 #include <pacemaker-internal.h>
  23 #include <crm/common/ipc_internal.h>
  24 #include "libpacemaker_private.h"
  25 
  26 extern bool pcmk__is_daemon;
  27 
  28 static void
  29 log_resource_details(pe_working_set_t *data_set)
     /* [previous][next][first][last][top][bottom][index][help] */
  30 {
  31     pcmk__output_t *out = data_set->priv;
  32     GList *all = NULL;
  33 
  34     /* We need a list of nodes that we are allowed to output information for.
  35      * This is necessary because out->message for all the resource-related
  36      * messages expects such a list, due to the `crm_mon --node=` feature.  Here,
  37      * we just make it a list of all the nodes.
  38      */
  39     all = g_list_prepend(all, (gpointer) "*");
  40 
  41     for (GList *item = data_set->resources; item != NULL; item = item->next) {
  42         pe_resource_t *rsc = (pe_resource_t *) item->data;
  43 
  44         // Log all resources except inactive orphans
  45         if (!pcmk_is_set(rsc->flags, pe_rsc_orphan)
  46             || (rsc->role != RSC_ROLE_STOPPED)) {
  47             out->message(out, crm_map_element_name(rsc->xml), 0, rsc, all, all);
  48         }
  49     }
  50 
  51     g_list_free(all);
  52 }
  53 
  54 static void
  55 log_all_actions(pe_working_set_t *data_set)
     /* [previous][next][first][last][top][bottom][index][help] */
  56 {
  57     /* This only ever outputs to the log, so ignore whatever output object was
  58      * previously set and just log instead.
  59      */
  60     pcmk__output_t *prev_out = data_set->priv;
  61     pcmk__output_t *out = pcmk__new_logger();
  62 
  63     if (out == NULL) {
  64         return;
  65     }
  66 
  67     pcmk__output_set_log_level(out, LOG_NOTICE);
  68     data_set->priv = out;
  69 
  70     out->begin_list(out, NULL, NULL, "Actions");
  71     LogNodeActions(data_set);
  72 
  73     g_list_foreach(data_set->resources, (GFunc) LogActions, data_set);
  74 
  75     out->end_list(out);
  76     out->finish(out, CRM_EX_OK, true, NULL);
  77     pcmk__output_free(out);
  78 
  79     data_set->priv = prev_out;
  80 }
  81 
  82 /*!
  83  * \internal
  84  * \brief Run the scheduler for a given CIB
  85  *
  86  * \param[in,out] data_set  Cluster working set
  87  * \param[in]     xml_input CIB XML to use as scheduler input
  88  * \param[in]     now       Time to use for rule evaluation (or NULL for now)
  89  */
  90 xmlNode *
  91 pcmk__schedule_actions(pe_working_set_t *data_set, xmlNode *xml_input,
     /* [previous][next][first][last][top][bottom][index][help] */
  92                        crm_time_t *now)
  93 {
  94     GList *gIter = NULL;
  95 
  96     CRM_ASSERT(xml_input || pcmk_is_set(data_set->flags, pe_flag_have_status));
  97 
  98     if (!pcmk_is_set(data_set->flags, pe_flag_have_status)) {
  99         set_working_set_defaults(data_set);
 100         data_set->input = xml_input;
 101         data_set->now = now;
 102 
 103     } else {
 104         crm_trace("Already have status - reusing");
 105     }
 106 
 107     if (data_set->now == NULL) {
 108         data_set->now = crm_time_new(NULL);
 109     }
 110 
 111     crm_trace("Calculate cluster status");
 112     stage0(data_set);
 113     if (!pcmk_is_set(data_set->flags, pe_flag_quick_location) &&
 114          pcmk__is_daemon) {
 115         log_resource_details(data_set);
 116     }
 117 
 118     crm_trace("Applying location constraints");
 119     stage2(data_set);
 120 
 121     if (pcmk_is_set(data_set->flags, pe_flag_quick_location)) {
 122         return NULL;
 123     }
 124 
 125     pcmk__create_internal_constraints(data_set);
 126 
 127     crm_trace("Check actions");
 128     stage4(data_set);
 129 
 130     crm_trace("Allocate resources");
 131     stage5(data_set);
 132 
 133     crm_trace("Processing fencing and shutdown cases");
 134     stage6(data_set);
 135 
 136     pcmk__apply_orderings(data_set);
 137     log_all_actions(data_set);
 138 
 139     crm_trace("Create transition graph");
 140     stage8(data_set);
 141 
 142     crm_trace("=#=#=#=#= Summary =#=#=#=#=");
 143     crm_trace("\t========= Set %d (Un-runnable) =========", -1);
 144     if (get_crm_log_level() == LOG_TRACE) {
 145         gIter = data_set->actions;
 146         for (; gIter != NULL; gIter = gIter->next) {
 147             pe_action_t *action = (pe_action_t *) gIter->data;
 148 
 149             if (!pcmk_any_flags_set(action->flags,
 150                                     pe_action_optional
 151                                     |pe_action_runnable
 152                                     |pe_action_pseudo)) {
 153                 log_action(LOG_TRACE, "\t", action, TRUE);
 154             }
 155         }
 156     }
 157 
 158     return data_set->graph;
 159 }

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