pacemaker  2.0.4-2deceaa
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-2020 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 gboolean show_scores = FALSE;
26 gboolean show_utilization = FALSE;
27 
28 static void
29 log_resource_details(pe_working_set_t *data_set)
30 {
31  int rc = pcmk_rc_ok;
32  pcmk__output_t *out = NULL;
33  const char* argv[] = { "", NULL };
34  GListPtr unames = NULL;
35  pcmk__supported_format_t formats[] = {
37  { NULL, NULL, NULL }
38  };
39 
40  /* We need a list of nodes that we are allowed to output information for.
41  * This is necessary because out->message for all the resource-related
42  * messages expects such a list, due to the `crm_mon --node=` feature. Here,
43  * we just make it a list of all the nodes.
44  */
45  unames = g_list_append(unames, strdup("*"));
46 
47  pcmk__register_formats(NULL, formats);
48  rc = pcmk__output_new(&out, "log", NULL, (char**)argv);
49  if ((rc != pcmk_rc_ok) || (out == NULL)) {
50  crm_err("Can't log resource details due to internal error: %s\n",
51  pcmk_rc_str(rc));
52  return;
53  }
55 
56  for (GList *item = data_set->resources; item != NULL; item = item->next) {
57  pe_resource_t *rsc = (pe_resource_t *) item->data;
58 
59  // Log all resources except inactive orphans
60  if (is_not_set(rsc->flags, pe_rsc_orphan)
61  || (rsc->role != RSC_ROLE_STOPPED)) {
62  out->message(out, crm_map_element_name(rsc->xml), 0, rsc, unames);
63  }
64  }
65 
66  pcmk__output_free(out);
67  g_list_free_full(unames, free);
68 }
69 
78 xmlNode *
79 pcmk__schedule_actions(pe_working_set_t *data_set, xmlNode *xml_input,
80  crm_time_t *now)
81 {
82  GListPtr gIter = NULL;
83 
84 /* pe_debug_on(); */
85 
86  CRM_ASSERT(xml_input || is_set(data_set->flags, pe_flag_have_status));
87 
88  if (is_set(data_set->flags, pe_flag_have_status) == FALSE) {
89  set_working_set_defaults(data_set);
90  data_set->input = xml_input;
91  data_set->now = now;
92 
93  } else {
94  crm_trace("Already have status - reusing");
95  }
96 
97  if (data_set->now == NULL) {
98  data_set->now = crm_time_new(NULL);
99  }
100 
101  crm_trace("Calculate cluster status");
102  stage0(data_set);
103  if (is_not_set(data_set->flags, pe_flag_quick_location)) {
104  log_resource_details(data_set);
105  }
106 
107  crm_trace("Applying placement constraints");
108  stage2(data_set);
109 
110  if(is_set(data_set->flags, pe_flag_quick_location)){
111  return NULL;
112  }
113 
114  crm_trace("Create internal constraints");
115  stage3(data_set);
116 
117  crm_trace("Check actions");
118  stage4(data_set);
119 
120  crm_trace("Allocate resources");
121  stage5(data_set);
122 
123  crm_trace("Processing fencing and shutdown cases");
124  stage6(data_set);
125 
126  crm_trace("Applying ordering constraints");
127  stage7(data_set);
128 
129  crm_trace("Create transition graph");
130  stage8(data_set);
131 
132  crm_trace("=#=#=#=#= Summary =#=#=#=#=");
133  crm_trace("\t========= Set %d (Un-runnable) =========", -1);
134  if (get_crm_log_level() == LOG_TRACE) {
135  gIter = data_set->actions;
136  for (; gIter != NULL; gIter = gIter->next) {
137  pe_action_t *action = (pe_action_t *) gIter->data;
138 
139  if (is_set(action->flags, pe_action_optional) == FALSE
140  && is_set(action->flags, pe_action_runnable) == FALSE
141  && is_set(action->flags, pe_action_pseudo) == FALSE) {
142  log_action(LOG_TRACE, "\t", action, TRUE);
143  }
144  }
145  }
146 
147  return data_set->graph;
148 }
#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:354
void pcmk__output_free(pcmk__output_t *out)
Definition: output.c:19
gboolean stage0(pe_working_set_t *data_set)
xmlNode * xml
Definition: pe_types.h:307
int(* message)(pcmk__output_t *out, const char *message_id,...)
Definition: output.h:311
GListPtr resources
Definition: pe_types.h:147
#define pe_flag_have_status
Definition: pe_types.h:110
gboolean show_scores
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
Definition: results.c:413
xmlNode * pcmk__schedule_actions(pe_working_set_t *data_set, xmlNode *xml_input, crm_time_t *now)
const char * action
Definition: pcmk_fence.c:29
int rc
Definition: pcmk_fence.c:34
gboolean stage8(pe_working_set_t *data_set)
gboolean stage4(pe_working_set_t *data_set)
#define crm_trace(fmt, args...)
Definition: logging.h:369
void pcmk__register_formats(GOptionGroup *group, pcmk__supported_format_t *table)
Definition: output.c:96
void set_working_set_defaults(pe_working_set_t *data_set)
Definition: status.c:357
unsigned long long flags
Definition: pe_types.h:332
GListPtr actions
Definition: pe_types.h:153
Wrappers for and extensions to libxml2.
#define PCMK__SUPPORTED_FORMAT_LOG
Definition: output.h:140
void pe__register_messages(pcmk__output_t *out)
Definition: pe_output.c:1756
xmlNode * input
Definition: pe_types.h:126
unsigned int get_crm_log_level(void)
Definition: logging.c:922
gboolean show_utilization
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:113
Cluster status and scheduling.
#define crm_err(fmt, args...)
Definition: logging.h:363
#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.
Definition: output.h:153
gboolean stage6(pe_working_set_t *data_set)
enum pe_action_flags flags
Definition: pe_types.h:397
unsigned long long flags
Definition: pe_types.h:135
GList * GListPtr
Definition: crm.h:214
int pcmk__output_new(pcmk__output_t **out, const char *fmt_name, const char *filename, char **argv)
Definition: output.c:31
crm_time_t * now
Definition: pe_types.h:127
#define pe_rsc_orphan
Definition: pe_types.h:235
xmlNode * graph
Definition: pe_types.h:165