Skip to content

http: introduce addEncodedMetadata()#7756

Merged
mattklein123 merged 16 commits intoenvoyproxy:masterfrom
soya3129:addencodedmetadata
Aug 7, 2019
Merged

http: introduce addEncodedMetadata()#7756
mattklein123 merged 16 commits intoenvoyproxy:masterfrom
soya3129:addencodedmetadata

Conversation

@soya3129
Copy link
Contributor

Description: introduce addEncodedMetadata(). Newly added metadata by addEncodedMetadata() will only be passed to filters following the filter where the metadata are added.
Risk Level: low.
Testing: integration tests.
Docs Changes: Updated metadata docs.
Release Notes: Introduce addEncodeMetadata() function.

Yang Song added 12 commits July 27, 2019 09:08
Signed-off-by: Yang Song <yasong@google.com>
Signed-off-by: Yang Song <yasong@google.com>
Signed-off-by: Yang Song <yasong@google.com>
Signed-off-by: Yang Song <yasong@google.com>
Signed-off-by: Yang Song <yasong@google.com>
Signed-off-by: Yang Song <yasong@google.com>
Signed-off-by: Yang Song <yasong@google.com>
Signed-off-by: Yang Song <yasong@google.com>
Signed-off-by: Yang Song <yasong@google.com>
Signed-off-by: Yang Song <yasong@google.com>
Signed-off-by: Yang Song <yasong@google.com>
@soya3129
Copy link
Contributor Author

cc @birenroy

Yang Song added 2 commits July 30, 2019 12:54
Signed-off-by: Yang Song <yasong@google.com>
Signed-off-by: Yang Song <yasong@google.com>
Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

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

Looks mostly good (and thankfully parallel to the decode path!)
Just a couple of thoughts from me:

std::unique_ptr<MetadataMapVector> saved_request_metadata_;
std::unique_ptr<MetadataMapVector> saved_response_metadata_;
std::unique_ptr<MetadataMapVector> saved_request_metadata_ = nullptr;
std::unique_ptr<MetadataMapVector> saved_response_metadata_ = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this necessary? If so let's use the {nullptr} syntax you use for request_medata_map_vector_

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Thanks!

void StreamEncoderImpl::encodeTrailers(const HeaderMap&) { endEncode(); }

void StreamEncoderImpl::encodeMetadata(const MetadataMapVector&) {
ENVOY_LOG_MISC(error, "HTTP1 doesn't support metadata");
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

{"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));
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there HCM unit tests we should update as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think adding new metadata was only covered in integration test.

Signed-off-by: Yang Song <yasong@google.com>
alyssawilk
alyssawilk previously approved these changes Aug 1, 2019
Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

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

LGTM modulo the error log. I'd rather have that fixed before merge but given I suspect most folks aren't using metadata I'm fine with a follow-up PR too

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM modulo the error log. I will review the other change.

/wait

void StreamEncoderImpl::encodeTrailers(const HeaderMap&) { endEncode(); }

void StreamEncoderImpl::encodeMetadata(const MetadataMapVector&) {
ENVOY_LOG_MISC(error, "HTTP1 doesn't support metadata");
Copy link
Member

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.

Signed-off-by: Yang Song <yasong@google.com>
@soya3129
Copy link
Contributor Author

soya3129 commented Aug 7, 2019

Merged h1 stats change. PTAL. Thanks!

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks!

@mattklein123 mattklein123 merged commit 2942421 into envoyproxy:master Aug 7, 2019
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.

3 participants