Skip to content

fix NPE In refreshCachedRoute#6359

Merged
mattklein123 merged 4 commits intoenvoyproxy:masterfrom
yuval-k:fix-crash-before-headers
Mar 25, 2019
Merged

fix NPE In refreshCachedRoute#6359
mattklein123 merged 4 commits intoenvoyproxy:masterfrom
yuval-k:fix-crash-before-headers

Conversation

@yuval-k
Copy link
Copy Markdown
Contributor

@yuval-k yuval-k commented Mar 22, 2019

Fix refreshCachedRoute not check if request headers are null

Risk Level: Low
Testing: Added unit test
Docs Changes: N/A
Release Notes: N/A
Fixes #6348

Signed-off-by: Yuval Kohavi <yuval.kohavi@gmail.com>
Signed-off-by: Yuval Kohavi <yuval.kohavi@gmail.com>
@yuval-k yuval-k force-pushed the fix-crash-before-headers branch from f5e2349 to 37adccd Compare March 22, 2019 19:12
Copy link
Copy Markdown
Member

@venilnoronha venilnoronha 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 fixing this.

// encodeHeaders()/encodeData().
EXPECT_CALL(*idle_timer, enableTimer(_)).Times(2);
EXPECT_CALL(*idle_timer, disableTimer());
// Simulate and idle timeout so that the filter chain gets created
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.

nit: end the comment with a period for consistency.

Buffer::OwnedImpl fake_input;
conn_manager_->onData(fake_input, false);

// This should not be called as we don't have request headers
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.

nit: end the comment with a period for consistency.

EXPECT_CALL(*encoder_filters_[0], encodeComplete());
EXPECT_CALL(*encoder_filters_[0], onDestroy());

// 408 direct response after timeout.
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.

Unrelated comment?

EXPECT_CALL(*route_config_provider_.route_config_, route(_, _)).Times(0);

// Under heavy load it is possible that stream timeout will be reached before any headers were
// received. Envoy will creates a local reply that will go through the encoder filter chain. we
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.

s/creates/create

EXPECT_CALL(*route_config_provider_.route_config_, route(_, _)).Times(0);

// Under heavy load it is possible that stream timeout will be reached before any headers were
// received. Envoy will creates a local reply that will go through the encoder filter chain. we
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.

s/we/We

Signed-off-by: Yuval Kohavi <yuval.kohavi@gmail.com>
@yuval-k yuval-k force-pushed the fix-crash-before-headers branch from 9958f26 to 704f43c Compare March 22, 2019 21:52
@yuval-k
Copy link
Copy Markdown
Contributor Author

yuval-k commented Mar 22, 2019

/retest

@repokitteh-read-only
Copy link
Copy Markdown

🙀 failed invoking rebuild of ci/circleci: mac: 500 Internal Server Error

🐱

Caused by: a #6359 (comment) was created by @yuval-k.

see: more, trace.

@mattklein123 mattklein123 self-assigned this Mar 22, 2019
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.

Thank you so much for the quick fix. One small request to improve the test.

/wait

// Under heavy load it is possible that stream timeout will be reached before any headers were
// received. Envoy will create a local reply that will go through the encoder filter chain. We
// want to make sure that encoder filters get a null route object.
auto route = encoder_filters_[0]->callbacks_->route();
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.

Instead of doing this here, can you potentially make this test a little more realistic by installing a mocker encoder filter and actually calling route() from within that filter's callbacks similar to what your filter does? You can see examples below in this file of how to setup a mock filter, it should be pretty simple.

Signed-off-by: Yuval Kohavi <yuval.kohavi@gmail.com>
@yuval-k
Copy link
Copy Markdown
Contributor Author

yuval-k commented Mar 23, 2019

/retest - compile_time_options stuck for 15 hours

@repokitteh-read-only
Copy link
Copy Markdown

🐴 hold your horses - no failures detected, yet.

🐱

Caused by: a #6359 (comment) was created by @yuval-k.

see: more, trace.

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.

Sweet, thanks.

@benishak
Copy link
Copy Markdown

thanks a lot guys
when will it be merged?

@benishak
Copy link
Copy Markdown

@mattklein123?

@mattklein123 mattklein123 merged commit dcf5544 into envoyproxy:master Mar 25, 2019
@yuval-k yuval-k deleted the fix-crash-before-headers branch March 26, 2019 11: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

Development

Successfully merging this pull request may close these issues.

4 participants