Skip to content

Commit

Permalink
Log: don't use corosync logging settings
Browse files Browse the repository at this point in the history
The community consensus is that Pacemaker should not log to Corosync's log
file.
  • Loading branch information
kgaillot committed Feb 3, 2018
1 parent e979d21 commit b8075c8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 71 deletions.
65 changes: 0 additions & 65 deletions mcp/corosync.c
Expand Up @@ -164,9 +164,6 @@ mcp_read_config(void)
{
int rc = CS_OK;
int retries = 0;

const char *const_value = NULL;

cmap_handle_t local_handle;
uint64_t config = 0;

Expand Down Expand Up @@ -227,68 +224,6 @@ mcp_read_config(void)
free(debug_enabled);
}

/* If the user didn't explicitly configure a Pacemaker log file, check
* whether they configured a corosync log file, and use that.
*
* @TODO Maybe we should drop this, and just rely on the logging set up by
* crm_log_init(). That would be a significant user-visible change that
* would need to be publicized.
*/
if (daemon_option("logfile") == NULL) {
/* Check corosync */
char *logfile = NULL;
char *logfile_enabled = NULL;

get_config_opt(config, local_handle, "logging.to_logfile", &logfile_enabled, "on");
get_config_opt(config, local_handle, "logging.logfile", &logfile,
CRM_LOG_DIR "/pacemaker.log");

if (crm_is_true(logfile_enabled) == FALSE) {
crm_trace("File logging disabled in corosync");

} else if (crm_add_logfile(logfile)) {
set_daemon_option("logfile", logfile);

} else {
crm_err("Couldn't create logfile: %s", logfile);
set_daemon_option("logfile", "none");
}

free(logfile);
free(logfile_enabled);
}

if (daemon_option("logfacility")) {
/* Syslog logging is already setup by crm_log_init() */

} else {
/* Check corosync */
char *syslog_enabled = NULL;
char *syslog_facility = NULL;

get_config_opt(config, local_handle, "logging.to_syslog", &syslog_enabled, "on");
get_config_opt(config, local_handle, "logging.syslog_facility", &syslog_facility, "daemon");

if (crm_is_true(syslog_enabled) == FALSE) {
qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_ENABLED, QB_FALSE);
set_daemon_option("logfacility", "none");

} else {
qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_FACILITY, qb_log_facility2int(syslog_facility));
qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_ENABLED, QB_TRUE);
set_daemon_option("logfacility", syslog_facility);
}

free(syslog_enabled);
free(syslog_facility);
}

const_value = daemon_option("logfacility");
if (const_value) {
/* cluster-glue module needs HA_LOGFACILITY */
setenv("HA_LOGFACILITY", const_value, 1);
}

if(local_handle){
gid_t gid = 0;
if (crm_user_lookup(CRM_DAEMON_USER, NULL, &gid) < 0) {
Expand Down
13 changes: 9 additions & 4 deletions mcp/pacemaker.c
Expand Up @@ -899,7 +899,6 @@ main(int argc, char **argv)
struct rlimit cores;
crm_ipc_t *old_instance = NULL;
qb_ipcs_service_t *ipcs = NULL;
const char *facility = daemon_option("logfacility");
static crm_cluster_t cluster;

crm_log_preinit(NULL, argc, argv);
Expand Down Expand Up @@ -960,9 +959,6 @@ main(int argc, char **argv)

crm_log_init(NULL, LOG_INFO, TRUE, FALSE, argc, argv, FALSE);

/* Restore the original facility so that mcp_read_config() does the right thing */
set_daemon_option("logfacility", facility);

crm_debug("Checking for old instances of %s", CRM_SYSTEM_MCP);
old_instance = crm_ipc_new(CRM_SYSTEM_MCP, 0);
crm_ipc_connect(old_instance);
Expand Down Expand Up @@ -998,6 +994,15 @@ main(int argc, char **argv)
crm_exit(CRM_EX_UNAVAILABLE);
}

// OCF shell functions and cluster-glue need facility under different name
{
const char *facility = daemon_option("logfacility");

if (facility && safe_str_neq(facility, "none")) {
setenv("HA_LOGFACILITY", facility, 1);
}
}

crm_notice("Starting Pacemaker %s "CRM_XS" build=%s features:%s",
PACEMAKER_VERSION, BUILD_VERSION, CRM_FEATURES);
mainloop = g_main_new(FALSE);
Expand Down
3 changes: 1 addition & 2 deletions mcp/pacemaker.sysconfig
Expand Up @@ -9,8 +9,7 @@
# via syslog, messages in this file may have extended information, and will
# include messages of "info" severity (and, if debug and/or trace logging
# has been enabled, those as well). This log is of more use to developers and
# advanced system administrators, and when reporting problems. By default,
# Pacemaker will use the value of logfile in corosync.conf, if found.
# advanced system administrators, and when reporting problems.
# PCMK_logfile=/var/log/pacemaker/pacemaker.log

# Enable logging via syslog, using the specified syslog facility. Messages sent
Expand Down

0 comments on commit b8075c8

Please sign in to comment.