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

srds: remove to-de-removed scopes first and then apply additions to avoid scope key conflict. #9366

Merged
merged 3 commits into from
Dec 18, 2019

Conversation

stevenzzzz
Copy link
Contributor

@stevenzzzz stevenzzzz commented Dec 16, 2019

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

…a new scope has the same key as an existing scope.

Signed-off-by: Xin Zhuang <stevenzzz@google.com>
@stevenzzzz stevenzzzz changed the title Scoped rds conflict srds: remove to-de-removed scopes first and then apply additions to avoid scope conflict. Dec 17, 2019
@stevenzzzz stevenzzzz changed the title srds: remove to-de-removed scopes first and then apply additions to avoid scope conflict. srds: remove to-de-removed scopes first and then apply additions to avoid scope key conflict. Dec 17, 2019
@stevenzzzz
Copy link
Contributor Author

/assign AndresGuedez

Signed-off-by: Xin Zhuang <stevenzzz@google.com>
Copy link
Contributor

@AndresGuedez AndresGuedez left a 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.

@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

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

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

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>>
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

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

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.
Copy link
Contributor

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.

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

@@ -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) {
Copy link
Contributor

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

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

->getRouteConfig(TestHeaderMapImpl{{"Addr", "x-foo-key;x-foo-key"}})
->name(),
"foo_routes");
}
Copy link
Contributor

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.

Copy link
Contributor Author

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

/assign htuch

@@ -184,12 +184,15 @@ bool ScopedRdsConfigSubscription::addOrUpdateScopes(
return any_applied;
}

bool ScopedRdsConfigSubscription::removeScopes(
std::list<std::unique_ptr<ScopedRdsConfigSubscription::RdsRouteConfigProviderHelper>>
Copy link
Contributor

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.

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!

@htuch htuch merged commit 58802ba into envoyproxy:master Dec 18, 2019
spenceral added a commit to spenceral/envoy that referenced this pull request Dec 20, 2019
* 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)
  ...
prakhag1 pushed a commit to prakhag1/envoy that referenced this pull request Jan 3, 2020
…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>
@stevenzzzz stevenzzzz deleted the scoped-rds-conflict branch June 25, 2020 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants