Skip to content

router: Add do_formatting arg to responseHeaderTransforms #16529

Merged
snowp merged 6 commits intoenvoyproxy:mainfrom
ahedberg:response_transforms_no_format
May 27, 2021
Merged

router: Add do_formatting arg to responseHeaderTransforms #16529
snowp merged 6 commits intoenvoyproxy:mainfrom
ahedberg:response_transforms_no_format

Conversation

@ahedberg
Copy link
Copy Markdown
Contributor

Commit Message: Add do_formatting arg to responseHeaderTransforms
Additional Description: This change adds an additional argument, bool do_formatting, to ResponseEntry::responseHeaderTransforms. This allows callers to retrieve the original value instead of the evaluated/formatted value. The default value is true to match existing behavior and prevents changes to existing callsites.
Risk Level: low
Testing: unit tests
Docs Changes: doc updated
Release Notes: n/a
Platform Specific Features: n/a

ahedberg added 2 commits May 17, 2021 12:51
Signed-off-by: Ashley Hedberg <ahedberg@google.com>
Signed-off-by: Ashley Hedberg <ahedberg@google.com>
Copy link
Copy Markdown
Contributor

@snowp snowp left a comment

Choose a reason for hiding this comment

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

Thanks, this seems reasonable to just a few nits.

Out of curiosity what is the use case for this?

ahedberg added 2 commits May 20, 2021 11:48
Signed-off-by: Ashley Hedberg <ahedberg@google.com>
Signed-off-by: Ashley Hedberg <ahedberg@google.com>
Copy link
Copy Markdown
Contributor Author

@ahedberg ahedberg left a comment

Choose a reason for hiding this comment

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

Thanks, this seems reasonable to just a few nits.

Out of curiosity what is the use case for this?

We have an Envoy deployment where, at request time, we need to send the configured response header transformations to another (non-Envoy) service, which will apply them at response time. We don't want to evaluate the response header transformations at request time, as we need to convert any with the Envoy-style %PER_REQUEST_FORMAT% markers to the format the other service understands.

My initial PR adding this API should have done this, but I didn't realize the interaction at the time. My bad.

@ahedberg
Copy link
Copy Markdown
Contributor Author

Ping @snowp ? Windows presubmit errors look unrelated to this change.

snowp
snowp previously approved these changes May 24, 2021
Copy link
Copy Markdown
Contributor

@snowp snowp left a comment

Choose a reason for hiding this comment

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

LGTM!

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #16529 (review) was submitted by @snowp.

see: more, trace.

@snowp
Copy link
Copy Markdown
Contributor

snowp commented May 25, 2021

The Windows CI failures seem related:

external/com_google_googletest/googlemock/include\gmock/gmock-actions.h(776,60): error: returning reference to local temporary object [-Werror,-Wreturn-stack-address]
    Result Perform(const ArgumentTuple&) override { return ref_; }
                                                           ^~~~
external/com_google_googletest/googlemock/include\gmock/gmock-actions.h(774,14): note: in instantiation of member function 'testing::internal::ReturnRefAction<std::shared_ptr<Envoy::StreamInfo::FilterStateImpl>>::Impl<const std::shared_ptr<Envoy::StreamInfo::FilterState> &()>::Perform' requested here
    explicit Impl(T& ref) : ref_(ref) {}  // NOLINT
             ^
external/com_google_googletest/googlemock/include\gmock/gmock-actions.h(763,26): note: in instantiation of member function 'testing::internal::ReturnRefAction<std::shared_ptr<Envoy::StreamInfo::FilterStateImpl>>::Impl<const std::shared_ptr<Envoy::StreamInfo::FilterState> &()>::Impl' requested here
    return Action<F>(new Impl<F>(ref_));
                         ^
test/common/router/header_formatter_test.cc(1472,53): note: in instantiation of function template specialization 'testing::internal::ReturnRefAction<std::shared_ptr<Envoy::StreamInfo::FilterStateImpl>>::operator Action<const std::shared_ptr<Envoy::StreamInfo::FilterState> &()>' requested here
  ON_CALL(stream_info, filterState()).WillByDefault(ReturnRef(filter_state));

Signed-off-by: Ashley Hedberg <ahedberg@google.com>
@ahedberg
Copy link
Copy Markdown
Contributor Author

The Windows CI failures seem related:

external/com_google_googletest/googlemock/include\gmock/gmock-actions.h(776,60): error: returning reference to local temporary object [-Werror,-Wreturn-stack-address]
    Result Perform(const ArgumentTuple&) override { return ref_; }
                                                           ^~~~
external/com_google_googletest/googlemock/include\gmock/gmock-actions.h(774,14): note: in instantiation of member function 'testing::internal::ReturnRefAction<std::shared_ptr<Envoy::StreamInfo::FilterStateImpl>>::Impl<const std::shared_ptr<Envoy::StreamInfo::FilterState> &()>::Perform' requested here
    explicit Impl(T& ref) : ref_(ref) {}  // NOLINT
             ^
external/com_google_googletest/googlemock/include\gmock/gmock-actions.h(763,26): note: in instantiation of member function 'testing::internal::ReturnRefAction<std::shared_ptr<Envoy::StreamInfo::FilterStateImpl>>::Impl<const std::shared_ptr<Envoy::StreamInfo::FilterState> &()>::Impl' requested here
    return Action<F>(new Impl<F>(ref_));
                         ^
test/common/router/header_formatter_test.cc(1472,53): note: in instantiation of function template specialization 'testing::internal::ReturnRefAction<std::shared_ptr<Envoy::StreamInfo::FilterStateImpl>>::operator Action<const std::shared_ptr<Envoy::StreamInfo::FilterState> &()>' requested here
  ON_CALL(stream_info, filterState()).WillByDefault(ReturnRef(filter_state));

Hmm, that was not the error I saw the first time.

I think Windows is doing something weird now that I've switched this to auto - there are existing uses of ON_CALL(stream_info, filterState()).WillByDefault(ReturnRef(filter_state)); in this file that compile just fine, but those don't use auto. Switching back to spelling out the type to see if that fixes CI...

Signed-off-by: Ashley Hedberg <ahedberg@google.com>
@ahedberg
Copy link
Copy Markdown
Contributor Author

ahedberg commented May 25, 2021

Dropping auto has indeed resolved the Windows CI problems. @snowp PTAL.

Copy link
Copy Markdown
Contributor

@snowp snowp left a comment

Choose a reason for hiding this comment

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

Thanks!

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #16529 (review) was submitted by @snowp.

see: more, trace.

@snowp snowp merged commit 534a102 into envoyproxy:main May 27, 2021
leyao-daily pushed a commit to leyao-daily/envoy that referenced this pull request Sep 30, 2021
…#16529)

Signed-off-by: Ashley Hedberg <ahedberg@google.com>
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