]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Refactor: Improve Redis server discovery for Bayes 5714/head
authorCursor Agent <cursoragent@cursor.com>
Wed, 29 Oct 2025 13:14:54 +0000 (13:14 +0000)
committerCursor Agent <cursoragent@cursor.com>
Wed, 29 Oct 2025 13:14:54 +0000 (13:14 +0000)
Co-authored-by: v <v@rspamd.com>
lualib/rspamadm/statistics_dump.lua
src/plugins/lua/bayes_expiry.lua

index 6a08d11fdef61d1df6940b9524b45e0edfb85966..e727c739f754296759fa08305851491a84171879 100644 (file)
@@ -150,16 +150,23 @@ local function check_redis_classifier(cls, cfg)
     end
 
     local redis_params
+    -- Try load from classifier config
     redis_params = lua_redis.try_load_redis_servers(cls,
         rspamd_config, false, 'bayes')
     if not redis_params then
+      -- Try load from statistics_dump module config
       redis_params = lua_redis.try_load_redis_servers(cfg[N] or E,
           rspamd_config, false, 'bayes')
       if not redis_params then
         redis_params = lua_redis.try_load_redis_servers(cfg[N] or E,
             rspamd_config, true)
         if not redis_params then
-          return false
+          -- Try load from global redis config
+          redis_params = lua_redis.try_load_redis_servers(rspamd_config:get_all_opt('redis'),
+              rspamd_config, true)
+          if not redis_params then
+            return false
+          end
         end
       end
     end
index 0d78f227250ce6cb309a66f3f7fce543522a10a3..69b0f93266fd35c7aaf250835e10a60432a73f46 100644 (file)
@@ -101,13 +101,21 @@ local function check_redis_classifier(cls, cfg)
     -- Now try to load redis_params if needed
 
     local redis_params
+    -- Try load from classifier config
     redis_params = lredis.try_load_redis_servers(cls, rspamd_config, false, 'bayes')
     if not redis_params then
+      -- Try load from bayes_expiry module config
       redis_params = lredis.try_load_redis_servers(cfg[N] or E, rspamd_config, false, 'bayes')
       if not redis_params then
         redis_params = lredis.try_load_redis_servers(cfg[N] or E, rspamd_config, true)
         if not redis_params then
-          return false
+          -- Try load from global redis config
+          redis_params = lredis.try_load_redis_servers(rspamd_config:get_all_opt('redis'), rspamd_config, true)
+          if not redis_params then
+            logger.debugm(N, rspamd_config,
+                'disable expiry for classifier: cannot load redis parameters')
+            return false
+          end
         end
       end
     end