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

On demand loading of ScopedRouteConfiguration #12640

Merged
merged 62 commits into from
Sep 9, 2020

Conversation

chaoqin-li1123
Copy link
Member

Commit Message:
Add a field to the current protobuf of ScopedRouteConfiguration to enable on demand scoped route table loading. The on demand scope route tables will be loaded lazily. The lazy loading feature of route table associated with scope is achieved by extending the current vhds on_demand filter to support lazy loading of RouteConfigurationscoped route discovery service.If a scoped route configuration is set to be loaded lazily, upon a http request using SRDS, when the corresponding route table of a scope is not found, post a callback to control plane, request the route table from the management server, after the route table has been initialized, continue the filter chain.
Additional Description: Design doc
Risk Level:
Testing: add unit tests and integration test to verifiy behavior changes
Docs Changes:
Release Notes:
[Optional Runtime guard:]
[Optional Fixes #Issue] on demand s/rds
[Optional Deprecated:]

chaoqinli added 16 commits August 7, 2020 15:17
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
...
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/envoy/.
CC @envoyproxy/api-watchers: FYI only for changes made to api/envoy/.

🐱

Caused by: #12640 was opened by chaoqin-li1123.

see: more, trace.

@chaoqin-li1123 chaoqin-li1123 changed the title Lazy rds on demand loading of scoped rds Aug 14, 2020
@chaoqin-li1123 chaoqin-li1123 changed the title on demand loading of scoped rds On demand loading of ScopedRouteConfiguration Aug 14, 2020
chaoqinli added 4 commits August 14, 2020 02:15
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
@stevenzzzz
Copy link
Contributor

/cc stevenzzzz

Signed-off-by: chaoqinli <chaoqinli@google.com>
data if RouteConfiguration is specified to be loaded on demand in the :ref:`Scoped RouteConfiguration <envoy_v3_api_msg_config.route.v3.ScopedRouteConfiguration>`. The
contents of the http header is used to find the scope and create the on-demand request.

On-demand VHDS and on-demand S/RDS can not be used at the same time at this point.
Copy link
Member

Choose a reason for hiding this comment

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

Do you have a tracking issue yet for converging the two?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess not.

Copy link
Member

Choose a reason for hiding this comment

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

Recommend adding one.

bool operator==(const ScopeKey& other) const;

private:
// Update the key's hash with the new fragment hash.
Copy link
Member

Choose a reason for hiding this comment

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

Arguably we should split this into interface/implementation, since there is a lot of low-level implementation logic here. We have precedence for doing it this way in some cases, e.g. header map, but strongly prefer to not put a ton of implementation logic (e.g. the hash function below) inside include/.

source/common/http/conn_manager_impl.cc Show resolved Hide resolved
test/integration/scoped_rds_integration_test.cc Outdated Show resolved Hide resolved
source/common/router/scoped_rds.cc Show resolved Hide resolved
chaoqinli added 3 commits September 1, 2020 23:49
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Copy link
Contributor

@stevenzzzz stevenzzzz left a comment

Choose a reason for hiding this comment

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

almost there!

test/common/router/scoped_rds_test.cc Show resolved Hide resolved
std::function<void(bool)> route_config_updated_cb = [](bool) {};
// Scope no longer exists after srds update.
std::function<void(bool)> route_config_updated_cb = [](bool scope_exist) {
EXPECT_FALSE(scope_exist);
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto here.

docs/root/intro/arch_overview/http/http_routing.rst Outdated Show resolved Hide resolved
source/common/http/conn_manager_impl.cc Outdated Show resolved Hide resolved
test/integration/scoped_rds_integration_test.cc Outdated Show resolved Hide resolved
test/integration/scoped_rds_integration_test.cc Outdated Show resolved Hide resolved
source/common/router/scoped_rds.cc Outdated Show resolved Hide resolved
chaoqinli added 2 commits September 2, 2020 20:32
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
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.

Agree with @stevenzzzz, this looks great and close to ready to ship.
/wait

data if RouteConfiguration is specified to be loaded on demand in the :ref:`Scoped RouteConfiguration <envoy_v3_api_msg_config.route.v3.ScopedRouteConfiguration>`. The
contents of the http header is used to find the scope and create the on-demand request.

On-demand VHDS and on-demand S/RDS can not be used at the same time at this point.
Copy link
Member

Choose a reason for hiding this comment

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

Recommend adding one.

@@ -1,15 +1,21 @@
.. _config_http_filters_on_demand:

On-demand VHDS Updates
Copy link
Member

Choose a reason for hiding this comment

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

source/common/http/conn_manager_impl.cc Outdated Show resolved Hide resolved
test/common/router/scoped_rds_test.cc Outdated Show resolved Hide resolved
test/common/router/scoped_rds_test.cc Outdated Show resolved Hide resolved
test/common/router/scoped_rds_test.cc Show resolved Hide resolved
test_server_->waitForCounterGe("http.config_test.rds.foo_route1.update_attempt", 1);
// Close the connection and destroy the active stream.
cleanupUpstreamAndDownstream();
// Push rds update, on demand updated callback is post to worker thread.
Copy link
Member

Choose a reason for hiding this comment

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

Here's another situation I'm curious about. If I'm an untrusted client and I keep making requests that trigger on-demand behavior, then immediately shutdown the stream, and maybe the upstream is slow to respond, do we keep accumulate on-demand update callbacks on the main thread indefinitely?

Copy link
Member Author

Choose a reason for hiding this comment

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

The callbacks will be cleared after the RouteConfiguration is fetched. I guess that wouldn't cause a problem if the management server is alive?

Copy link
Member

Choose a reason for hiding this comment

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

True, I wonder if there is a possible combined attack where you take out the availability of the management server, and can then OOM the Envoy by unbounded growth of these per-stream resources that hang around when the stream is gone. Maybe a bit far fetched, it probably takes millions of requests to OOM given how tiny the closure is.

Signed-off-by: chaoqinli <chaoqinli@google.com>
chaoqinli added 7 commits September 7, 2020 04:52
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
@htuch
Copy link
Member

htuch commented Sep 8, 2020

LGTM modulo coverage validation. @stevenzzzz any additional comments?

@stevenzzzz
Copy link
Contributor

LGTM modulo coverage validation. @stevenzzzz any additional comments?

I have been talking to Chaoqin offline regularly, LGTM +1 modulo unresolved replies around clearer comments.

Signed-off-by: chaoqinli <chaoqinli@google.com>
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!

@repokitteh-read-only repokitteh-read-only bot removed the api label Sep 8, 2020
@htuch htuch merged commit 709d1c3 into envoyproxy:master Sep 9, 2020
@chaoqin-li1123 chaoqin-li1123 deleted the lazy_rds branch February 23, 2021 21:18
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.

4 participants