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 GOAWAY frame send on client transport shutdown #4248

Closed
wants to merge 4 commits into from

Conversation

zasweq
Copy link
Contributor

@zasweq zasweq commented Mar 6, 2021

Fixes issue #460. The data of the GOAWAY frame is that of a peer attempting a graceful shutdown according to the HTTP/2 spec (ErrCodeNo, Stream ID of 2 ^ 32 - 1). Eventually, seen by Doug's comment in #4190, it is desirable to pass an error into http2_client.close(), which will end up in the GOAWAY frame, but for now any GOAWAY frame sent is better than none.

@zasweq zasweq requested a review from dfawley March 6, 2021 16:39
@zasweq zasweq added this to the 1.37 Release milestone Mar 6, 2021
Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

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

Please check the test failures; I suspect they are real errors.

// The HTTP/2 spec mentions that a GOAWAY frame should be sent before a connection close. If this close() function
// ever starts to take in an HTTP/2 error code the peer will be able to get more information about the reason
// behind the connection close.
if err := t.framer.fr.WriteGoAway(math.MaxUint32, http2.ErrCodeNo, []byte{}); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

If writing the GOAWAY fails, we still need to close the conn and do the other cleanup below, like adding an error to any streams that are still open.

// The HTTP/2 spec mentions that a GOAWAY frame should be sent before a connection close. If this close() function
// ever starts to take in an HTTP/2 error code the peer will be able to get more information about the reason
// behind the connection close.
if err := t.framer.fr.WriteGoAway(math.MaxUint32, http2.ErrCodeNo, []byte{}); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

It's possible we want to do some refactoring here. I think I was expecting we'd pass an error to http2Client.Close, and that would dictate the code used here -- OR, pass the code in directly. Anywhere we already send a GOAWAY, we could delete that and rely on this to do it instead. Or we need a way to call Close to indicate a GOAWAY was already sent, and so Close should not send another one.

@dfawley dfawley assigned zasweq and unassigned dfawley Mar 9, 2021
@menghanl
Copy link
Contributor

Closing this PR now. Let's get back to this when it's ready.

@menghanl menghanl closed this Mar 11, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants