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

go extension trailer add api #27350

Merged
merged 3 commits into from
May 16, 2023
Merged

Conversation

StarryVae
Copy link
Contributor

Commit Message: go extension trailer add api
Additional Description: N/A
Risk Level: low
Testing: integration test
Docs Changes: N/A
Release Notes: N/A

@StarryVae
Copy link
Contributor Author

@doujiang24 Hi, here is the trailer add api for go extension, and i find some bug in trailer phase when i try to add trailer related integration test, but i am not sure if it is fixed correctly.

When StopAndBuffer is return in decodeHeaders phase, state will be WaitingAllData, so doDataGo will be called in doTrailer, but in this scenario, doDataList is not move out back to body. And doTrailerGo should also be called when isBufferDataEmpty is true, otherwize the filter chain will be stopped.

case FilterState::WaitingAllData:

}

func (h *requestOrResponseTrailerMapImpl) Add(key, value string) {
panic("unsupported yet")
h.initHeaders()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
h.initHeaders()
h.initTrailers()

yep, it should be an old issue, let's fix it here, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, this means we need a trailerMapImpl like headerMapImpl?

Copy link
Member

Choose a reason for hiding this comment

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

nope, I don't think so, just update the initHeaders of requestOrResponseTrailerMapImpl could be ok? at line 176.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, PTAL again, thanks.

done = doTrailerGo(state, trailers);
}
state.doDataList.moveOut(body);
Copy link
Member

Choose a reason for hiding this comment

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

oh, seems it's an old bug?

seems we should add these after line 347? instead of these two line.

if (done) {
      state.continueDoData();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

yep, there is not yet, I mean we should add it there, and we do not these two new lines then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

emmm, i think moveOut should not be there, since even if isBufferDataEmpty is true, doDataList may be also not empty, for example, decodeHeaders returns continue and decodeData returns StopAndBuffer, doDataGo will be called at decodeData phase first, so doDataList will not be empty at decodeTrailers phase. Did i make myself clear? 😄

Copy link
Member

Choose a reason for hiding this comment

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

oh, yes, the case you said is right.
but, the current implemention is not a proper fix. for example, doDataGo may return false at line 347, and we should not send doDataList then.
I think the proper fix might be, add continueDoData in the else branch, before doTrailerGo at line 355.

Copy link
Member

Choose a reason for hiding this comment

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

Also, could you please add some related test case? thanks very much.
Ah, seem this PR is bugfix more than feature, cool!

Comment on lines 348 to 354
// NP: can not use done as condition here, since done will be false
// maybe we can remove the done variable totally? by using state_ only?
// continue trailers
if (state.state() == FilterState::WaitingTrailer) {
done = doTrailerGo(state, trailers);
}
} else {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about these changes, could you please explain them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just like what i comment above, doTrailerGo should also be called when isBufferDataEmpty is true, otherwize the filter chain will be stopped.

Copy link
Member

Choose a reason for hiding this comment

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

oh, yes, I see, didn't see the comment before I comment, thanks.

Signed-off-by: wangkai19 <[email protected]>
doujiang24
doujiang24 previously approved these changes May 12, 2023
done = doTrailerGo(state, trailers);
}
state.doDataList.moveOut(body);
Copy link
Member

Choose a reason for hiding this comment

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

oh, yes, the case you said is right.
but, the current implemention is not a proper fix. for example, doDataGo may return false at line 347, and we should not send doDataList then.
I think the proper fix might be, add continueDoData in the else branch, before doTrailerGo at line 355.

done = doTrailerGo(state, trailers);
}
state.doDataList.moveOut(body);
Copy link
Member

Choose a reason for hiding this comment

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

Also, could you please add some related test case? thanks very much.
Ah, seem this PR is bugfix more than feature, cool!

@RyanTheOptimist
Copy link
Contributor

/assign @mattklein123

Copy link
Member

@doujiang24 doujiang24 left a comment

Choose a reason for hiding this comment

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

oh, sorry, not approve yet. accident happen in last comment.

Signed-off-by: wangkai19 <[email protected]>
@StarryVae
Copy link
Contributor Author

@doujiang24 Comments above are resolved as disscusion offline, and some test cases are already available like DataBuffer_DecodeHeader, DataBuffer_DecodeData... PTAL again, thanks.

@mattklein123 mattklein123 merged commit 10d55f2 into envoyproxy:main May 16, 2023
rshriram pushed a commit to rshriram/envoy that referenced this pull request May 17, 2023
Signed-off-by: wangkai19 <[email protected]>
Signed-off-by: Shriram Rajagopalan <[email protected]>
reskin89 pushed a commit to reskin89/envoy that referenced this pull request Jul 11, 2023
Signed-off-by: wangkai19 <[email protected]>
Signed-off-by: Ryan Eskin <[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.

None yet

4 participants