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

Use on-demand cluster discovery in on-demand extension #20065

Merged
merged 59 commits into from
May 3, 2022

Conversation

krnowak
Copy link
Contributor

@krnowak krnowak commented Feb 21, 2022

Commit Message:
This adds an odcds_config field to the extension's config, and also allows the extension to be configured per-route. As it stands, it currently works only with routes using cluster-header config.

Additional Description:
Risk Level:
Medium, extending one extension in an opt-in way.

Testing:
Added unit tests and integration tests.

Docs Changes:
Not sure.

Release Notes:
Extended on-demand extension with on-demand cluster discovery functionality.

Platform Specific Features:
None.

[Optional Runtime guard:]
Fixes #2500
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

CC: @jamesmulcahy

@krnowak krnowak requested a review from htuch as a code owner February 21, 2022 16:34
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @lizan
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #20065 was opened by krnowak.

see: more, trace.

Copy link
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, very exciting!
Took a first pass on the code, and left a few comments.

Comment on lines 26 to 27
// service. If not specified, the on-demand cluster discovery will
// be disabled. When it's specified, the filter will pause a request
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think that this field should be required?
IMO if a config update contains the OnDemand extension, then it is meant to be used (and enabled).
Unless if there are scenarios where a dummy placeholder is wanted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that before the on-demand plugin was only talking to RDS if there wasn't any matching route. Not sure if we want to break this by requiring the odcds_config to be defined.

Comment on lines 41 to 42
// service. If not specified, the on-demand cluster discovery will
// be disabled. When it's specified, the filter will pause a request
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

source/extensions/filters/http/on_demand/BUILD Outdated Show resolved Hide resolved
Upstream::OdCdsApiHandlePtr createOdCdsApi(const ProtoConfig& proto_config,
Upstream::ClusterManager& cm,
ProtobufMessage::ValidationVisitor& validation_visitor) {
if (!proto_config.has_odcds_config() && proto_config.resources_locator().empty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC the config-source is required no matter if resources-locator is set or not.
@htuch to correct me if I'm wrong.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, my confusion here. I was reading this as resource-name instead of locator.

filter_iteration_state_ = Http::FilterHeadersStatus::StopIteration;
auto callback = std::make_unique<Upstream::ClusterDiscoveryCallback>(
[this](Upstream::ClusterDiscoveryStatus cluster_status) {
onClusterDiscoveryCompletion(cluster_status);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could there be a case where the filter is destroyed before the callback is invoked?
What I'm not certain about is whether we'll get an invocation of onClusterDiscoveryCompletion on a destroyed filter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the filter is destroyed, then cluster_discovery_handle_ is going to be destroyed too, which will unregister and destroy the callback.

@rojkov
Copy link
Member

rojkov commented Mar 1, 2022

/wait

@rojkov
Copy link
Member

rojkov commented Mar 4, 2022

/wait
on coverage

@adisuissa adisuissa self-assigned this Mar 5, 2022
@jamesmulcahy
Copy link
Contributor

@adisuissa could you please take a look when you get a moment? Thanks!

Copy link
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

Overall LGTM.
/assign @htuch

test/integration/odcds_integration_test.cc Outdated Show resolved Hide resolved
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM modulo remaining comments.
/wait

test/integration/odcds_integration_test.cc Outdated Show resolved Hide resolved
test/integration/odcds_integration_test.cc Outdated Show resolved Hide resolved
test/integration/odcds_integration_test.cc Outdated Show resolved Hide resolved
@krnowak
Copy link
Contributor Author

krnowak commented Apr 29, 2022

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #20065 (comment) was created by @krnowak.

see: more, trace.

@krnowak
Copy link
Contributor Author

krnowak commented Apr 29, 2022

CI is green, so it's ready for review.

@jamesmulcahy
Copy link
Contributor

Thanks again, @krnowak -- fantastic work, I really appreciate it.

@krnowak
Copy link
Contributor Author

krnowak commented Apr 29, 2022

@jamesmulcahy: Thank you for the kind words. :)

I updated the PR again, this time no code changes (besides another merge from the main branch), but the CI needs to run again. I found out that there are some extra docs for on_demand extension, so I tried my hand at updating them a bit. I'd be grateful for a review of the wording. Thanks!

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM with two nits (look forward to getting this mergred)

krnowak added 3 commits May 2, 2022 18:49
Signed-off-by: Krzesimir Nowak <[email protected]>
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! Huge win for xDS APIs, thank you so much @krnowak for your contributions here and patience through the review process.

@repokitteh-read-only repokitteh-read-only bot removed the api label May 3, 2022
@htuch htuch merged commit a41b254 into envoyproxy:main May 3, 2022
@krnowak krnowak deleted the krnowak/odcds branch May 3, 2022 10:08
ravenblackx pushed a commit to ravenblackx/envoy that referenced this pull request Jun 8, 2022
)

This adds an odcds_config field to the extension's config, and also allows the extension to be configured per-route. As it stands, it currently works only with routes using cluster-header config.

Risk Level: Medium, extending one extension in an opt-in way.
Testing: Added unit tests and integration tests.
Fixes envoyproxy#2500

Signed-off-by: Krzesimir Nowak <[email protected]>
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.

Lazy loading (on demand) for Routes, Clusters and Endpoints
8 participants