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

Warning with redis storage: You're running Souin with the default storage that is not optimized and for development purpose #102

Closed
bgeneto opened this issue Sep 16, 2024 · 4 comments · Fixed by darkweak/souin#551

Comments

@bgeneto
Copy link

bgeneto commented Sep 16, 2024

I'm getting this warning message after having compiled the latest cache handler version, even though I'm using Redis storage (see Dockerfile below):

You're running Souin with the default storage that is not optimized and for development purpose.  
We recommend to use at least one of the storages from https://github.com/darkweak/storages

Here is the Dockerfile used to build the image...

FROM caddy:builder AS builder

RUN xcaddy build --with github.com/caddy-dns/duckdns \
                 --with github.com/caddy-dns/cloudflare \
                 --with github.com/darkweak/storages/redis/caddy \
                 --with github.com/caddyserver/cache-handler

FROM caddy

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

And below is the relevant global cache config in my Caddyfile:

{
        auto_https disable_redirects
        order cache before file_server
        order rewrite before file_server
        log {
                level warn
        }
        cache {
                default_cache_control public
                log_level error
                ttl 7200s
                stale 600s
                max_cacheable_body_bytes 2097152
                allowed_http_verbs GET HEAD POST
                redis {
                        url keydb:6379
                }
        }
}

[...]

        handle @somehost {
                cache
                root * /srv/app/somehost
                file_server
        }

It used to work previously, are there any breaking changes? TIA.

@darkweak
Copy link
Collaborator

Hello @bgeneto do you have some error logs above? If Souin/cache-handler fallbacks on the default storage, that's because it couldn't connect to the redis instance. Is your keydb reachable?

@bgeneto
Copy link
Author

bgeneto commented Sep 17, 2024

Hello @bgeneto do you have some error logs above?

Unfortunately there is no fallback log message. Only messages below. I'd tried hard to make it work...

{"level":"warn","ts":1726568026.1681597,"logger":"http.handlers.cache","msg":"You're running Souin
 with the default storage that is not optimized and for development purpose. We recommend to use at least one of the storages from https://github.com/darkweak/storages"}
{"level":"debug","ts":1726568026.1681979,"logger":"http.handlers.cache","msg":"Storer initialized: []types.Storer{(*storage.Default)(0xc0000e62e0)}."}
{"level":"debug","ts":1726568026.1682246,"logger":"http.handlers.cache","msg":"Surrogate storage initialized."}
{"level":"debug","ts":1726568026.1682472,"logger":"http.handlers.cache","msg":"Set Souin
 as Cache-Status name"}
{"level":"debug","ts":1726568026.16826,"logger":"http.handlers.cache","msg":"Enable GraphQL logic due to your custom HTTP verbs setup."}
{"level":"debug","ts":1726568026.168281,"logger":"http.handlers.cache","msg":"Allow 3 method(s). [GET HEAD POST]."}
{"level":"debug","ts":1726568026.1683073,"logger":"http.handlers.cache","msg":"The cache logic will run as : &{Strict:true Bypass_request:false Bypass_response:false}"}
{"level":"info","ts":1726568026.168325,"logger":"http.handlers.cache","msg":"Set backend timeout to 10s"}
{"level":"info","ts":1726568026.1683397,"logger":"http.handlers.cache","msg":"Set cache timeout to 10s"}
{"level":"info","ts":1726568026.1683526,"logger":"http.handlers.cache","msg":"Souin
 configuration is now loaded."}
{"level":"warn","ts":1726568026.175706,"logger":"http.handlers.cache","msg":"You're running Souin
 with the default storage that is not optimized and for development purpose. We recommend to use at least one of the storages from https://github.com/darkweak/storages"}
{"level":"debug","ts":1726568026.1757329,"logger":"http.handlers.cache","msg":"Storer initialized: []types.Storer{(*storage.Default)(0xc0000e62e0)}."}
{"level":"debug","ts":1726568026.1757607,"logger":"http.handlers.cache","msg":"Surrogate storage initialized."}
{"level":"debug","ts":1726568026.175776,"logger":"http.handlers.cache","msg":"Set Souin
 as Cache-Status name"}
{"level":"debug","ts":1726568026.1757874,"logger":"http.handlers.cache","msg":"Enable GraphQL logic due to your custom HTTP verbs setup."}
{"level":"debug","ts":1726568026.1758065,"logger":"http.handlers.cache","msg":"Allow 6 method(s). [GET HEAD PROPFIND GET HEAD POST]."}
{"level":"debug","ts":1726568026.175828,"logger":"http.handlers.cache","msg":"The cache logic will run as : &{Strict:true Bypass_request:false Bypass_response:false}"}
{"level":"info","ts":1726568026.1758401,"logger":"http.handlers.cache","msg":"Set backend timeout to 10s"}
{"level":"info","ts":1726568026.1758528,"logger":"http.handlers.cache","msg":"Set cache timeout to 10s"}
{"level":"info","ts":1726568026.1758654,"logger":"http.handlers.cache","msg":"Souin
 configuration is now loaded."}

If Souin/cache-handler fallbacks on the default storage, that's because it couldn't connect to the redis instance.

I don't know... I think that it is not falling back but not detecting the storage plug-in...

Is your keydb reachable?

Yes. It is...

❯ docker exec -it caddy ping keydb
PING keydb (172.24.0.2): 56 data bytes
64 bytes from 172.24.0.2: seq=0 ttl=64 time=0.139 ms
64 bytes from 172.24.0.2: seq=1 ttl=64 time=0.137 ms
64 bytes from 172.24.0.2: seq=2 ttl=64 time=0.136 ms

❯ docker exec -it caddy telnet keydb 6379
Connected to keydb

@bgeneto
Copy link
Author

bgeneto commented Sep 17, 2024

It follows a minimal Dockerfile, compose.yaml and Caddyfile to test...
just run something like docker compose up -d and then docker logs <container_id> to check the issue.

https://drive.google.com/file/d/1tFvsq_rxU5aav6ViR-38-693kWAOl3yw/view?usp=sharing

Thanks for your help!

@darkweak
Copy link
Collaborator

@bgeneto I found the bug

The check about the storages to use and the generated Uuid to identify redis weren't good.
This enables souin-client as default client name according to the go-redis expectations https://github.com/darkweak/souin/pull/551/files#diff-b6c42537d079f776a1500f1dcc8333e78f34e9bfec8d9e6817994dcb9a480228
This function https://github.com/darkweak/souin/pull/551/files#diff-e1704a111d38befa7770754690d6c92b01e974385878b10fc285f9dd6d279868R119-R122 centralize the check for each available storage.
This line https://github.com/darkweak/souin/pull/551/files#diff-e1704a111d38befa7770754690d6c92b01e974385878b10fc285f9dd6d279868R206 check all storages with the previous function.

That should work, you can already use it

RUN xcaddy build --with github.com/caddy-dns/cloudflare \
                 --with github.com/darkweak/storages/go-redis/caddy \
                 --with github.com/darkweak/souin@v1.7.1=github.com/darkweak/souin@5a79ab7fe694a33db6dc6014d79834cbb363bc5f \
                 --with github.com/darkweak/souin/plugins/caddy@5a79ab7fe694a33db6dc6014d79834cbb363bc5f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants