Skip to content

upstream: fix duplicate clusters#4012

Merged
mattklein123 merged 2 commits intoenvoyproxy:masterfrom
ramaraochavali:fix/cds_duplicate_crash
Aug 2, 2018
Merged

upstream: fix duplicate clusters#4012
mattklein123 merged 2 commits intoenvoyproxy:masterfrom
ramaraochavali:fix/cds_duplicate_crash

Conversation

@ramaraochavali
Copy link
Copy Markdown
Contributor

Signed-off-by: Rama rama.rao@salesforce.com
Description: Fixes envoy crash with duplicate clusters in cds response.
Risk Level: Low
Testing: Added Automated tests
Docs Changes: N/A
Release Notes: N/A

Fixes #3987

Signed-off-by: Rama <rama.rao@salesforce.com>
@mattklein123 mattklein123 self-assigned this Aug 1, 2018
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for fixing this. A couple of comments.

std::unordered_set<std::string> cluster_names;
for (const auto& cluster : resources) {
if (!cluster_names.insert(cluster.name()).second) {
throw EnvoyException("duplicate clusters found");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you say which cluster is duplicated?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can, if we have multiple need to maintain the list and combine all of them as single string display? -NBD, I can do that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would just keep it simple and fail on the first one you find and print the cluster...

auto* cluster_2 = clusters.Add();
cluster_2->set_name("duplicate_cluster");

EXPECT_THROW(dynamic_cast<CdsApiImpl*>(cds_.get())->onConfigUpdate(clusters, ""), EnvoyException);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

EXPECT_THROW_WITH_MESSAGE?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will change...

Signed-off-by: Rama <rama.rao@salesforce.com>
@ramaraochavali
Copy link
Copy Markdown
Contributor Author

@mattklein123 addressed comments. PTAL.

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

@mattklein123 mattklein123 merged commit 61421bd into envoyproxy:master Aug 2, 2018
@ramaraochavali ramaraochavali deleted the fix/cds_duplicate_crash branch August 3, 2018 03:53
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.

2 participants