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

Added a test to verify vhds updates when client closes connection #11341

Merged
merged 7 commits into from
Jun 10, 2020
Merged

Added a test to verify vhds updates when client closes connection #11341

merged 7 commits into from
Jun 10, 2020

Conversation

dmitri-d
Copy link
Contributor

@dmitri-d dmitri-d commented May 28, 2020

This is to help with #9784

Risk Level: Low (added a single test)
Testing: a new unit test
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
@@ -37,6 +37,8 @@ void OnDemandRouteUpdate::setDecoderFilterCallbacks(Http::StreamDecoderFilterCal
callbacks_ = &callbacks;
}

void OnDemandRouteUpdate::onDestroy() { route_config_updated_callback_.reset(); }
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding a test for this!

So you're resetting the callback, but what tells the caller of the callback to not call it?
you've created this lambda capturing this of the filter, and if the filter is destroyed, and the resolution completes, won't the callback still be called?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The callback pointer is eventually stored in a weak_ptr, which is verified before the invocation: https://github.com/envoyproxy/envoy/blob/master/source/common/router/rds_impl.cc#L288. A longer description of what's going on in relation to the callback is here: #9784 (comment).

createDeltaDiscoveryResponseWithResourceNameUsedAsAlias();
vhds_stream_->sendGrpcMessage(vhds_update);

codec_client_->close();
Copy link
Contributor

Choose a reason for hiding this comment

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

So I think a more interesting test would be to reset the stream, but not the connection. In that case the HCM will persist beyond the life of the stream, and I think you'll hit the lifetime issue Matt and I see.

I think rather than a simple lambda, you need something with a bit more state, so you can cancel the actual callback if the filter goes away.

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 think rather than a simple lambda, you need something with a bit more state, so you can cancel the actual callback if the filter goes away.

The state of the callback (whether it and the filter-chain are still active) is handled implicitly via shared_ptr - weak_ptr combination (pls. see #9784 (comment) for more details)

Copy link
Contributor

Choose a reason for hiding this comment

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

If it's not clear in the code, (which IMO it's not, especially given how many autos there are in here:
https://github.com/envoyproxy/envoy/blob/master/source/common/router/rds_impl.cc#L288
making it hard to tell what's going on w.r.t. weak pointers - mind adding some comments to onDestroy to explain it for posterity?

Also, please change this test to reset the stream without closing the connection.
thanks!

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

dmitri-d commented Jun 3, 2020

  • added comments re: use of the weak_ptr
  • Updated test to reset the upstream connection.

@alyssawilk

// EXPECT_EQ(
// initial_config_reloads + 1UL,
// TestUtility::findCounter(stats, "http.config_test.vhds.my_route.config_reload")->value());
cleanupUpstreamAndDownstream();
Copy link
Contributor

Choose a reason for hiding this comment

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

let's wait for the client_codec_->waitForEndStream() and assert the connection is connected, to make sure we're covering the case we're trying to cover (stream is reset,connection is not)

Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

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

Almost there on the tests - let's get that sorted out and make CI happy, and I'll do a full round of review.
thanks!

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

dmitri-d commented Jun 4, 2020

Please note that trying to do waitForEndStream() times out -as no data is being exchanged. I used waitForReset() instead, although I think it's redundant.

Dmitri Dolguikh added 2 commits June 4, 2020 14:53
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
@alyssawilk
Copy link
Contributor

hm, coverage is still failing after I kicked it this morning. Could you try a master merge?

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

dmitri-d commented Jun 8, 2020

  • merged in latest master

@alyssawilk
Copy link
Contributor

Could you update the PR description to follow the template? As soon as that's done I am happy to merge.

@dmitri-d
Copy link
Contributor Author

dmitri-d commented Jun 9, 2020

Could you update the PR description to follow the template? As soon as that's done I am happy to merge.

done

@alyssawilk alyssawilk merged commit 9d702c1 into envoyproxy:master Jun 10, 2020
@dmitri-d dmitri-d deleted the fix-vhds-tsan-failures branch June 10, 2020 15:51
yashwant121 pushed a commit to yashwant121/envoy that referenced this pull request Jun 24, 2020
This is to help with envoyproxy#9784

Risk Level: Low (added a single test)
Testing: a new unit test and integration test
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: yashwant121 <yadavyashwant36@gmail.com>
songhu pushed a commit to songhu/envoy that referenced this pull request Jun 25, 2020
This is to help with envoyproxy#9784

Risk Level: Low (added a single test)
Testing: a new unit test and integration test
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
yashwant121 pushed a commit to yashwant121/envoy that referenced this pull request Jul 24, 2020
This is to help with envoyproxy#9784

Risk Level: Low (added a single test)
Testing: a new unit test and integration test
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: yashwant121 <yadavyashwant36@gmail.com>
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