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

Improve logging messages and levels #151

Merged
merged 7 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ native/*/Makefile
native/*/autom4te.cache/
native/*/config.status
native/*/configure
native/*/configure~
rhusar marked this conversation as resolved.
Show resolved Hide resolved

# Native testsuite
bin/
Expand All @@ -36,5 +37,13 @@ test/httpd/mod_proxy_cluster
# Log files
**/*.log

# test nohup files
# test files
**/nohup.out
test/MODCLUSTER-640/mod_proxy_cluster_new.conf
test/dependency-reduced-pom.xml
test/mod_proxy_cluster_new.conf
test/new.xml
test/server.xml

# patch files
**/*.patch
19 changes: 10 additions & 9 deletions native/advertise/mod_advertise.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,9 @@ static apr_status_t ma_group_join(const char *addr, apr_port_t port, const char
return rv;
}
if ((rv = apr_mcast_join(ma_mgroup_socket, ma_mgroup_sa, ma_niface_sa, NULL)) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, s, "mod_advertise: ma_group_join apr_mcast_join failed");
ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, "mod_advertise: ma_group_join apr_mcast_join failed");
if ((rv = apr_mcast_loopback(ma_mgroup_socket, 1)) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_WARNING, rv, s, "mod_advertise: ma_group_join apr_mcast_loopback failed");
ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, "mod_advertise: ma_group_join apr_mcast_loopback failed");
apr_socket_close(ma_mgroup_socket);
return rv;
}
Expand Down Expand Up @@ -581,8 +581,8 @@ static int post_config_hook(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *pte
if (ppid) {
ma_parent_pid = atol(ppid);
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
"[%" APR_PID_T_FMT " - %" APR_PID_T_FMT "] in child post config hook", getpid(),
ma_parent_pid);
"post_config_hook: [%" APR_PID_T_FMT " - %" APR_PID_T_FMT "] in child post config hook",
getpid(), ma_parent_pid);
return OK;
}
}
Expand All @@ -608,7 +608,7 @@ static int post_config_hook(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *pte
rv = ma_group_join(mconf->ma_advertise_adrs, mconf->ma_advertise_port, mconf->ma_bind_adrs, mconf->ma_bind_port,
pconf, s);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, "mod_advertise: multicast join failed for %s:%d.",
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, "post_config_hook: multicast join failed for %s:%d.",
mconf->ma_advertise_adrs, mconf->ma_advertise_port);
ma_advertise_run = 0;
} else {
Expand Down Expand Up @@ -651,23 +651,23 @@ static int post_config_hook(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *pte
rv = apr_parse_addr_port(&mconf->ma_advertise_srvs, &mconf->ma_advertise_srvi, &mconf->ma_advertise_srvp, ptr,
pproc);
if (rv != APR_SUCCESS || !mconf->ma_advertise_srvs || !mconf->ma_advertise_srvp) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, "mod_advertise: Invalid ServerAdvertise Address %s", ptr);
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, "post_config_hook: Invalid ServerAdvertise Address %s", ptr);
return rv;
}
}

/* prevent X-Manager-Address: (null):0 */
if (!mconf->ma_advertise_srvs || !mconf->ma_advertise_srvp) {
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, s,
"mod_advertise: ServerAdvertise Address or Port not defined, Advertise disabled!!!");
"post_config_hook: ServerAdvertise Address or Port not defined, Advertise disabled!!!");
return OK;
}

/* Create parent management thread */
is_mp_running = 1;
rv = apr_thread_create(&tp, NULL, parent_thread, server, pconf);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, "mod_advertise: parent apr_thread_create");
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, "post_config_hook: parent apr_thread_create");
return rv;
}
apr_thread_detach(tp);
Expand All @@ -678,7 +678,8 @@ static int post_config_hook(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *pte
apr_pool_create(&magd->cpool, pconf);
apr_pool_cleanup_register(magd->cpool, magd, pconfig_cleanup, apr_pool_cleanup_null);

ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s, "Advertise initialized for process %" APR_PID_T_FMT, getpid());
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s, "post_config_hook: Advertise initialized for process %" APR_PID_T_FMT,
getpid());

apr_pool_cleanup_register(magd->ppool, magd, process_cleanup, apr_pool_cleanup_null);

Expand Down
37 changes: 17 additions & 20 deletions native/balancers/mod_lbmethod_cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,10 @@ static int lbmethod_cluster_trans(request_rec *r)


#if HAVE_CLUSTER_EX_DEBUG
ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r->server,
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"lbmethod_cluster_trans for %d %s %s uri: %s args: %s unparsed_uri: %s", r->proxyreq, r->filename,
r->handler, r->uri, r->args, r->unparsed_uri);
ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r->server, "lbmethod_cluster_trans for %d",
conf->balancers->nelts);
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "lbmethod_cluster_trans for %d", conf->balancers->nelts);
#endif

proxy_vhost_table *vhost_table = read_vhost_table(r->pool, host_storage, 0);
Expand Down Expand Up @@ -219,15 +218,15 @@ static int lbmethod_cluster_trans(request_rec *r)
r->handler = "proxy-server";
r->proxyreq = PROXYREQ_REVERSE;
#if HAVE_CLUSTER_EX_DEBUG
ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r->server, "proxy_cluster_trans using %s uri: %s",
balancer, r->filename);
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "proxy_cluster_trans using %s uri: %s", balancer,
r->filename);
#endif
return OK; /* Mod_proxy will process it */
}

#if HAVE_CLUSTER_EX_DEBUG
ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r->server,
"proxy_cluster_trans DECLINED %s uri: %s unparsed_uri: %s", balancer, r->filename, r->unparsed_uri);
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "proxy_cluster_trans DECLINED %s uri: %s unparsed_uri: %s",
balancer, r->filename, r->unparsed_uri);
#endif
return DECLINED;
}
Expand Down Expand Up @@ -361,32 +360,27 @@ static int lbmethod_cluster_post_config(apr_pool_t *p, apr_pool_t *plog, apr_poo

node_storage = ap_lookup_provider("manager", "shared", "0");
if (node_storage == NULL) {
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, s,
"proxy_cluster_post_config: Can't find mod_manager for nodes");
ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, "proxy_cluster_post_config: Can't find mod_manager for nodes");
return !OK;
}
host_storage = ap_lookup_provider("manager", "shared", "1");
if (host_storage == NULL) {
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, s,
"proxy_cluster_post_config: Can't find mod_manager for hosts");
ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, "proxy_cluster_post_config: Can't find mod_manager for hosts");
return !OK;
}
context_storage = ap_lookup_provider("manager", "shared", "2");
if (context_storage == NULL) {
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, s,
"proxy_cluster_post_config: Can't find mod_manager for contexts");
ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, "proxy_cluster_post_config: Can't find mod_manager for contexts");
return !OK;
}
balancer_storage = ap_lookup_provider("manager", "shared", "3");
if (balancer_storage == NULL) {
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, s,
"proxy_cluster_post_config: Can't find mod_manager for balancers");
ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, "proxy_cluster_post_config: Can't find mod_manager for balancers");
return !OK;
}
domain_storage = ap_lookup_provider("manager", "shared", "5");
if (domain_storage == NULL) {
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, s,
"proxy_cluster_post_config: Can't find mod_manager for domains");
ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, "proxy_cluster_post_config: Can't find mod_manager for domains");
return !OK;
}

Expand All @@ -401,17 +395,20 @@ static int lbmethod_cluster_post_config(apr_pool_t *p, apr_pool_t *plog, apr_poo
mc_watchdog_get_instance = APR_RETRIEVE_OPTIONAL_FN(ap_watchdog_get_instance);
mc_watchdog_register_callback = APR_RETRIEVE_OPTIONAL_FN(ap_watchdog_register_callback);
if (!mc_watchdog_get_instance || !mc_watchdog_register_callback) {
ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s, APLOGNO(03262) "mod_watchdog is required");
ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s,
APLOGNO(03262) "proxy_cluster_post_config: mod_watchdog is required");
return !OK;
}
if (mc_watchdog_get_instance(&watchdog, LB_CLUSTER_WATHCHDOG_NAME, 0, 1, p)) {
ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s, APLOGNO(03263) "Failed to create watchdog instance (%s)",
ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s,
APLOGNO(03263) "proxy_cluster_post_config: Failed to create watchdog instance (%s)",
LB_CLUSTER_WATHCHDOG_NAME);
return !OK;
}
while (s) {
if (mc_watchdog_register_callback(watchdog, AP_WD_TM_SLICE, s, mc_watchdog_callback)) {
ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s, APLOGNO(03264) "Failed to register watchdog callback (%s)",
ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s,
APLOGNO(03264) "proxy_cluster_post_config: Failed to register watchdog callback (%s)",
LB_CLUSTER_WATHCHDOG_NAME);
return !OK;
}
Expand Down
Loading