From mboxrd@z Thu Jan 1 00:00:00 1970 From: fabbione@sourceware.org Date: 23 Jun 2008 12:01:52 -0000 Subject: [Cluster-devel] Cluster Project branch, master, updated. cluster-2.99.04-57-g0b8bd69 Message-ID: <20080623120152.28626.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Cluster Project". http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=0b8bd69b8f6a393958229551396057ac44ca5391 The branch, master has been updated via 0b8bd69b8f6a393958229551396057ac44ca5391 (commit) via 4d6472e59640d2594c5d9101b1ca7cc6ee1c952e (commit) via 8b317c5b251513a0825d8c0ccd85aa7b246a5b19 (commit) from 06be5b42ff670cbb9177a72c9ac43ac10caa8d7d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0b8bd69b8f6a393958229551396057ac44ca5391 Author: Fabio M. Di Nitto Date: Mon Jun 23 13:59:56 2008 +0200 [QDISK] Port qdisk to the new logsys config interface NOTE: this commit also retain backward compatibility with the old logging config options but warns the users that they are depracated. Signed-off-by: Fabio M. Di Nitto commit 4d6472e59640d2594c5d9101b1ca7cc6ee1c952e Author: Fabio M. Di Nitto Date: Mon Jun 23 13:34:18 2008 +0200 [CCS] Fix debug override from command line vs config Signed-off-by: Fabio M. Di Nitto commit 8b317c5b251513a0825d8c0ccd85aa7b246a5b19 Author: Fabio M. Di Nitto Date: Mon Jun 23 11:38:32 2008 +0200 [CCS] Always check for debug setting as first thing This allow us to enable and read debugging output as soon as possible. Signed-off-by: Fabio M. Di Nitto ----------------------------------------------------------------------- Summary of changes: ccs/daemon/misc.c | 92 ++++++++++++------------ cman/qdisk/main.c | 199 ++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 213 insertions(+), 78 deletions(-) diff --git a/ccs/daemon/misc.c b/ccs/daemon/misc.c index 5ba999f..acab5c8 100644 --- a/ccs/daemon/misc.c +++ b/ccs/daemon/misc.c @@ -166,6 +166,52 @@ int set_ccs_logging(xmlDocPtr ldoc){ logmode = logsys_config_mode_get(); + res = do_simple_xml_query(ctx, "/cluster/logging/@debug"); + if(res) { + if(!strcmp(res, "on")) { + global_debug = 1; + } else + if(!strcmp(res, "off")) { + global_debug = 0; + } else + log_printf(LOG_ERR, "global debug: unknown value\n"); + free(res); + res=NULL; + } + + res = do_simple_xml_query(ctx, "/cluster/logging/logger_subsys[@subsys=\"CCS\"]/@debug"); + if(res) { + if(!debug) { + if(!strcmp(res, "on")) { + debug = 1; + } else + if(!strcmp(res, "off")) { /* debug from cmdline/envvars override config */ + debug = 0; + } else + log_printf(LOG_ERR, "subsys debug: unknown value\n"); + } + free(res); + res=NULL; + } else + debug = global_debug; /* global debug overrides subsystem only if latter is not specified */ + + if(debug) + logsys_config_priority_set (LOG_LEVEL_DEBUG); + + res = do_simple_xml_query(ctx, "/cluster/logging/logger_subsys[@subsys=\"CCS\"]/@syslog_level"); + if(res) { + loglevel = logsys_priority_id_get (res); + if (loglevel < 0) + loglevel = LOG_LEVEL_INFO; + + if (!debug) + logsys_config_priority_set (loglevel); + + log_printf(LOG_DEBUG, "syslog_level: %s (%d).\n", res, loglevel); + free(res); + res=NULL; + } + res = do_simple_xml_query(ctx, "/cluster/logging/@to_stderr"); if(res) { if(!strcmp(res, "yes")) { @@ -228,52 +274,6 @@ int set_ccs_logging(xmlDocPtr ldoc){ res=NULL; } - res = do_simple_xml_query(ctx, "/cluster/logging/@debug"); - if(res) { - if(!strcmp(res, "on")) { - global_debug = 1; - } else - if(!strcmp(res, "off")) { - global_debug = 0; - } else - log_printf(LOG_ERR, "debug: unknown value\n"); - free(res); - res=NULL; - } - - /* subsytem config */ - - res = do_simple_xml_query(ctx, "/cluster/logging/logger_subsys[@subsys=\"CCS\"]/@debug"); - if(res) { - if(!strcmp(res, "on")) { - debug = 1; - } else - if(!strcmp(res, "off") && !debug) { /* debug from cmdline/envvars override config */ - debug = 0; - } else - log_printf(LOG_ERR, "debug: unknown value\n"); - free(res); - res=NULL; - } else - debug = global_debug; /* global debug overrides subsystem only if latter is not specified */ - - if(debug) - logsys_config_priority_set (LOG_LEVEL_DEBUG); - - res = do_simple_xml_query(ctx, "/cluster/logging/logger_subsys[@subsys=\"CCS\"]/@syslog_level"); - if(res) { - loglevel = logsys_priority_id_get (res); - if (loglevel < 0) - loglevel = LOG_LEVEL_INFO; - - if (!debug) - logsys_config_priority_set (loglevel); - - log_printf(LOG_DEBUG, "syslog_level: %s (%d).\n", res, loglevel); - free(res); - res=NULL; - } - if(ctx){ xmlXPathFreeContext(ctx); } diff --git a/cman/qdisk/main.c b/cman/qdisk/main.c index 1f1d082..466609a 100644 --- a/cman/qdisk/main.c +++ b/cman/qdisk/main.c @@ -1057,18 +1057,176 @@ quorum_logout(qd_ctx *ctx) /** - Grab all our configuration data from CCSD + Grab logsys configuration data from libccs + */ +static int +get_logsys_config_data(int *debug) +{ + int ccsfd = -1, loglevel = LOG_LEVEL_INFO, facility = SYSLOGFACILITY; + char *val = NULL, *error = NULL; + unsigned int logmode; + int global_debug = 0; + + log_printf(LOG_DEBUG, "Loading logsys configuration information\n"); + + ccsfd = ccs_connect(); + if (ccsfd < 0) { + log_printf(LOG_CRIT, "Connection to CCSD failed; cannot start\n"); + return -1; + } + + logmode = logsys_config_mode_get(); + + if (ccs_get(ccsfd, "/cluster/logging/@debug", &val) == 0) { + if(!strcmp(val, "on")) { + global_debug = 1; + } else + if(!strcmp(val, "off")) { + global_debug = 0; + } else + log_printf(LOG_ERR, "global debug: unknown value\n"); + free(val); + val = NULL; + } + + if (ccs_get(ccsfd, "/cluster/logging/logger_subsys[@subsys=\"QDISK\"]/@debug", &val) == 0) { + if(!*debug) { + if(!strcmp(val, "on")) { + *debug = 1; + } else + if(!strcmp(val, "off") && !*debug) { /* debug from cmdline/envvars override config */ + *debug = 0; + } else + log_printf(LOG_ERR, "subsys debug: unknown value: %s\n", val); + free(val); + val = NULL; + } + } else + *debug = global_debug; /* global debug overrides subsystem only if latter is not specified */ + + if (ccs_get(ccsfd, "/cluster/logging/logger_subsys[@subsys=\"QDISK\"]/@syslog_level", &val) == 0) { + loglevel = logsys_priority_id_get (val); + if (loglevel < 0) + loglevel = LOG_LEVEL_INFO; + + if (!*debug) { + *debug = 1; + logsys_config_priority_set (loglevel); + } + + free(val); + } else + if (ccs_get(ccsfd, "/cluster/quorumd/@log_level", &val) == 0) { /* check backward compat options */ + loglevel = logsys_priority_id_get (val); + if (loglevel < 0) + loglevel = LOG_LEVEL_INFO; + + log_printf(LOG_ERR, "qc_sched = SCHED_RR; ctx->qc_sched_prio = 1; - /* Get log log_facility */ - snprintf(query, sizeof(query), "/cluster/quorumd/@log_facility"); - if (ccs_get(ccsfd, query, &val) == 0) { - int facility; - - facility = logsys_facility_id_get (val); - if (facility < 0) - facility = SYSLOGFACILITY; - - logsys_config_facility_set ("QDISK", facility); - log_printf(LOG_DEBUG, "Log facility: %s (%d)\n", val, facility); - free(val); - } - - /* Get log level */ - snprintf(query, sizeof(query), "/cluster/quorumd/@log_level"); - if (ccs_get(ccsfd, query, &val) == 0) { - loglevel = atoi(val); - free(val); - if (loglevel < 0) - loglevel = LOG_LEVEL_INFO; - - if (!debug) - logsys_config_priority_set (loglevel); - } - /* Get interval */ snprintf(query, sizeof(query), "/cluster/quorumd/@interval"); if (ccs_get(ccsfd, query, &val) == 0) { @@ -1356,7 +1488,7 @@ main(int argc, char **argv) cman_handle_t ch = NULL; node_info_t ni[MAX_NODES_DISK]; struct h_data h[10]; - int debug = 0, foreground = 0; + int debug = 0, foreground = 0, trylater = 0; char device[128]; pid_t pid; quorum_header_t qh; @@ -1396,7 +1528,10 @@ main(int argc, char **argv) if(debug) logsys_config_priority_set (LOG_LEVEL_DEBUG); - logsys_config_mode_set (LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_OUTPUT_FILE | LOG_MODE_FLUSH_AFTER_CONFIG); + trylater = get_logsys_config_data(&debug); + + if (trylater) + logsys_config_mode_set (LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_OUTPUT_FILE | LOG_MODE_FLUSH_AFTER_CONFIG); #if (defined(LIBCMAN_VERSION) && LIBCMAN_VERSION >= 2) ch = cman_admin_init(NULL); @@ -1439,7 +1574,7 @@ main(int argc, char **argv) signal(SIGINT, int_handler); signal(SIGTERM, int_handler); - if (get_config_data(&ctx, h, 10, &cfh, debug) < 0) { + if (get_config_data(&ctx, h, 10, &cfh, debug, trylater) < 0) { log_printf(LOG_CRIT, "Configuration failed\n"); check_stop_cman(&ctx); goto out; hooks/post-receive -- Cluster Project