Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring ClusterManagerImpl to support dynamic config for composite filter when its in upstream filter chain #33218

Closed
yanjunxiang-google opened this issue Mar 29, 2024 · 6 comments
Labels
enhancement Feature requests. Not bugs or questions.

Comments

@yanjunxiang-google
Copy link
Contributor

yanjunxiang-google commented Mar 29, 2024

Title: Refactoring ClusterManagerImpl c'tor and to support dynamic config for composite filter when its in upstream filter chain

This issue is related to the PR: #33013

Description:
Currently, the cluster manager is initialized with the below sequence:

cluster_manager_ = cluster_manager_factory.clusterManagerFromProto(bootstrap);

2)

THROW_IF_NOT_OK(cluster_manager_impl->init(bootstrap));

i.e, it calls the cluster_manager_impl->init(bootstrap) before return unique_ptr, and assign to the cluster_manager_.

This is causing problems when functions called inside cluster_manager_impl->init(bootstrap) needs to access cluster_manger_, which is the case for composite filter in the upstream filter chain.

So, for composite filter case, if it is put in the upstream filter chain, when the dynamic_config is configured:

the above cluster_manager_impl->init(bootstrap) will eventually call this function:

factory_context, server_factory_context.clusterManager(), false, "http", nullptr);

which access above cluster_manger_ through server_factory_context.clusterManager(). As cluster_manager_ is nullptr, this crashed.

So, if we want to support composite filter with dynamic_config in the upstream filter chain, one of the solution is moving the
cluster_manager_impl->init(bootstrap)
out from
ProdClusterManagerFactory::clusterManagerFromProto

And call it after, like this:

cluster_manager_ = clusterManagerFromProto();
cluster_manager_->init(bootstrap);

This way, when the above init() function access clusterManager(), cluster_manager_ is already setup and no issues.
We need to add good comments to make sure no other code wrote in between these two lines though.

[optional Relevant Links:]

Any extra documentation required to understand the issue.

@soulxu
Copy link
Member

soulxu commented Apr 1, 2024

cc @wbpcode @RyanTheOptimist

It will lead to a crash, so it should be a bug I think

@soulxu soulxu added bug and removed triage Issue requires triage labels Apr 1, 2024
@wbpcode
Copy link
Member

wbpcode commented Apr 1, 2024

This is duplicate with #26653

I am glad to review/see a fix to close these two issue. :)

@yanjunxiang-google
Copy link
Contributor Author

Thanks for sharing the info! I have a draft PR for this:
#33221

@yanjunxiang-google
Copy link
Contributor Author

@soulxu As we currently does not support composite filter in upstream filter chain, there is no crash at this moment.

@yanjunxiang-google
Copy link
Contributor Author

@soulxu soulxu added enhancement Feature requests. Not bugs or questions. and removed bug labels Apr 1, 2024
htuch pushed a commit that referenced this issue Apr 11, 2024
This is to address the issue: #33218

Signed-off-by: Yanjun Xiang <yanjunxiang@google.com>
@qqustc
Copy link
Contributor

qqustc commented Apr 16, 2024

alyssawilk pushed a commit to alyssawilk/envoy that referenced this issue Apr 29, 2024
This is to address the issue: envoyproxy#33218

Signed-off-by: Yanjun Xiang <yanjunxiang@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests. Not bugs or questions.
Projects
None yet
Development

No branches or pull requests

4 participants