Skip to content

http: add server factory only factory support to cache_v2#46219

Open
wbpcode wants to merge 1 commit into
envoyproxy:mainfrom
wbpcode:route-factory-cache-v2
Open

http: add server factory only factory support to cache_v2#46219
wbpcode wants to merge 1 commit into
envoyproxy:mainfrom
wbpcode:route-factory-cache-v2

Conversation

@wbpcode

@wbpcode wbpcode commented Jul 17, 2026

Copy link
Copy Markdown
Member

Commit Message: http: add server factory only factory support to cache_v2
Additional Description:
This adds the server-factory-context-only filter factory creation method
(createHttpFilterFactoryFromProtoTyped taking only a ServerFactoryContext,
introduced in #45989) to the cache_v2 HTTP filter(s).

This allows these filters to be created in contexts where only a
ServerFactoryContext is available (e.g. route/virtual-host level filter
configuration) rather than requiring the full downstream FactoryContext.
The existing downstream FactoryContext path is preserved and now delegates
to a shared helper, so behavior for existing use cases is unchanged.

Generative AI was used to assist with this change. I have reviewed all changes also.

Risk Level: Low
Testing: Existing/added unit config tests; CI.
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #46219 was opened by wbpcode.

see: more, trace.

@wbpcode

wbpcode commented Jul 18, 2026

Copy link
Copy Markdown
Member Author

/coverage

@repokitteh-read-only

Copy link
Copy Markdown

Coverage for this Pull Request will be rendered here:

https://storage.googleapis.com/envoy-cncf-pr/46219/coverage/index.html

For comparison, current coverage on main branch is here:

https://storage.googleapis.com/envoy-cncf-postsubmit/main/coverage/index.html

The coverage results are (re-)rendered each time the CI Envoy/Checks (coverage) job completes.

🐱

Caused by: a #46219 (comment) was created by @wbpcode.

see: more, trace.

Signed-off-by: wbpcode <wbphub@gmail.com>
@wbpcode
wbpcode force-pushed the route-factory-cache-v2 branch from 9d01e7f to 8d27e23 Compare July 18, 2026 09:00
@wbpcode
wbpcode marked this pull request as ready for review July 18, 2026 09:00
Comment on lines +150 to +154
// Pass the server factory context to allow HttpCache to use async client, stats scope
// etc.
virtual absl::StatusOr<std::shared_ptr<CacheSessions>>
getCache(const envoy::extensions::filters::http::cache_v2::v3::CacheV2Config& config,
Server::Configuration::FactoryContext& context) PURE;
Server::Configuration::ServerFactoryContext& context) PURE;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also may break forks but it's should be fine because:

  • Cache v2 still in WIP status.
  • All existing getCache implementation will return a singleton which will be shared across listeners, it would be better to use server factory context here.

@@ -64,7 +64,7 @@ class CacheSingleton : public Envoy::Singleton::Instance {
async_file_manager_factory_->getAsyncFileManager(config.manager_config());
std::unique_ptr<FileSystemHttpCache> fs_cache = std::make_unique<FileSystemHttpCache>(
singleton, cache_eviction_thread_, std::move(config), std::move(async_file_manager),
context.serverFactoryContext().scope());
context.scope());

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually fixed a potential lifetime bug. For example, the listener A's cache filter create the CacheSessions first with it's scope. Then listener B get the cached CacheSessions because same configuration. Then the listener A is removed. Then the CacheSessions may refer to invalid stats.

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 this pull request may close these issues.

2 participants