A cache storage that is not available is logged and skipped; Souin then serves from its unbounded in-memory storage
まだ誰も着手していません。
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Go
- スター
- 395
- フォーク
- 30
- 平均マージ
- 32分
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
caddyserver/cache-handler のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
caddyserver/cache-handler#138 · コメント 1 件 · リアクション 3 件 ·
-
難易度 3/5 半日 初心者へのやさしさ 45/100
caddyserver/cache-handler#146 ·
-
Admin API purge/invalidation still panics with nil pointer on v0.16.0 (same root cause as #140)オープン
難易度 3/5 1〜2日 初心者へのやさしさ 76/100
caddyserver/cache-handler#143 · コメント 2 件 ·
-
Can not flush cacheオープン
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
caddyserver/cache-handler#140 · コメント 4 件 · リアクション 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 45/100
caddyserver/cache-handler#139 · コメント 1 件 ·
caddyserver/cache-handler の issue をすべて見る
似ている issue
-
documentation hacktoberfest priority: low skill: good first issue status: ready for dev
難易度 2/5 半日 初心者へのやさしさ 85/100
hyperledger-labs/fabric-smart-client#2142 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
numberly/vault-db-injector#107 ·
メンテナーはふだん 1 日以内に返信
-
area/import kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
[DOC] Wrong sg_egress_ports range in the Terraform Databricks Guide for AWS Hub & Spoke with Network Firewall対応中かも @akhil9tiet が今日担当しました。 オープンdocs
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
databricks/terraform-provider-databricks#6080 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
spqr-coordinator usage shows 'run --config', but 'run' is not a subcommand (unknown command "run")オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
pg-sharding/spqr#3092 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信