-
Notifications
You must be signed in to change notification settings - Fork 5.5k
http: introduce addEncodedMetadata() #7756
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
Merged
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
614ba5d
add metadata size limit test
f7b24b3
Merge branch 'master' of https://github.com/envoyproxy/envoy
2d85da4
addenodedmetadata without test
55375f6
Merge branch 'master' into addencodedmetadata
c80b445
clean up
bd03a39
add test for addEncodedMetadata
b1c22b0
clean up
1246b96
format fix
5e22128
clean up
b464c1d
change existing tests to use addEncodedMetadata.
bc4493a
fix format
ac8c0bf
update doc
b08fbbe
fix test failure
128dcc7
fix format
736f0a1
address comments
fbcfe1e
merge from master
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,42 +16,39 @@ class ResponseMetadataStreamFilter : public Http::PassThroughFilter { | |
| public: | ||
| // Inserts one new metadata_map. | ||
| Http::FilterHeadersStatus encodeHeaders(Http::HeaderMap&, bool) override { | ||
| Http::MetadataMap metadata_map = { | ||
| {"headers", "headers"}, {"duplicate", "duplicate"}, {"remove", "remove"}}; | ||
| Http::MetadataMap metadata_map = {{"headers", "headers"}, {"duplicate", "duplicate"}}; | ||
| Http::MetadataMapPtr metadata_map_ptr = std::make_unique<Http::MetadataMap>(metadata_map); | ||
| decoder_callbacks_->encodeMetadata(std::move(metadata_map_ptr)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there HCM unit tests we should update as well?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think adding new metadata was only covered in integration test. |
||
| encoder_callbacks_->addEncodedMetadata(std::move(metadata_map_ptr)); | ||
| return Http::FilterHeadersStatus::Continue; | ||
| } | ||
|
|
||
| // Inserts one new metadata_map. | ||
| Http::FilterDataStatus encodeData(Buffer::Instance&, bool) override { | ||
| Http::MetadataMap metadata_map = { | ||
| {"data", "data"}, {"duplicate", "duplicate"}, {"remove", "remove"}}; | ||
| Http::MetadataMap metadata_map = {{"data", "data"}, {"duplicate", "duplicate"}}; | ||
| Http::MetadataMapPtr metadata_map_ptr = std::make_unique<Http::MetadataMap>(metadata_map); | ||
| decoder_callbacks_->encodeMetadata(std::move(metadata_map_ptr)); | ||
| encoder_callbacks_->addEncodedMetadata(std::move(metadata_map_ptr)); | ||
| return Http::FilterDataStatus::Continue; | ||
| } | ||
|
|
||
| // Inserts two metadata_maps by calling decoder_callbacks_->encodeMetadata() twice. | ||
| Http::FilterTrailersStatus encodeTrailers(Http::HeaderMap&) override { | ||
| Http::MetadataMap metadata_map = {{"trailers", "trailers"}, {"remove", "remove"}}; | ||
| Http::MetadataMap metadata_map = {{"trailers", "trailers"}}; | ||
| Http::MetadataMapPtr metadata_map_ptr = std::make_unique<Http::MetadataMap>(metadata_map); | ||
| decoder_callbacks_->encodeMetadata(std::move(metadata_map_ptr)); | ||
| encoder_callbacks_->addEncodedMetadata(std::move(metadata_map_ptr)); | ||
| metadata_map = {{"duplicate", "duplicate"}}; | ||
| metadata_map_ptr = std::make_unique<Http::MetadataMap>(metadata_map); | ||
| decoder_callbacks_->encodeMetadata(std::move(metadata_map_ptr)); | ||
| encoder_callbacks_->addEncodedMetadata(std::move(metadata_map_ptr)); | ||
| return Http::FilterTrailersStatus::Continue; | ||
| } | ||
|
|
||
| // Inserts two metadata_maps by calling decoder_callbacks_->encodeMetadata() twice. | ||
| Http::FilterHeadersStatus encode100ContinueHeaders(Http::HeaderMap&) override { | ||
| Http::MetadataMap metadata_map = { | ||
| {"100-continue", "100-continue"}, {"duplicate", "duplicate"}, {"remove", "remove"}}; | ||
| Http::MetadataMap metadata_map = {{"100-continue", "100-continue"}, {"duplicate", "duplicate"}}; | ||
| Http::MetadataMapPtr metadata_map_ptr = std::make_unique<Http::MetadataMap>(metadata_map); | ||
| decoder_callbacks_->encodeMetadata(std::move(metadata_map_ptr)); | ||
| encoder_callbacks_->addEncodedMetadata(std::move(metadata_map_ptr)); | ||
| metadata_map = {{"duplicate", "duplicate"}}; | ||
| metadata_map_ptr = std::make_unique<Http::MetadataMap>(metadata_map); | ||
| decoder_callbacks_->encodeMetadata(std::move(metadata_map_ptr)); | ||
| encoder_callbacks_->addEncodedMetadata(std::move(metadata_map_ptr)); | ||
| return Http::FilterHeadersStatus::Continue; | ||
| } | ||
|
|
||
|
|
@@ -66,10 +63,6 @@ class ResponseMetadataStreamFilter : public Http::PassThroughFilter { | |
| metadata_map.erase("consume"); | ||
| metadata_map.emplace("replace", "replace"); | ||
| } | ||
| it = metadata_map.find("remove"); | ||
| if (it != metadata_map.end()) { | ||
| metadata_map.erase("remove"); | ||
| } | ||
| it = metadata_map.find("metadata"); | ||
| if (it != metadata_map.end()) { | ||
| metadata_map.erase("metadata"); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if an H2 upstream sends medatadata to an H1 data source, we'll log an error message for every frame? I think we want to handle that in a way that's less painful. I think ideally we'd error log once (or better yet with pow-2 backoff) and increment a stat, but I don't think Envoy has backoff logging yet so maybe just a stat for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! Fixed in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. If you want to change this to a no-op I'd be fine with it landing as-is, though it should probably get a Matt Klein pass as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I can sync to master after #7801 is merged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah agreed this should be a NOP + stat, so fine to review the other change first and then come back to this one.