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

Cant update caddy config when olric enabled #29

Closed
mattvb91 opened this issue May 26, 2022 · 5 comments · Fixed by darkweak/souin#214
Closed

Cant update caddy config when olric enabled #29

mattvb91 opened this issue May 26, 2022 · 5 comments · Fixed by darkweak/souin#214

Comments

@mattvb91
Copy link

mattvb91 commented May 26, 2022

Caddy crashes when posting a new config to :2019/load when olric is enabled as the cache driver
Seems to not shut down the olric port gracefully / cant reuse it on reboot

caddy_1  | 2022/05/26 14:11:12 [INFO] Storage engine has been loaded: kvstore => service.go:129
caddy_1  | 2022/05/26 14:11:12 [DEBUG] memberlist: Got bind error: Failed to start TCP listener on "172.19.0.2" port 3322: listen tcp 172.19.0.2:3322: bind: address already in use
caddy_1  | Impossible to start the embedded Olric instance: Could not set up network transport: failed to obtain an address: Failed to start TCP listener on "172.19.0.2" port 3322: listen tcp 172.19.0.2:3322: bind: address already in use
caddy_1  | Closed EmbeddedOlricProvider chan

Also sometimes seeing this but not sure if related or not

caddy_1  | 2022/05/26 14:01:12 [INFO] Routing table has been pushed by 172.19.0.2:3320 => operations.go:87
caddy_1  | {"level":"debug","ts":1653573697.4362159,"logger":"http.stdlib","msg":"http: panic serving 172.19.0.1:40298: runtime error: invalid memory address or nil pointer dereference\ngoroutine 16465 [running]:\nnet/http.(*conn).serve.func1()\n\tnet/http/server.go:1825 +0xbf\npanic({0x1969700, 0x2c547a0})\n\truntime/panic.go:844 +0x258\ngithub.com/darkweak/souin/cache/providers.(*EmbeddedOlric).ListKeys(0x0)\n\tgithub.com/darkweak/souin@v1.6.8/cache/providers/embeddedOlricProvider.go:109 +0x1f2\ngithub.com/darkweak/souin/api.(*SouinAPI).GetAll(...)\n\tgithub.com/darkweak/souin@v1.6.8/api/souin.go:60\ngithub.com/darkweak/souin/api.(*SouinAPI).HandleRequest(0xc006e0f630, {0x7fc0373ab558, 0xc0008ec2a0}, 0xc000246400)\n\tgithub.com/darkweak/souin@v1.6.8/api/souin.go:90 +0x1b8\ngithub.com/darkweak/souin/plugins/caddy.(*SouinCaddyPlugin).ServeHTTP(0xc0000fa600, {0x7fc0373ab558?, 0xc0008ec2a0}, 0xc000246300, {0x1f50760, 0xc0008c1f60})\n\tgithub.com/darkweak/souin/plugins/caddy@v0.0.0-20220526084703-8bc41371ab53/httpcache.go:77 +0x94e\ngithub.com/caddyserver/caddy/v2/modules/caddyhttp.(*metricsInstrumentedHandler).ServeHTTP(0xc006e4c1c0, {0x1f5adf8?, 0xc0008ee000}, 0xc000246300, {0x1f50760, 0xc0008c1f60})\n\tgithub.com/caddyserver/caddy/v2@v2.5.1/modules/caddyhttp/metrics.go:132 +0x53b\ngithub.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1({0x1f5adf8?, 0xc0008ee000?}, 0x1f50760?)\n\tgithub.com/caddyserver/caddy/v2@v2.5.1/modules/caddyhttp/routes.go:272 +0x3b\ngithub.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f50760?, {0x1f5adf8?, 0xc0008ee000?}, 0x7785c6?)\n\tgithub.com/caddyserver/caddy/v2@v2.5.1/modules/caddyhttp/caddyhttp.go:57 +0x2f\ngithub.com/caddyserver/caddy/v2/modules/caddyhttp.wrapRoute.func1.1({0x1f5adf8, 0xc0008ee000}, 0xc000246300)\n\tgithub.com/caddyserver/caddy/v2@v2.5.1/modules/caddyhttp/routes.go:244 +0x322\ngithub.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x400?, {0x1f5adf8?, 0xc0008ee000?}, 0x1b06960?)\n\tgithub.com/caddyserver/caddy/v2@v2.5.1/modules/caddyhttp/caddyhttp.go:57 +0x2f\ngithub.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).enforcementHandler(0x0?, {0x1f5adf8?, 0xc0008ee000?}, 0xc0005fdcd0?, {0x1f50760?, 0xc006e4c200?})\n\tgithub.com/caddyserver/caddy/v2@v2.5.1/modules/caddyhttp/server.go:318 +0x252\ngithub.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).wrapPrimaryRoute.func1({0x1f5adf8?, 0xc0008ee000?}, 0x49ba97?)\n\tgithub.com/caddyserver/caddy/v2@v2.5.1/modules/caddyhttp/server.go:294 +0x3b\ngithub.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0xc0002eadc0?, {0x1f5adf8?, 0xc0008ee000?}, 0xc000246300?)\n\tgithub.com/caddyserver/caddy/v2@v2.5.1/modules/caddyhttp/caddyhttp.go:57 +0x2f\ngithub.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).ServeHTTP(0xc00027ea20, {0x1f5adf8, 0xc0008ee000}, 0xc000246300)\n\tgithub.com/caddyserver/caddy/v2@v2.5.1/modules/caddyhttp/server.go:230 +0xac6\nnet/http.serverHandler.ServeHTTP({0xc0008a7f50?}, {0x1f5adf8, 0xc0008ee000}, 0xc000246100)\n\tnet/http/server.go:2916 +0x43b\nnet/http.(*conn).serve(0xc0008dc000, {0x1f5c808, 0xc006bf2bd0})\n\tnet/http/server.go:1966 +0x5d7\ncreated by net/http.(*Server).Serve\n\tnet/http/server.go:3071 +0x4db"}

Reproducible example here:

https://github.com/mattvb91/caddy-cache-olric-bug

Edit: Just to point out this is using @latest in the Dockerfile

@darkweak
Copy link
Collaborator

Works with the --with github.com/darkweak/souin/plugins/caddy@960e570879a28ed30b4738738c4636895b8239af

@mattvb91
Copy link
Author

My build fails:

2022/05/29 19:12:46 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /usr/bin/caddy -ldflags -w -s -trimpath 
# github.com/darkweak/souin/plugins/caddy
/go/pkg/mod/github.com/darkweak/souin/plugins/caddy@v0.0.0-20220529173637-960e570879a2/httpcache.go:233:10: eo.GetDM undefined (type *"github.com/darkweak/souin/cache/providers".EmbeddedOlric has no field or method GetDM)
/go/pkg/mod/github.com/darkweak/souin/plugins/caddy@v0.0.0-20220529173637-960e570879a2/httpcache.go:236:13: cannot use providers.EmbeddedOlricConnectionFactory(s.Configuration) (value of type *"github.com/darkweak/souin/cache/providers".EmbeddedOlric) as type caddy.Destructor in return statement:
        *"github.com/darkweak/souin/cache/providers".EmbeddedOlric does not implement caddy.Destructor (missing Destruct method)
2022/05/29 19:13:12 [INFO] Skipping cleanup as requested; leaving folder intact: /tmp/buildenv_2022-05-29-1911.322171750
2022/05/29 19:13:12 [FATAL] exit status 2

My dockerfile:

FROM caddy:2.5.1-builder-alpine

RUN xcaddy build --with github.com/caddy-dns/route53 \
    --with github.com/darkweak/souin/plugins/caddy@960e570879a28ed30b4738738c4636895b8239af

# See https://caddyserver.com/docs/conventions#file-locations for details
ENV XDG_CONFIG_HOME /config
ENV XDG_DATA_HOME /data

VOLUME /config
VOLUME /data


EXPOSE 80
EXPOSE 443
EXPOSE 2019

WORKDIR /srv

@darkweak
Copy link
Collaborator

darkweak commented May 30, 2022

You have to specify --with github.com/darkweak/souin@960e570879a28ed30b4738738c4636895b8239af too.

@mattvb91
Copy link
Author

😆 you can tell im lacking sleep I didnt realize it was a completely different repository.

Looks good now and can post to /load and succesfully reboots.

@darkweak do you have a sponsors / opencollective link? Only thing that currently still seems to be an issue is the stale & 'strategy' => 'hard' directives seems to get ignored: #26 (comment) but I dont want to open another issue 😆

@darkweak
Copy link
Collaborator

I don't need or want sponsors because I prefer people keep their money and for me open-source is just a hobby 😅.
Okay, I'll fix the soft strategy eviction asap.

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