router: scoped rds (2c): implement scoped rds API#6932
router: scoped rds (2c): implement scoped rds API#6932htuch merged 42 commits intoenvoyproxy:masterfrom
Conversation
This commit introduces: - Support for scoped routing configuration parsing. - Inline and dynamic config providers using the ConfigProvider framework. - Unit and integration testing scaffolding. This is the second step in the PR chain for envoyproxy#4704. Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
…-dynamic Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
- Top level SRDS resource is now called a 'ScopedRouteConfiguration'. - SRDS now operates like CDS where the full set of resources received via the DS builds the complete configuration state. - Modified the ConfigProvider framework to support delta APIs such as SRDS and CDS - Scoped RDS unit test mostly passing, integration tests have not yet been migrated to new API Signed-off-by: Andres Guedez <aguedez@google.com>
Also, cleanup. Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
…-dynamic Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
…-dynamic Signed-off-by: Andres Guedez <aguedez@google.com>
- Refactor the framework to create a cleaner, more cohesive set of abstractions based on the ConfigProvider::ApiType of the DS API. - Rename base classes for consistency and clarity. Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
…scoped-rds-config-provider Signed-off-by: Andres Guedez <aguedez@google.com>
…-provider Signed-off-by: Andres Guedez <aguedez@google.com>
|
@stevenzzzz FYI |
|
@htuch PTAL (or reassign as appropriate) |
Signed-off-by: Andres Guedez <aguedez@google.com>
|
@AndresGuedez would be happy to take a pass, but curious also to get a review from @fredlas and @dmitri-d as well, since they have been doing a lot more work in the depths of RDS and xDS ingest lately. |
fredlas
left a comment
There was a problem hiding this comment.
This only touches the code I'm familiar with, the speaking-xDS-with-server parts, a bit, but those parts look fine.
htuch
left a comment
There was a problem hiding this comment.
Thanks, this looks good; I take it that outside of the config update/dump, it's largely plumbing and there isn't a ton to review. Can we get coverage to 100% here, or do we need to wait for followup PRs?
include/envoy/router/scopes.h
Outdated
| * @param headers the request headers to match the scoped routing configuration against. | ||
| * @return ConfigConstSharedPtr the router's Config matching the request headers. | ||
| */ | ||
| virtual ConfigConstSharedPtr getRouterConfig(const Http::HeaderMap& headers) const PURE; |
There was a problem hiding this comment.
I think it's important to distinguish between three concepts; "route config", "router config" and "HTTP connection manager route configuration". I think you mean the first or last year, rather than the middle?
There was a problem hiding this comment.
This returns an Envoy::Router::Config, hence the name. However, I agree it is fairly confusing since the documentation refers to it by yet another name (route table).
I am fine switching to getRouteTable or even getRouteConfiguration if you think either of those more directly convey the meaning.
There was a problem hiding this comment.
getRouteConfiguration or even the shorter getRouteConfig would be clearer to me.
source/common/router/scoped_rds.cc
Outdated
| Protobuf::Message* clone = it.New(); | ||
| clone->CopyFrom(it); | ||
| config_protos.push_back(std::unique_ptr<const Protobuf::Message>(clone)); | ||
| } |
There was a problem hiding this comment.
Do we need to copy, or could we pass the RepeatedFieldPtr intro createStaticConfigProvider somehow?
There was a problem hiding this comment.
To keep the Envoy::Config::ConfigProviderManager::createStaticConfigProvider interface generic, the container passed into the function must contain Protobuf::Message pointers. Switching to RepeatedFieldPtr<Protobuf::Message> would still trigger a copy of each item in the container.
There was a problem hiding this comment.
OK, maybe use std::copy or std::transform then.
There was a problem hiding this comment.
I removed this code from the PR since it is not yet used. I will reintroduce it in the next PR with modifications based on the feedback.
source/common/router/scoped_rds.cc
Outdated
| for (const auto& provider : immutableConfigProviders(ConfigProviderInstanceType::Inline)) { | ||
| const auto protos_info = | ||
| provider->configProtoInfoVector<envoy::api::v2::ScopedRouteConfiguration>(); | ||
| if (protos_info == absl::nullopt) { |
There was a problem hiding this comment.
When would this be true? Maybe add a comment?
There was a problem hiding this comment.
Converted to ASSERT().
source/common/router/scoped_rds.h
Outdated
| #include "envoy/config/subscription.h" | ||
| #include "envoy/stats/scope.h" | ||
|
|
||
| #include "common/common/logger.h" |
There was a problem hiding this comment.
Suggest moving more of this file into the .cc and then we lose the .h dependency here on as many files.
| std::vector<std::string> exception_msgs; | ||
| // We need to keep track of which scoped routes we might need to remove. | ||
| ScopedConfigManager::ScopedRouteMap scoped_routes_to_remove = | ||
| scoped_config_manager_.scopedRouteMap(); |
There was a problem hiding this comment.
Is the state kept in scoped_config_manager_ used anywhere else (or are there plans for that)? If not, I think you could clear the scoped route map on each update and then add routes that came in onConfigUpdate...
There was a problem hiding this comment.
The state must persist across onConfigUpdate() calls such that the diff can be computed between the previous set of ScopedRouteConfiguration protos and the new set of protos.
I am working on a commit to improve the coverage a bit, but the next PR with the integration tests will certainly add a significant amount of coverage as well, so I would prefer to avoid focusing on coverage too much until the next PR. |
Signed-off-by: Andres Guedez <aguedez@google.com>
Also, fixes a bug removing scoped routes. Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
htuch
left a comment
There was a problem hiding this comment.
LGTM modulo remaining comments.
/wait
include/envoy/router/scopes.h
Outdated
| * @param headers the request headers to match the scoped routing configuration against. | ||
| * @return ConfigConstSharedPtr the router's Config matching the request headers. | ||
| */ | ||
| virtual ConfigConstSharedPtr getRouterConfig(const Http::HeaderMap& headers) const PURE; |
There was a problem hiding this comment.
getRouteConfiguration or even the shorter getRouteConfig would be clearer to me.
source/common/router/scoped_rds.cc
Outdated
| Protobuf::Message* clone = it.New(); | ||
| clone->CopyFrom(it); | ||
| config_protos.push_back(std::unique_ptr<const Protobuf::Message>(clone)); | ||
| } |
There was a problem hiding this comment.
OK, maybe use std::copy or std::transform then.
| public: | ||
| ScopedRoutesConfigProviderManagerTest() = default; | ||
|
|
||
| ~ScopedRoutesConfigProviderManagerTest() override = default; |
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
* master: (65 commits) proto: Add PATCH method to RequestMethod enum (envoyproxy#6737) exe: drop unused deps on zlib compressor code (envoyproxy#7022) coverage: fix some misc coverage (envoyproxy#7033) Enable proto schema for router_check_tool (envoyproxy#6992) stats: rework stat sink flushing to centralize counter latching (envoyproxy#6996) [test] convert lds api test config stubs to v2 (envoyproxy#7021) router: scoped rds (2c): implement scoped rds API (envoyproxy#6932) build: Add option for size-optimized binary (envoyproxy#6960) test: adding an integration test framework for file-based LDS (envoyproxy#6933) doc: update obsolete ref to api/XDS_PROTOCOL.md (envoyproxy#7002) dispatcher: faster runOnAllThreads (envoyproxy#7011) example: add csrf sandbox (envoyproxy#6805) fix syntax of gcov exclusion zone. (envoyproxy#7023) /runtime_modify: add support for query params in body (envoyproxy#6977) stats: Create stats for http codes with the symbol table. (envoyproxy#6733) health check: fix more fallout from inline deletion change (envoyproxy#6988) Max heap fix (envoyproxy#7016) Add support to unregister from lifecycle notifications (envoyproxy#6984) build spdy_core_alt_svc_wire_format (envoyproxy#7010) ext_authz: Make sure initiateCall only called once (envoyproxy#6949) ... Signed-off-by: Michael Puncel <mpuncel@squareup.com>
Implement the scoped RDS (SRDS) API config subscription and provider based on the config protos introduced in #6675 and the ConfigProvider framework introduced in #5243 and #6781.
NOTES:
HttpConnectionManager, that will be done in the next PR.Risk Level: Low (this DS API is not yet integrated into the HCM and can not be enabled via config).
Testing: Unit tests added.
Docs Changes: N/A.