Only cache NotFound errors from S3 backend, rather than any errors.

We need to cache NotFound responses to avoid hitting the backend
whenever there's a flurry of requests for the same invalid domain.
But caching any kind of error, including context cancellation, results
in poisoning the cache with that error, e.g. if the domain exists but
the client that requested it first did not wait for the response.
This commit is contained in:
Catherine
2025-09-30 03:44:24 +00:00
parent 764b4cd9f5
commit b1ef57d32a

View File

@@ -312,8 +312,10 @@ func (s3 *S3Backend) GetManifest(ctx context.Context, name string) (*Manifest, e
if err != nil {
if errResp := minio.ToErrorResponse(err); errResp.Code == "NoSuchKey" {
err = fmt.Errorf("%w: %s", errNotFound, errResp.Key)
return &CachedManifest{nil, 1, err}, nil
} else {
return nil, err
}
return &CachedManifest{nil, 1, err}, nil
} else {
return &CachedManifest{manifest, size, err}, nil
}