A cache storage that is not available is logged and skipped; Souin then serves from its unbounded in-memory storage
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Start in dispatch.go at parseStorages and trace how configured storage UUIDs are registered and looked up during Provision, including the call immediately after s.parseStorages(ctx). Reproduce the large size lookup mismatch and failed SimpleFS provisioning described in the issue. Done means provisioning fails when a configured storage is unavailable, so Caddy does not silently serve from the in-memory default.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Versions: Caddy v2.11.4, cache-handler v0.17.0, github.com/darkweak/storages/simplefs/caddy v0.0.20 (built with xcaddy, nothing else).
When the storage a cache block configures is not available, cache-handler logs it and Souin serves every response from its in-memory default storage. Caddy accepts the configuration, caddy reload included, so its automatic rollback never applies, and every cached response then lives in Caddy's heap with no cap, although the configuration asked for a disk-backed, size-capped storage.
Two ways to get there, both reproduced on the versions above with this Caddyfile (only the configuration block changes):
{
admin off
cache {
ttl 60s
simplefs {
configuration {
path /tmp/simplefs
size 1000000
}
}
}
}
:8080 {
cache
header Cache-Control "public, max-age=60"
respond "hello" 200
}
1. size of 1,000,000 or more. The storer provisions and creates its directory, but the lookup does not find it: the name cache-handler composes for the lookup formats the decoded size (a float64) as 1e+06, while the storer registers under 1000000. The only log line is Souin's warning:
{"level":"warn","logger":"http.handlers.cache","msg":"You're running Souin with the default storage that is not optimized and for development purpose. ..."}
and every hit reports Cache-Status: Souin; hit; ttl=59; key=GET-http-127.0.0.1:8080-/; detail=DEFAULT, with nothing written under /tmp/simplefs. With size 1000 the same Caddyfile serves detail=SIMPLEFS and writes the body files.
2. A storage that fails to provision, e.g. path /nope/simplefs (a directory the process cannot create). parseStorages (dispatch.go) logs the error and carries on:
{"level":"error","logger":"http.handlers.cache","msg":"Error during SimpleFS init, did you include the SimpleFS storage (--with github.com/darkweak/storages/simplefs/caddy)? provision storages.cache.simplefs: mkdir /nope: read-only file system"}
then the same warning, and the same detail=DEFAULT hits.
Suggested fix: fail Provision when a configured storage (Found) is not registered under the UUID Souin looks it up by. That covers both cases: a reload is then refused and Caddy keeps the config it ran, and a start fails. We run this as a small patch, called right after s.parseStorages(ctx) and before middleware.NewHTTPCacheHandler:
func (s *SouinCaddyMiddleware) requireConfiguredStorages() error {
dc := s.Configuration.DefaultCache
for _, configured := range []struct {
name string
provider configurationtypes.CacheProvider
}{
{"badger", dc.Badger}, {"etcd", dc.Etcd}, {"nats", dc.Nats}, {"nuts", dc.Nuts},
{"olric", dc.Olric}, {"otter", dc.Otter}, {"redis", dc.Redis}, {"simplefs", dc.SimpleFS},
} {
if configured.provider.Found &&
(configured.provider.Uuid == "" || core.GetRegisteredStorer(configured.provider.Uuid) == nil) {
return fmt.Errorf("the %s storage is configured but is not available (its error is logged above): refusing to serve from the in-memory storage", configured.name)
}
}
return nil
}
Case 1 could also be fixed at the source, by formatting size as an integer in the lookup name, or by asking the provisioned storer for the name it registered under. Happy to open a PR for either.
- Ngôn ngữ chính
- Go
- Star
- 395
- Fork
- 30
- Merge trung bình
- 32 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của caddyserver/cache-handler
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
caddyserver/cache-handler#138 · 1 bình luận · 3 reaction ·
-
Admin API purge/invalidation still panics with nil pointer on v0.16.0 (same root cause as #140)Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
caddyserver/cache-handler#143 · 2 bình luận ·
-
Can not flush cacheĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
caddyserver/cache-handler#140 · 4 bình luận · 1 reaction ·
-
`Incomming` has a typoĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 45/100
caddyserver/cache-handler#139 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
caddyserver/cache-handler#137 · 1 bình luận ·
Tất cả issue của caddyserver/cache-handler
Issue tương tự
-
darwin zsh
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
carapace-sh/carapace-bin#3846 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
appplication - is a typo?Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
golang-app/ecommerce#179 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Simulator process crashes (nil pointer panic) when the dataset returns an errorCó thể đã có người làm @EugeneVon đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
llm-d/llm-d-inference-sim#772 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
refactor: decode numchildren with a lenient int type instead of a hand-written xProp.UnmarshalXMLĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
crazy-goat/xdbg#125 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
150 points ci complexity:medium drips-wave help wanted medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
sorotrail/SoroBeacon#449 ·
Maintainer thường phản hồi trong vòng 1 ngày