Skip to content

router: scoped rds (2c): implement scoped rds API#6932

Merged
htuch merged 42 commits intoenvoyproxy:masterfrom
AndresGuedez:scoped-rds-config-provider
May 22, 2019
Merged

router: scoped rds (2c): implement scoped rds API#6932
htuch merged 42 commits intoenvoyproxy:masterfrom
AndresGuedez:scoped-rds-config-provider

Conversation

@AndresGuedez
Copy link
Contributor

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:

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.

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>
- Readability cleanup in various places.
- Improve integration tests.
- Add 'name' field to ScopedRoutes proto.

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>
…-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>
@AndresGuedez
Copy link
Contributor Author

@stevenzzzz FYI

@AndresGuedez
Copy link
Contributor Author

@htuch PTAL (or reassign as appropriate)

Signed-off-by: Andres Guedez <aguedez@google.com>
@htuch htuch self-assigned this May 14, 2019
@htuch
Copy link
Member

htuch commented May 14, 2019

@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.

@htuch htuch requested review from dmitri-d and fredlas May 14, 2019 22:23
Copy link
Contributor

@fredlas fredlas left a comment

Choose a reason for hiding this comment

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

This only touches the code I'm familiar with, the speaking-xDS-with-server parts, a bit, but those parts look fine.

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.

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?

* @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;
Copy link
Member

Choose a reason for hiding this comment

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

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

getRouteConfiguration or even the shorter getRouteConfig would be clearer to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Protobuf::Message* clone = it.New();
clone->CopyFrom(it);
config_protos.push_back(std::unique_ptr<const Protobuf::Message>(clone));
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to copy, or could we pass the RepeatedFieldPtr intro createStaticConfigProvider somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

OK, maybe use std::copy or std::transform then.

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 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.

for (const auto& provider : immutableConfigProviders(ConfigProviderInstanceType::Inline)) {
const auto protos_info =
provider->configProtoInfoVector<envoy::api::v2::ScopedRouteConfiguration>();
if (protos_info == absl::nullopt) {
Copy link
Member

Choose a reason for hiding this comment

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

When would this be true? Maybe add a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Converted to ASSERT().

#include "envoy/config/subscription.h"
#include "envoy/stats/scope.h"

#include "common/common/logger.h"
Copy link
Member

Choose a reason for hiding this comment

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

Suggest moving more of this file into the .cc and then we lose the .h dependency here on as many files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

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();
Copy link
Contributor

Choose a reason for hiding this comment

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

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...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

@AndresGuedez
Copy link
Contributor Author

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?

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>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@google.com>
Signed-off-by: Andres Guedez <aguedez@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 modulo remaining comments.
/wait

* @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;
Copy link
Member

Choose a reason for hiding this comment

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

getRouteConfiguration or even the shorter getRouteConfig would be clearer to me.

Protobuf::Message* clone = it.New();
clone->CopyFrom(it);
config_protos.push_back(std::unique_ptr<const Protobuf::Message>(clone));
}
Copy link
Member

Choose a reason for hiding this comment

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

OK, maybe use std::copy or std::transform then.

public:
ScopedRoutesConfigProviderManagerTest() = default;

~ScopedRoutesConfigProviderManagerTest() override = default;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: no need for these defaults.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

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>
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.

Great, thanks!

@htuch htuch merged commit 831d0cb into envoyproxy:master May 22, 2019
mpuncel added a commit to mpuncel/envoy that referenced this pull request May 22, 2019
* 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>
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.

5 participants