-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
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 |
There was a problem hiding this 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. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update comment.
oopps, done.
@@ -184,12 +184,15 @@ bool ScopedRdsConfigSubscription::addOrUpdateScopes( | |||
return any_applied; | |||
} | |||
|
|||
bool ScopedRdsConfigSubscription::removeScopes( | |||
std::list<std::unique_ptr<ScopedRdsConfigSubscription::RdsRouteConfigProviderHelper>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using an alias for this type to improve readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's only used within this module, I would leave it if you don't feel strongly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered obtaining the iterator instead to avoid a second lookup in the erase()
?
@@ -414,7 +414,7 @@ route_configuration_name: foo_routes | |||
"foo_routes"); | |||
} | |||
|
|||
// Tests that conflict resources are detected. | |||
// Tests that conflict resources in the same push are detected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: 's/push/config update' to maintain consistency with Envoy terminology.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -477,6 +477,70 @@ route_configuration_name: foo_routes | |||
"foo_routes"); | |||
} | |||
|
|||
// Tests that scope-key conflict resources in different pushes are handled correctly. | |||
TEST_F(ScopedRdsTest, ScopeKeyReuseInDifferentPushes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:s/pushes/config updates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
->getRouteConfig(TestHeaderMapImpl{{"Addr", "x-foo-key;x-foo-key"}}) | ||
->name(), | ||
"foo_routes"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
@@ -184,12 +184,15 @@ bool ScopedRdsConfigSubscription::addOrUpdateScopes( | |||
return any_applied; | |||
} | |||
|
|||
bool ScopedRdsConfigSubscription::removeScopes( | |||
std::list<std::unique_ptr<ScopedRdsConfigSubscription::RdsRouteConfigProviderHelper>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
* 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