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

http inspector:inline the recv in the onAccept #8111

Merged
merged 3 commits into from
Sep 17, 2019

Conversation

lambdai
Copy link
Contributor

@lambdai lambdai commented Aug 30, 2019

Signed-off-by: Yuchen Dai [email protected]

Similar to #7951

Description:

There is one behavior change.
This PR watch Closed type event. On closed event http_inspector close the connection and http_inspector doesn't pass to follow up listener filters
Closed indicates a FIN is received on the OS supporting this event.
Upon Closed event http inspector would parse the last round. If the parser cannot determine the protocol is http this listener would give up since there is no more data from client.
Previous behavior: watch only READ event and hoping peek would return errno.

With this PR:

  1. A poll cycle is saved.
  2. A client stream "ping"+FIN flag could pass the listener filter. Not sure this is very useful in production but it helps me debug with ping-pong client server. And this behavior is less surprising.

I am not sure what event libevent would pass on when socket buffer is not empty and if peek would return -1 under this condition.

Risk Level: MID
Testing: UT
Docs Changes:
Release Notes:
[Optional Fixes #Issue]
[Optional Deprecated:]

@lambdai lambdai requested a review from lizan as a code owner August 30, 2019 22:41
@lambdai
Copy link
Contributor Author

lambdai commented Aug 30, 2019

CC initial author @yxue

@lambdai
Copy link
Contributor Author

lambdai commented Aug 31, 2019

To reviewer: the wrong spelling is intended

@htuch
Copy link
Member

htuch commented Sep 3, 2019

@yxue would be great if you could take a first pass on this review, thanks.

@yxue
Copy link
Contributor

yxue commented Sep 3, 2019

@yxue would be great if you could take a first pass on this review, thanks.

Sure! I was reviewing and should finish the first pass earlier tomorrow.

socket.ioHandle().fd(),
[this](uint32_t events) {
if (events & Event::FileReadyType::Closed) {
config_->stats().read_error_.inc();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to increase the read_error_ here?

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's a great point! I found out Closed actually means the client send FIN. It is probably not an error.
According to the above observation the latest commit allow http inspector to finalize the parse. Please review!

@lambdai
Copy link
Contributor Author

lambdai commented Sep 3, 2019

Update the description

@lizan
Copy link
Member

lizan commented Sep 6, 2019

@lambdai fix format?
/wait

@lambdai
Copy link
Contributor Author

lambdai commented Sep 6, 2019

@lizan double checked the format is the spelling in string literal and it is intended. Do you known any annotation so that we can skip the check in certain line?

@lizan
Copy link
Member

lizan commented Sep 6, 2019

@jmarantz any idea above?

@lambdai
Copy link
Contributor Author

lambdai commented Sep 10, 2019

Gentle ping @jmarantz

@stale
Copy link

stale bot commented Sep 17, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Sep 17, 2019
Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

The blocker on this is this error from the pedantic checker:

check_spelling_pedantic...
./test/extensions/filters/listener/http_inspector/http_inspector_test.cc:457:  const absl::string_view data = "GET /index HTT\r";
Checked 2284 file(s) and 59998 comment(s), found 1 error(s).
ERROR: spell check failed. Run 'tools/check_spelling_pedantic.py fix and/or add new words to tools/spelling_dictionary.txt'

for the record I did not create the pedantic spell checker (even though I am pedantic in other things) and find it annoying though I also see the value.

Suggestions for solutions:

  1. Find a way in the pedantic checker to allow for a // NOPEDANTIC escape on the line in question, or similar. This is IMO the best option as it saves a ton of annoyance for others later.
  2. This test on line 457 looking for "GET /index HTT\r looks kind of broken. Is it meant to be that way? Fix it by changing HTT to HTTP/1.1 or similar?
  3. If you really need to send that string you could maybe octal-escape the "HTT" part?

I realize also you didn't even change that part of the code but are being dinged because you are editing a file that probably predated the pedantic spell checker. Not sure what to say..

@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Sep 17, 2019
typos and fix spelling

Signed-off-by: Yuchen Dai <[email protected]>
@lambdai
Copy link
Contributor Author

lambdai commented Sep 17, 2019

/retest ci/circleci: asan

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: asan (failed build)

🐱

Caused by: a #8111 (comment) was created by @lambdai.

see: more, trace.

Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

this last change to side-step the pedantic check LGTM.

Please try to avoid force-pushing in the future though as it removes comment history from the PR review process. Just do normal pushes.

const absl::string_view data = "GET /index HTT\r";
const std::string valid_header = "GET /index HTTP/1.1\r";
// offset: 0 10
const std::string truncate_header = valid_header.substr(0, 14).append("\r");
Copy link
Member

Choose a reason for hiding this comment

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

🤦‍♂

@lizan lizan merged commit 99004b8 into envoyproxy:master Sep 17, 2019
@lambdai
Copy link
Contributor Author

lambdai commented Sep 17, 2019

this last change to side-step the pedantic check LGTM.

Please try to avoid force-pushing in the future though as it removes comment history from the PR review process. Just do normal pushes.

I won't if the commits attached with comment.

@jmarantz What if I modify the last commits that no one comment?

@jmarantz
Copy link
Contributor

idk; why would you need to? why not just do normal commits always?

I guess there can be a race where you think no one has commented, but someone is commenting while you are doing the force-push.

@lambdai lambdai deleted the httpins branch September 17, 2019 22:39
danzh2010 pushed a commit to danzh2010/envoy that referenced this pull request Sep 24, 2019
Description:

There is one behavior change. 
This PR watch Closed type event. `Closed` indicates a FIN is received on the OS supporting this event.
Upon `Closed` event http inspector would parse the last round. If the parser cannot determine the protocol is http this listener would give up since there is no more data from client.
Previous behavior: watch only READ event and hoping peek would return errno.

With this PR: 
1. A poll cycle is saved.
2. A client stream "ping"+FIN flag could pass the listener filter. Not sure this is very useful in production but it helps me debug with ping-pong client server. And this behavior is less surprising.

Risk Level: MID
Testing: UT
Docs Changes:
Release Notes:

Signed-off-by: Yuchen Dai <[email protected]>
danzh2010 pushed a commit to danzh2010/envoy that referenced this pull request Oct 4, 2019
Description:

There is one behavior change. 
This PR watch Closed type event. `Closed` indicates a FIN is received on the OS supporting this event.
Upon `Closed` event http inspector would parse the last round. If the parser cannot determine the protocol is http this listener would give up since there is no more data from client.
Previous behavior: watch only READ event and hoping peek would return errno.

With this PR: 
1. A poll cycle is saved.
2. A client stream "ping"+FIN flag could pass the listener filter. Not sure this is very useful in production but it helps me debug with ping-pong client server. And this behavior is less surprising.

Risk Level: MID
Testing: UT
Docs Changes:
Release Notes:

Signed-off-by: Yuchen Dai <[email protected]>
danzh2010 pushed a commit to danzh2010/envoy that referenced this pull request Oct 4, 2019
Description:

There is one behavior change. 
This PR watch Closed type event. `Closed` indicates a FIN is received on the OS supporting this event.
Upon `Closed` event http inspector would parse the last round. If the parser cannot determine the protocol is http this listener would give up since there is no more data from client.
Previous behavior: watch only READ event and hoping peek would return errno.

With this PR: 
1. A poll cycle is saved.
2. A client stream "ping"+FIN flag could pass the listener filter. Not sure this is very useful in production but it helps me debug with ping-pong client server. And this behavior is less surprising.

Risk Level: MID
Testing: UT
Docs Changes:
Release Notes:

Signed-off-by: Yuchen Dai <[email protected]>
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.

5 participants