pacemaker  2.1.0-7c3f660
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pcmk_sched_messages.c
Go to the documentation of this file.
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>
24 
25 extern bool pcmk__is_daemon;
26 
27 static void
28 log_resource_details(pe_working_set_t *data_set)
29 {
30  pcmk__output_t *out = data_set->priv;
31  GList *all = NULL;
32 
33  /* We need a list of nodes that we are allowed to output information for.
34  * This is necessary because out->message for all the resource-related
35  * messages expects such a list, due to the `crm_mon --node=` feature. Here,
36  * we just make it a list of all the nodes.
37  */
38  all = g_list_prepend(all, strdup("*"));
39 
40  for (GList *item = data_set->resources; item != NULL; item = item->next) {
41  pe_resource_t *rsc = (pe_resource_t *) item->data;
42 
43  // Log all resources except inactive orphans
44  if (!pcmk_is_set(rsc->flags, pe_rsc_orphan)
45  || (rsc->role != RSC_ROLE_STOPPED)) {
46  out->message(out, crm_map_element_name(rsc->xml), 0, rsc, all, all);
47  }
48  }
49 
50  g_list_free_full(all, free);
51 }
52 
61 xmlNode *
62 pcmk__schedule_actions(pe_working_set_t *data_set, xmlNode *xml_input,
63  crm_time_t *now)
64 {
65  GList *gIter = NULL;
66 
67  CRM_ASSERT(xml_input || pcmk_is_set(data_set->flags, pe_flag_have_status));
68 
69  if (!pcmk_is_set(data_set->flags, pe_flag_have_status)) {
70  set_working_set_defaults(data_set);
71  data_set->input = xml_input;
72  data_set->now = now;
73 
74  } else {
75  crm_trace("Already have status - reusing");
76  }
77 
78  if (data_set->now == NULL) {
79  data_set->now = crm_time_new(NULL);
80  }
81 
82  crm_trace("Calculate cluster status");
83  stage0(data_set);
84  if (!pcmk_is_set(data_set->flags, pe_flag_quick_location) &&
86  log_resource_details(data_set);
87  }
88 
89  crm_trace("Applying location constraints");
90  stage2(data_set);
91 
92  if (pcmk_is_set(data_set->flags, pe_flag_quick_location)) {
93  return NULL;
94  }
95 
96  crm_trace("Create internal constraints");
97  stage3(data_set);
98 
99  crm_trace("Check actions");
100  stage4(data_set);
101 
102  crm_trace("Allocate resources");
103  stage5(data_set);
104 
105  crm_trace("Processing fencing and shutdown cases");
106  stage6(data_set);
107 
108  crm_trace("Applying ordering constraints");
109  stage7(data_set);
110 
111  crm_trace("Create transition graph");
112  stage8(data_set);
113 
114  crm_trace("=#=#=#=#= Summary =#=#=#=#=");
115  crm_trace("\t========= Set %d (Un-runnable) =========", -1);
116  if (get_crm_log_level() == LOG_TRACE) {
117  gIter = data_set->actions;
118  for (; gIter != NULL; gIter = gIter->next) {
119  pe_action_t *action = (pe_action_t *) gIter->data;
120 
121  if (!pcmk_any_flags_set(action->flags,
124  |pe_action_pseudo)) {
125  log_action(LOG_TRACE, "\t", action, TRUE);
126  }
127  }
128  }
129 
130  return data_set->graph;
131 }
#define LOG_TRACE
Definition: logging.h:36
A dumping ground.
gboolean stage2(pe_working_set_t *data_set)
gboolean stage5(pe_working_set_t *data_set)
gboolean stage3(pe_working_set_t *data_set)
struct crm_time_s crm_time_t
Definition: iso8601.h:32
enum rsc_role_e role
Definition: pe_types.h:369
gboolean stage0(pe_working_set_t *data_set)
xmlNode * xml
Definition: pe_types.h:322
int(* message)(pcmk__output_t *out, const char *message_id,...)
#define pe_flag_have_status
Definition: pe_types.h:116
GList * actions
Definition: pe_types.h:164
xmlNode * pcmk__schedule_actions(pe_working_set_t *data_set, xmlNode *xml_input, crm_time_t *now)
const char * action
Definition: pcmk_fence.c:30
GList * resources
Definition: pe_types.h:158
gboolean stage8(pe_working_set_t *data_set)
gboolean stage4(pe_working_set_t *data_set)
#define crm_trace(fmt, args...)
Definition: logging.h:356
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
Definition: util.h:114
void set_working_set_defaults(pe_working_set_t *data_set)
Definition: status.c:359
bool pcmk__is_daemon
Definition: logging.c:47
unsigned long long flags
Definition: pe_types.h:347
Wrappers for and extensions to libxml2.
xmlNode * input
Definition: pe_types.h:137
unsigned int get_crm_log_level(void)
Definition: logging.c:987
void log_action(unsigned int log_level, const char *pre_text, pe_action_t *action, gboolean details)
gboolean stage7(pe_working_set_t *data_set)
#define pe_flag_quick_location
Definition: pe_types.h:119
Cluster status and scheduling.
#define CRM_ASSERT(expr)
Definition: results.h:42
Cluster Configuration.
crm_time_t * crm_time_new(const char *string)
Definition: iso8601.c:93
This structure contains everything that makes up a single output formatter.
gboolean stage6(pe_working_set_t *data_set)
enum pe_action_flags flags
Definition: pe_types.h:418
unsigned long long flags
Definition: pe_types.h:146
crm_time_t * now
Definition: pe_types.h:138
#define pe_rsc_orphan
Definition: pe_types.h:248
xmlNode * graph
Definition: pe_types.h:176