Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor log improvements #3782

Merged
merged 9 commits into from
Jan 8, 2025
19 changes: 12 additions & 7 deletions daemons/attrd/attrd_cib.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,16 @@ attrd_cib_updated_cb(const char *event, xmlNode *msg)
const char *client_name = NULL;
bool status_changed = false;

if (attrd_shutting_down(true)) {
crm_debug("Ignoring CIB change during shutdown");
return;
}

if (cib__get_notify_patchset(msg, &patchset) != pcmk_rc_ok) {
return;
}

if (pcmk__cib_element_in_patchset(patchset, PCMK_XE_ALERTS)) {
mainloop_set_trigger(attrd_config_read);
if (attrd_shutting_down(true)) {
crm_debug("Ignoring alerts change in CIB during shutdown");
} else {
mainloop_set_trigger(attrd_config_read);
}
}

status_changed = pcmk__cib_element_in_patchset(patchset, PCMK_XE_STATUS);
Expand All @@ -83,6 +82,12 @@ attrd_cib_updated_cb(const char *event, xmlNode *msg)

if (status_changed
|| pcmk__cib_element_in_patchset(patchset, PCMK_XE_NODES)) {

if (attrd_shutting_down(true)) {
crm_debug("Ignoring node change in CIB during shutdown");
return;
}

/* An unsafe client modified the PCMK_XE_NODES or PCMK_XE_STATUS
* section. Write transient attributes to ensure they're up-to-date in
* the CIB.
Expand All @@ -91,7 +96,7 @@ attrd_cib_updated_cb(const char *event, xmlNode *msg)
client_name = crm_element_value(msg, PCMK__XA_CIB_CLIENTID);
}
crm_notice("Updating all attributes after %s event triggered by %s",
event, pcmk__s(client_name, "(unidentified client)"));
event, pcmk__s(client_name, "unidentified client"));

attrd_write_attributes(attrd_write_all);
}
Expand Down
20 changes: 13 additions & 7 deletions daemons/execd/execd_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,19 @@ log_finished(const lrmd_cmd_t *cmd, int exec_time_ms, int queue_time_ms)
if (cmd->last_pid != 0) {
g_string_append_printf(str, ", PID %d", cmd->last_pid);
}
if (cmd->result.execution_status == PCMK_EXEC_DONE) {
g_string_append_printf(str, ") exited with status %d",
cmd->result.exit_status);
} else {
pcmk__g_strcat(str, ") could not be executed: ",
pcmk_exec_status_str(cmd->result.execution_status),
NULL);
switch (cmd->result.execution_status) {
case PCMK_EXEC_DONE:
g_string_append_printf(str, ") exited with status %d",
cmd->result.exit_status);
break;
case PCMK_EXEC_CANCELLED:
g_string_append_printf(str, ") cancelled");
break;
default:
pcmk__g_strcat(str, ") could not be executed: ",
pcmk_exec_status_str(cmd->result.execution_status),
NULL);
break;
}
if (cmd->result.exit_reason != NULL) {
pcmk__g_strcat(str, " (", cmd->result.exit_reason, ")", NULL);
Expand Down
8 changes: 8 additions & 0 deletions etc/sysconfig/pacemaker.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
# debug
#
# Default: PCMK_logpriority="notice"
# Warning: Debug logs may show sensitive configuration values.

# PCMK_logfile
#
Expand Down Expand Up @@ -80,6 +81,7 @@
#
# Default: PCMK_debug="no"
# Example: PCMK_debug="pacemakerd,pacemaker-execd"
# Warning: Debug logs may show sensitive configuration values.

# PCMK_stderr (Advanced Use Only)
#
Expand All @@ -99,6 +101,7 @@
#
# Default: PCMK_trace_functions=""
# Example: PCMK_trace_functions="unpack_colocation_set,pcmk__cmp_instance"
# Warning: Trace logs may show sensitive configuration values.

# PCMK_trace_files (Advanced Use Only)
#
Expand All @@ -107,6 +110,7 @@
#
# Default: PCMK_trace_files=""
# Example: PCMK_trace_files="remote.c,watchdog.c"
# Warning: Trace logs may show sensitive configuration values.

# PCMK_trace_formats (Advanced Use Only)
#
Expand All @@ -115,6 +119,7 @@
#
# Default: PCMK_trace_formats=""
# Example: PCMK_trace_formats="TLS handshake failed: %s (%d)"
# Warning: Trace logs may show sensitive configuration values.

# PCMK_trace_tags (Advanced Use Only)
#
Expand All @@ -123,6 +128,7 @@
#
# Default: PCMK_trace_tags=""
# Example: PCMK_trace_tags="client-ip,dbfs"
# Warning: Trace logs may show sensitive configuration values.

# PCMK_blackbox (Advanced Use Only)
#
Expand All @@ -138,6 +144,7 @@
#
# Default: PCMK_blackbox="no"
# Example: PCMK_blackbox="pacemaker-controld,pacemaker-fenced"
# Warning: Blackboxes may contain sensitive configuration values.

# PCMK_trace_blackbox (Advanced Use Only)
#
Expand All @@ -146,6 +153,7 @@
#
# Default: PCMK_trace_blackbox=""
# Example: PCMK_trace_blackbox="remote.c:144,remote.c:149"
# Warning: Blackboxes may contain sensitive configuration values.


## Option overrides
Expand Down
22 changes: 10 additions & 12 deletions include/crm/common/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <unistd.h> // pid_t, getpid()
#include <stdbool.h> // bool
#include <stdint.h> // uint8_t, uint64_t
#include <inttypes.h> // PRIu64

#include <glib.h> // guint, GList, GHashTable
#include <libxml/tree.h> // xmlNode
Expand Down Expand Up @@ -145,12 +146,10 @@ pcmk__set_flags_as(const char *function, int line, uint8_t log_level,

if (result != flag_group) {
do_crm_log_unlikely(log_level,
"%s flags %#.8llx (%s) for %s set by %s:%d",
((flag_type == NULL)? "Group of" : flag_type),
(unsigned long long) flags,
((flags_str == NULL)? "flags" : flags_str),
((target == NULL)? "target" : target),
function, line);
"%s flags %#.8" PRIx64 " (%s) for %s set by %s:%d",
pcmk__s(flag_type, "Group of"), flags,
pcmk__s(flags_str, "flags"),
pcmk__s(target, "target"), function, line);
}
return result;
}
Expand Down Expand Up @@ -179,12 +178,11 @@ pcmk__clear_flags_as(const char *function, int line, uint8_t log_level,

if (result != flag_group) {
do_crm_log_unlikely(log_level,
"%s flags %#.8llx (%s) for %s cleared by %s:%d",
((flag_type == NULL)? "Group of" : flag_type),
(unsigned long long) flags,
((flags_str == NULL)? "flags" : flags_str),
((target == NULL)? "target" : target),
function, line);
"%s flags %#.8" PRIx64
" (%s) for %s cleared by %s:%d",
pcmk__s(flag_type, "Group of"), flags,
pcmk__s(flags_str, "flags"),
pcmk__s(target, "target"), function, line);
}
return result;
}
Expand Down
28 changes: 14 additions & 14 deletions lib/common/xpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,21 @@ getXpathResult(xmlXPathObjectPtr xpathObj, int index)
xpathObj->nodesetval->nodeTab[index] = NULL;
}

if (match->type == XML_DOCUMENT_NODE) {
/* Will happen if section = '/' */
match = match->children;

} else if (match->type != XML_ELEMENT_NODE
&& match->parent && match->parent->type == XML_ELEMENT_NODE) {
/* Return the parent instead */
match = match->parent;

} else if (match->type != XML_ELEMENT_NODE) {
/* We only support searching nodes */
crm_err("We only support %d not %d", XML_ELEMENT_NODE, match->type);
match = NULL;
switch (match->type) {
case XML_ELEMENT_NODE:
return match;

case XML_DOCUMENT_NODE: // Searched for '/'
return match->children;

default:
if ((match->parent != NULL)
&& (match->parent->type == XML_ELEMENT_NODE)) {
return match->parent;
}
crm_warn("Unsupported XPath match type %d (bug?)", match->type);
return NULL;
}
return match;
}

void
Expand Down
5 changes: 5 additions & 0 deletions lib/pacemaker/pcmk_sched_utilization.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@ pcmk__show_node_capacities(const char *desc, pcmk_scheduler_t *scheduler)
const pcmk_node_t *node = (const pcmk_node_t *) iter->data;
pcmk__output_t *out = scheduler->priv->out;

// Utilization doesn't apply to bundle nodes
if (pcmk__is_bundle_node(node)) {
continue;
}

out->message(out, "node-capacity", node, desc);
}
}
14 changes: 8 additions & 6 deletions lib/pengine/pe_digest.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,15 @@ rsc_action_digest_cmp(pcmk_resource_t *rsc, const xmlNode *xml_op,
pcmk__sched_sanitized),
scheduler);

if (digest_restart && data->digest_restart_calc && strcmp(data->digest_restart_calc, digest_restart) != 0) {
if (!pcmk__str_eq(data->digest_restart_calc, digest_restart,
pcmk__str_null_matches)) {
pcmk__rsc_info(rsc,
"Parameters to %ums-interval %s action for %s on %s "
"changed: hash was %s vs. now %s (restart:%s) %s",
interval_ms, task, rsc->id, pcmk__node_name(node),
pcmk__s(digest_restart, "missing"),
data->digest_restart_calc, op_version,
"Parameter change for %s-interval %s of %s on %s "
"requires restart (hash now %s vs. %s "
"with op feature set %s for transition %s)",
pcmk__readable_interval(interval_ms), task, rsc->id,
pcmk__node_name(node), data->digest_restart_calc,
pcmk__s(digest_restart, "missing"), op_version,
crm_element_value(xml_op, PCMK__XA_TRANSITION_MAGIC));
data->rc = pcmk__digest_restart;

Expand Down
5 changes: 5 additions & 0 deletions lib/pengine/pe_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,11 @@ cluster_options_html(pcmk__output_t *out, va_list args) {
}

switch (scheduler->no_quorum_policy) {
/* @COMPAT These should say something like "resources that require
* quorum" since resources with requires="nothing" are unaffected, but
* it would be a good idea to investigate whether any major projects
* search for this text first
*/
case pcmk_no_quorum_freeze:
out->list_item(out, NULL, "No quorum policy: Freeze resources");
break;
Expand Down
6 changes: 4 additions & 2 deletions lib/pengine/unpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,12 @@ unpack_config(xmlNode *config, pcmk_scheduler_t *scheduler)

switch (scheduler->no_quorum_policy) {
case pcmk_no_quorum_freeze:
crm_debug("On loss of quorum: Freeze resources");
crm_debug("On loss of quorum: "
"Freeze resources that require quorum");
break;
case pcmk_no_quorum_stop:
crm_debug("On loss of quorum: Stop ALL resources");
crm_debug("On loss of quorum: "
"Stop resources that require quorum");
break;
case pcmk_no_quorum_demote:
crm_debug("On loss of quorum: "
Expand Down
3 changes: 2 additions & 1 deletion python/pacemaker/_cts/corosync.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def generate_corosync_cfg(logdir, cluster_name, node_name):

if corosync_cfg_exists():
# pylint: disable=consider-using-with
f = tempfile.NamedTemporaryFile(delete=True)
config_dir = os.path.dirname(BuildOptions.COROSYNC_CONFIG_FILE)
f = tempfile.NamedTemporaryFile(dir=config_dir, prefix="corosync.conf-")
f.close()
shutil.move(BuildOptions.COROSYNC_CONFIG_FILE, f.name)

Expand Down