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

Server should send RST_STREAM when deadline is exceeded #2

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

misvivek
Copy link
Owner

@misvivek misvivek commented Oct 1, 2024

Problem:

#issue no: 2886
Server should send RST_STREAM when deadline is exceeded
Action:

Added the condition for RST_STREAM once status code matches

Release note:

NA

@@ -1104,6 +1104,9 @@ func (t *http2Server) WriteStatus(s *Stream, st *status.Status) error {
}
// Send a RST_STREAM after the trailers if the client has not already half-closed.
rst := s.getState() == streamActive
if st.Code() == codes.DeadlineExceeded {

Choose a reason for hiding this comment

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

can you write a test for this or modify an exsting test to verify?

Copy link

@purnesh42H purnesh42H Oct 9, 2024

Choose a reason for hiding this comment

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

How did you verify if this is the only change we need? Did you test we are actually getting RST_STREAM at client?

Copy link
Owner Author

@misvivek misvivek Oct 10, 2024

Choose a reason for hiding this comment

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

@purnesh42H Please find the screen once putting the sleep time 40sec, deadline exceed we are getting if we are remove the check "context cancel" respectively in the flow_control feature example image

Choose a reason for hiding this comment

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

you need to write a test to verify where client is receiving RST_STREAM when deadline exceeded. Check existing tests where RST_STREAM is sent

Copy link
Owner Author

Choose a reason for hiding this comment

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

sure @purnesh42H I will do same

@@ -1042,6 +1042,18 @@ func (t *http2Server) writeHeaderLocked(s *Stream) error {
return nil
}

type NoopFunc func()

var noop NoopFunc = func() {

Choose a reason for hiding this comment

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

please see how other noop functions are implemented. There are some for goaway tests. Please make a habit of going through existing code to get an idea.

Give meaningful name to it. May be something like SignalDeadlineExceededForTesting. Also, it should not be exported.

@@ -1042,6 +1042,18 @@ func (t *http2Server) writeHeaderLocked(s *Stream) error {
return nil
}

type NoopFunc func()

Choose a reason for hiding this comment

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

why this? Please remove

Copy link
Owner Author

Choose a reason for hiding this comment

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

removed

// Default noop function does nothing
}

func setRstAndCallNoop(rst *bool) {

Choose a reason for hiding this comment

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

this is not needed either. Please remove

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

@@ -1104,6 +1116,10 @@ func (t *http2Server) WriteStatus(s *Stream, st *status.Status) error {
}
// Send a RST_STREAM after the trailers if the client has not already half-closed.
rst := s.getState() == streamActive
if st.Code() == codes.DeadlineExceeded {
rst = true
setRstAndCallNoop(&rst)

Choose a reason for hiding this comment

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

you should just call the noop function here which is overriden in the test

ch <- struct{}{}
}
var rst bool
setRstAndCallNoop(&rst)

Choose a reason for hiding this comment

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

this has to be declared in the test. Please see resolver tests how things are being done there. You need to also assign it back to original definition

@misvivek misvivek requested a review from purnesh42H November 7, 2024 04:05
@misvivek misvivek force-pushed the rst-stream-on-deadline-exceed branch from 8bdfb99 to 5ce3627 Compare November 7, 2024 20:44
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