srds: remove to-de-removed scopes first and then apply additions to avoid scope key conflict.#9366
Conversation
…a new scope has the same key as an existing scope. Signed-off-by: Xin Zhuang <stevenzzz@google.com>
e7748a5 to
7af0f6c
Compare
|
/assign AndresGuedez |
AndresGuedez
left a comment
There was a problem hiding this comment.
Thanks for working on this. A few minor comments.
source/common/router/scoped_rds.h
Outdated
| @@ -133,8 +133,9 @@ class ScopedRdsConfigSubscription : public Envoy::Config::DeltaConfigSubscriptio | |||
| std::vector<std::string>& exception_msgs); | |||
| // Removes given scopes from the managed set of scopes. | |||
| // Returns true if any scope updated, false otherwise. | |||
There was a problem hiding this comment.
Please update comment.
There was a problem hiding this comment.
Please update comment.
oopps, done.
| } | ||
|
|
||
| bool ScopedRdsConfigSubscription::removeScopes( | ||
| std::list<std::unique_ptr<ScopedRdsConfigSubscription::RdsRouteConfigProviderHelper>> |
There was a problem hiding this comment.
Consider using an alias for this type to improve readability.
There was a problem hiding this comment.
it's only used within this module, I would leave it if you don't feel strongly.
There was a problem hiding this comment.
I think it's worth it, this is a long type and it's repeated in several places; however, I'll leave it up to the final reviewer.
source/common/router/scoped_rds.cc
Outdated
| for (const auto& scope_name : scope_names) { | ||
| auto iter = scoped_route_map_.find(scope_name); | ||
| if (iter != scoped_route_map_.end()) { | ||
| to_be_removed_rds_providers.emplace_back(std::move(route_provider_by_scope_[scope_name])); |
There was a problem hiding this comment.
Have you considered obtaining the iterator instead to avoid a second lookup in the erase()?
| } | ||
|
|
||
| // Tests that conflict resources are detected. | ||
| // Tests that conflict resources in the same push are detected. |
There was a problem hiding this comment.
nit: 's/push/config update' to maintain consistency with Envoy terminology.
| } | ||
|
|
||
| // Tests that scope-key conflict resources in different pushes are handled correctly. | ||
| TEST_F(ScopedRdsTest, ScopeKeyReuseInDifferentPushes) { |
There was a problem hiding this comment.
nit:s/pushes/config updates
| ->getRouteConfig(TestHeaderMapImpl{{"Addr", "x-foo-key;x-foo-key"}}) | ||
| ->name(), | ||
| "foo_routes"); | ||
| } |
There was a problem hiding this comment.
I suggest also testing the edge case where the scope key is reused but the route_configuration_name is new.
There was a problem hiding this comment.
added a scenario where new scope has the same key but different route-table name that will (conflict/remove-old-add-new) with existing scope.
Signed-off-by: Xin Zhuang <stevenzzz@google.com>
|
/assign htuch |
| } | ||
|
|
||
| bool ScopedRdsConfigSubscription::removeScopes( | ||
| std::list<std::unique_ptr<ScopedRdsConfigSubscription::RdsRouteConfigProviderHelper>> |
There was a problem hiding this comment.
I think it's worth it, this is a long type and it's repeated in several places; however, I'll leave it up to the final reviewer.
* master: (167 commits) stats: Avoid asserts in fuzz-tests by eliminating arbitrary length limits, using the new MemBlock wrapper for memcpy (envoyproxy#8779) Make %UPSTREAM_LOCAL_ADDRESS% access-log format work for HTTP requests. (envoyproxy#9362) tools: API boosting support for using decls and enum constants. (envoyproxy#9418) Fix incorrect cluster InitializePhase type (envoyproxy#9379) build: fix merge race between envoyproxy#9241 and envoyproxy#9413. (envoyproxy#9427) fuzz: fix incorrect evaluator test (envoyproxy#9402) server: fix bogus startup log message (envoyproxy#9404) tools: Add protoxform tests (envoyproxy#9241) api: options after import (envoyproxy#9413) misc: use std::move instead of constructing a copy (envoyproxy#9415) tools: API boosting support for rewriting elaborated types. (envoyproxy#9375) docs: fix invalid transport_socket value (envoyproxy#9403) fix typo in docs (envoyproxy#9394) srds: remove to-de-removed scopes first and then apply additions to avoid scope key conflict. (envoyproxy#9366) api: generate whole directory and sync (envoyproxy#9382) bazel: Add load statements for proto_library (envoyproxy#9367) Fix typo (envoyproxy#9388) Correct test of OptionsImpl argc type (Was: Correct type for std::array size() result) (envoyproxy#9290) http1 encode trailers in chunk encoding (envoyproxy#8667) Add mode to PipeInstance (envoyproxy#8423) ...
…void scope key conflict. (envoyproxy#9366) Remove scopes first then add scopes to avoid scope key conflict when a new scope has the same key as an existing scope Risk Level: MID Testing: unit test Docs Changes: Release Notes: Fixes: envoyproxy#9349 Signed-off-by: Xin Zhuang <stevenzzz@google.com> Signed-off-by: Prakhar <prakhar_au@yahoo.com>
Description: remove scopes first then add scopes to avoid scope key conflict when a new scope has the same key as an existing scope
Risk Level: MID
Testing: unit test
Docs Changes:
Release Notes:
Fixes: #9349