From 56cc6c85ad3812bbc2651ca2095d6b4b6c420ccb Mon Sep 17 00:00:00 2001 From: Andrew Lewis Date: Wed, 16 Nov 2016 13:24:44 +0200 Subject: [PATCH] [Minor] Fix upstreams handling --- src/plugins/lua/asn.lua | 7 +++---- src/plugins/lua/fann_classifier.lua | 9 +++------ src/plugins/lua/greylist.lua | 10 +++------- src/plugins/lua/ip_score.lua | 6 ++---- src/plugins/lua/metadata_exporter.lua | 3 +-- src/plugins/lua/mx_check.lua | 6 ++---- src/plugins/lua/ratelimit.lua | 9 +++------ 7 files changed, 17 insertions(+), 33 deletions(-) diff --git a/src/plugins/lua/asn.lua b/src/plugins/lua/asn.lua index 91b5cc874..d7afa2507 100644 --- a/src/plugins/lua/asn.lua +++ b/src/plugins/lua/asn.lua @@ -71,7 +71,7 @@ local function asn_check(task) if not redis_err then upstream:ok() else - rspamd_logger.infox(task, 'got error %s when setting asn record on server %s', + rspamd_logger.errx(task, 'got error %s when setting asn record on server %s', redis_err, upstream:get_addr()) upstream:fail() end @@ -89,8 +89,7 @@ local function asn_check(task) redis_key, tostring(options['expire']) }) else - rspamd_logger.infox(task, 'got error while connecting to redis: %1', upstream:get_addr()) - upstream:fail() + rspamd_logger.err(task, 'got error while connecting to redis') end end end @@ -126,7 +125,7 @@ local function asn_check(task) {key, tostring(options.expire)} -- arguments ) if not ret then - upstream:fail() + rspamd_logger.err('got error connecting to redis') end end end diff --git a/src/plugins/lua/fann_classifier.lua b/src/plugins/lua/fann_classifier.lua index ca6fb2026..3b360d9a0 100644 --- a/src/plugins/lua/fann_classifier.lua +++ b/src/plugins/lua/fann_classifier.lua @@ -89,8 +89,7 @@ local function maybe_load_fann(task, continue_cb, call_if_fail) {key, 'version', 'data', 'spam', 'ham'} -- arguments ) if not ret then - rspamd_logger.errx(task, 'redis error on host %s', upstream:get_addr()) - upstream:fail() + rspamd_logger.err(task, 'got error connecting to redis') end end @@ -124,8 +123,7 @@ local function maybe_load_fann(task, continue_cb, call_if_fail) {key, 'version'} -- arguments ) if not ret then - rspamd_logger.errx(task, 'redis error on host %s', upstream:get_addr()) - upstream:fail() + rspamd_logger.err(task, 'got error connecting to redis') end end @@ -227,8 +225,7 @@ local function save_fann(task, is_spam) conn:add_cmd('HINCRBY', {key, 'ham', 1}) end else - rspamd_logger.errx(task, 'redis error on host %s: %s', upstream:get_addr()) - upstream:fail() + rspamd_logger.err(task, 'got error connecting to redis') end end diff --git a/src/plugins/lua/greylist.lua b/src/plugins/lua/greylist.lua index 354c2b3d2..36819e1d0 100644 --- a/src/plugins/lua/greylist.lua +++ b/src/plugins/lua/greylist.lua @@ -225,8 +225,7 @@ local function greylist_check(task) {body_key, meta_key} -- arguments ) if not ret then - rspamd_logger.errx(task, 'cannot make redis request to check results') - upstream:fail() + rspamd_logger.err(task, 'cannot make redis request to check results') end end @@ -304,8 +303,7 @@ local function greylist_set(task) meta_key, tostring(settings['expire']) }) else - rspamd_logger.infox(task, 'got error while connecting to redis: %1', upstream:get_addr()) - upstream:fail() + rspamd_logger.err(task, 'got error while connecting to redis') end elseif do_greylisting or do_greylisting_required then local t = tostring(math.floor(rspamd_util.get_time())) @@ -329,9 +327,7 @@ local function greylist_set(task) meta_key, tostring(settings['expire']), t }) else - rspamd_logger.infox(task, 'got error while connecting to redis: %s', - upstream:get_addr()) - upstream:fail() + rspamd_logger.err(task, 'got error while connecting to redis') end else if action ~= 'no action' and action ~= 'reject' then diff --git a/src/plugins/lua/ip_score.lua b/src/plugins/lua/ip_score.lua index d8f61f511..ffffb22b1 100644 --- a/src/plugins/lua/ip_score.lua +++ b/src/plugins/lua/ip_score.lua @@ -166,8 +166,7 @@ local ip_score_set = function(task) redis_args -- arguments ) if not ret then - rspamd_logger.errx(task, 'Redis HMSET failed on %s', upstream:get_addr()) - upstream:fail() + rspamd_logger.err(task, 'error connecting to redis') return end @@ -320,8 +319,7 @@ local ip_score_check = function(task) args -- arguments ) if not ret then - rspamd_logger.errx(task, 'Call to redis at %s failed', upstream:get_addr()) - upstream:fail() + rspamd_logger.err(task, 'error connecting to redis') end end end diff --git a/src/plugins/lua/metadata_exporter.lua b/src/plugins/lua/metadata_exporter.lua index 70c10e6b7..d2c0fa620 100644 --- a/src/plugins/lua/metadata_exporter.lua +++ b/src/plugins/lua/metadata_exporter.lua @@ -93,8 +93,7 @@ local function metadata_exporter(task) {channel, data} -- arguments ) if not ret then - rspamd_logger.errx(task, 'Redis PUBLISH failed') - upstream:fail() + rspamd_logger.err(task, 'error connecting to redis') end end if url then diff --git a/src/plugins/lua/mx_check.lua b/src/plugins/lua/mx_check.lua index fbf68d6d7..f5a44bc4e 100644 --- a/src/plugins/lua/mx_check.lua +++ b/src/plugins/lua/mx_check.lua @@ -90,8 +90,7 @@ local function mx_check(task) {key, tostring(settings.expire_novalid), '0'} -- arguments ) if not ret then - rspamd_logger.errx(task, 'Redis SETEX failed') - upstream:fail() + rspamd_logger.err(task, 'got error connecting to redis') end else local valid_mx = {} @@ -108,8 +107,7 @@ local function mx_check(task) {key, tostring(settings.expire), table.concat(valid_mx, ';')} -- arguments ) if not ret then - rspamd_logger.errx(task, 'Redis SETEX failed') - upstream:fail() + rspamd_logger.err(task, 'error connecting to redis') end end end diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua index 92d80fe32..f15d8633e 100644 --- a/src/plugins/lua/ratelimit.lua +++ b/src/plugins/lua/ratelimit.lua @@ -308,8 +308,7 @@ local function check_limits(task, args) fun.totable(fun.map(function(l) return l[2] end, args)) -- arguments ) if not ret then - rspamd_logger.errx(task, 'Redis MGET failed on %s', upstream:get_addr()) - upstream:fail() + rspamd_logger.err(task, 'got error connecting to redis') end end @@ -378,8 +377,7 @@ local function set_limits(task, args) conn:add_cmd('setex', v) end, fun.drop_n(1, values)) else - rspamd_logger.infox(task, 'got error while connecting to redis: %1', upstream:get_addr()) - upstream:fail() + rspamd_logger.err(task, 'got error while connecting to redis') end end end @@ -394,8 +392,7 @@ local function set_limits(task, args) fun.totable(fun.map(function(l) return l[2] end, args)) -- arguments ) if not ret then - rspamd_logger.errx(task, 'Redis MGET failed on %s', upstream:get_addr()) - upstream:fail() + rspamd_logger.err(task, 'got error connecting to redis') end end -- 2.39.5