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

Fixes #7617 - fixes handling creation of VHDS subscription after Init… #8650

Merged
merged 4 commits into from
Nov 27, 2019
Merged

Fixes #7617 - fixes handling creation of VHDS subscription after Init… #8650

merged 4 commits into from
Nov 27, 2019

Conversation

dmitri-d
Copy link
Contributor

…Manager has completed initialization

Signed-off-by: Dmitri Dolguikh ddolguik@redhat.com

For an explanation of how to fill out the fields, please see the relevant section
in PULL_REQUESTS.md

Description: Fixes #7617
Risk Level:
Testing: added an integration test
Docs Changes:
Release Notes:
[Optional Fixes #Issue] #7617
[Optional Deprecated:]

Copy link
Contributor

@lambdai lambdai left a comment

Choose a reason for hiding this comment

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

Thank you for the fix!
Could you fix below and explain the cleanup block? Thanks!

// Initialize a no-op InitManager in case the one in the factory_context has completed
// initialization. This can happen if an RDS config update for an already established RDS
// subscription contains VHDS configuration.
void RdsRouteConfigSubscription::maybeCreateInitManager(
Copy link
Contributor

Choose a reason for hiding this comment

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

style: return unique_ptrInit::Manager. Maybe optionalInit::ManagerImpl

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'm populating both init_manager and init_vhds method parameters, I think returning just one of them as the result of the method call would be confusing...

source/common/router/rds_impl.cc Outdated Show resolved Hide resolved
source/common/router/rds_impl.cc Outdated Show resolved Hide resolved
Copy link
Contributor

@lambdai lambdai left a comment

Choose a reason for hiding this comment

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

Fat finger before. Update my opinion. Sorry!

@zuercher
Copy link
Member

/wait

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

Requesting changes on this one also just to make sure that we have documentation before landing any more VHDS changes. Thank you for making Envoy's documentation first class! :)

@dmitri-d
Copy link
Contributor Author

@mattklein123: This is just a bugfix, with no changes to existing VHDS functionality, not sure what docs you wanted to go with this PR.

@mattklein123
Copy link
Member

@mattklein123: This is just a bugfix, with no changes to existing VHDS functionality, not sure what docs you wanted to go with this PR.

There are no docs for VHDS currently. I'm using these PRs as a forcing function to get docs into the code base. We should have never gotten this far without docs.

@dmitri-d
Copy link
Contributor Author

  • rebased, responded to feedback

@dmitri-d
Copy link
Contributor Author

  • added a test that verifies creation of a noop init manager

@dmitri-d
Copy link
Contributor Author

ping @lambdai

lambdai
lambdai previously approved these changes Oct 31, 2019
Copy link
Contributor

@lambdai lambdai left a comment

Choose a reason for hiding this comment

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

Thank you! The new integration test case is awesome!

@lambdai
Copy link
Contributor

lambdai commented Oct 31, 2019

Could you merge master to see if test passes?

@dmitri-d
Copy link
Contributor Author

dmitri-d commented Nov 1, 2019

  • rebased and squashed the commits

@zuercher
Copy link
Member

zuercher commented Nov 1, 2019

You have a use-after-free error because the std::unique_ptr<Cleanup> you construct has a reference to the std::unique_ptr<Init::ManagerImpl>. The init manager is being destroyed first in this test and when the cleanup runs it references freed memory.

Rather than just fixing the ordering in the test, I think it's probably better to figure out a way to remove or make explicit the destruction order dependency.

@dmitri-d
Copy link
Contributor Author

dmitri-d commented Nov 4, 2019

@zuercher: the issue was that the route_config_provider created by route_config_provider_manager_->createRdsRouteConfigProvider call was going out of scope and taking the subscription with it.

@dmitri-d
Copy link
Contributor Author

dmitri-d commented Nov 4, 2019

ping @lambdai

@dmitri-d
Copy link
Contributor Author

dmitri-d commented Nov 7, 2019

  • rebased

ping @lambdai: I think this is ready to be merged now.

…Manager has completed initialization

Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
@dmitri-d
Copy link
Contributor Author

  • rebased

ping @lambdai

lambdai
lambdai previously approved these changes Nov 14, 2019
Copy link
Contributor

@lambdai lambdai left a comment

Choose a reason for hiding this comment

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

LGTM in terms of the core fix: The lifetime of CleanUp and Init::Manager is correct.

I don't understand the fuzz failure.

@lambdai
Copy link
Contributor

lambdai commented Nov 14, 2019

CC @zuercher for more comments

Copy link
Member

@zuercher zuercher left a comment

Choose a reason for hiding this comment

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

Couple relatively minor things.

@mattklein123 were you documentation concerns addressed?

@@ -111,6 +115,9 @@ class RdsRouteConfigSubscription : Envoy::Config::SubscriptionCallbacks,
return route_config_providers_;
}
RouteConfigUpdatePtr& routeConfigUpdate() { return config_update_info_; }
void maybeCreateInitManager(const std::string& version_info,
Copy link
Member

Choose a reason for hiding this comment

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

Let's not leak this method into the public API of this class. Is it not possible to test its behavior in the context of onConfigUpdate?

Copy link
Contributor Author

@dmitri-d dmitri-d Nov 20, 2019

Choose a reason for hiding this comment

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

Let's not leak this method into the public API of this class.

This is a concrete implementation class, not a public interface. I very strongly prefer testability over encapsulation in such a case.

Is it not possible to test its behavior in the context of onConfigUpdate?

I'm trying to test this in isolation; the setup is already difficult (and fragile) enough without dragging in another method.

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps make it private and make the test class a friend so that it can access it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would result in a dependency to test code in production code, would it not?

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 the friend class statement constitutes a forward reference and needn't ever be declared, but I could be wrong.

@@ -72,6 +72,16 @@ const char Config[] = R"EOF(
cluster_name: xds_cluster
)EOF";

const char RdsWithoutVhdsConfig[] = R"EOF(
Copy link
Member

Choose a reason for hiding this comment

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

We prefer these configs to are created using the protobuf objects directly rather than parsing configs.

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 is the first time I hear about this preference. This test suit been around for a while now, with this exact setup (and it's not the only test suite to use yaml for setup).

FWIW, configurations used in these tests have enough nested fields/protobufs that building them programmatically will be laborious and harder to read.

Copy link
Member

Choose a reason for hiding this comment

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

The ConfigHelper object underlying the integration test should be helpful here. I'm ok if you leave this as-is for now with a todo to circle back and refactor this test to use ConfigHelper. I think it's a matter of picking one of the default configs from test/utility/config.cc, adding your RDS/VHDS clusters with a ConfigModifier, and adding virtual hosts either with addVirtualHost or createVirtualHost.

Copy link
Contributor Author

@dmitri-d dmitri-d Nov 22, 2019

Choose a reason for hiding this comment

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

I disagree re: adding vhds to one of default configs (shared test configuration couples independent tests and can make them brittle), but I see value in adding helper methods to generate VHDS config. Will do, but in a separate PR if that's ok.

@@ -100,6 +110,113 @@ name: my_route
cluster_name: xds_cluster
)EOF";

const char VhostTemplate[] = R"EOF(
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

@mattklein123
Copy link
Member

@mattklein123 were you documentation concerns addressed?

There is still no documentation merged for VHDS. Since this is a bug fix I won't hold this PR hostage, but nothing else will be merged until there is docs.

@dmitri-d
Copy link
Contributor Author

ping @zuercher, @lambdai

Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
@dmitri-d
Copy link
Contributor Author

  • updated with the latest changes from master

@lambdai
Copy link
Contributor

lambdai commented Nov 22, 2019

@dmitri-d My understanding is that it's only a TODO away from @zuercher 's approval on this PR

@lambdai
Copy link
Contributor

lambdai commented Nov 22, 2019

The rest LGTM

Dmitri Dolguikh added 2 commits November 22, 2019 18:21
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
@dmitri-d
Copy link
Contributor Author

  • added a todo re: test configuration
  • merged latest changes from upstream master

@dmitri-d
Copy link
Contributor Author

ping @lambdai, @zuercher

@zuercher zuercher dismissed mattklein123’s stale review November 27, 2019 17:56

Per comment that we'll allow this fix, dimissing Matt's change request.

@zuercher zuercher merged commit fb628ce into envoyproxy:master Nov 27, 2019
@dmitri-d dmitri-d deleted the vhds-init-manager branch May 20, 2020 19:45
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.

[xDS] VHDS support of subscription creation after initManager.initiliaze()
4 participants