A cache storage that is not available is logged and skipped; Souin then serves from its unbounded in-memory storage
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Go
- Estrellas
- 395
- Forks
- 30
- Merge medio
- 32 min
- PR fusionados (30 d)
- 1
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de caddyserver/cache-handler
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
caddyserver/cache-handler#138 · 1 comentario · 3 reacciones ·
-
Admin API purge/invalidation still panics with nil pointer on v0.16.0 (same root cause as #140)Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 76/100
caddyserver/cache-handler#143 · 2 comentarios ·
-
Can not flush cacheAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
caddyserver/cache-handler#140 · 4 comentarios · 1 reacción ·
-
`Incomming` has a typoAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 45/100
caddyserver/cache-handler#139 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
caddyserver/cache-handler#137 · 1 comentario ·
Todos los issues de caddyserver/cache-handler
Issues similares
-
agent-review-finding bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
jordansmall/spindrift#5281 ·
Los mantenedores suelen responder en 1 día
-
unbounded value for n in `/v1/logs` can panic/OOMPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertosmall item
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
canonical/pebble#1127 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[schema-coverage] elasticstack_elasticsearch_synonym_set (data source)Posiblemente ocupada @github-actions la tomó hoy. Abiertoacceptance-tests phase-coding schema-coverage testing triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 81/100
elastic/terraform-provider-elasticstack#5211 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 89/100
open-policy-agent/opa#9366 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
defect
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nats-io/nats-server#8752 ·
Los mantenedores suelen responder en 1 día