-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
make custom inline headers bootstrap configurable #17330
Conversation
Signed-off-by: wbpcode <[email protected]>
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
Signed-off-by: wbpcode <[email protected]>
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.
Left an API comment and some drive-by code comments.
source/server/server.cc
Outdated
@@ -294,6 +295,46 @@ void loadBootstrap(absl::optional<uint32_t> bootstrap_version, | |||
throw EnvoyException(fmt::format("Unknown bootstrap version {}.", *bootstrap_version)); | |||
} | |||
} | |||
|
|||
bool canBeRegisteredAsInlineHeaderOrNot(const Http::LowerCaseString& header_name) { |
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.
nit: canBeRegisteredAsInlineHeader
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.
👌
source/server/server.cc
Outdated
void registerCustomInlineHeadersFromBootstrap( | ||
const envoy::config::bootstrap::v3::Bootstrap& bootstrap) { | ||
for (const auto& inline_header : bootstrap.inline_headers()) { | ||
Http::LowerCaseString lower_case_name(inline_header.inline_header_name()); |
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.
nit: const
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.
👌
test/server/server_test.cc
Outdated
// instantiation of InstanceImpl. If InstanceImpl is instantiated again and the inline header is | ||
// registered again, the assertion will be triggered. |
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.
Is there a test that covers this scenario? If not, can you please add one.
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.
👌
string inline_header_name = 1 [(validate.rules).string = {min_len: 1}]; | ||
|
||
// The type of the header that is expected to be set as the inline header. | ||
InlineHeaderType inline_header_type = 2; |
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.
I think that the following PGV constraint (validate.rules).enum.defined_only = true
can be added.
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.
👌
Signed-off-by: wbpcode <[email protected]>
Signed-off-by: wbpcode <[email protected]>
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.
/lgtm api
Signed-off-by: wbpcode <[email protected]>
Signed-off-by: wbpcode <[email protected]>
/retest |
Retrying Azure Pipelines: |
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.
/lgtm api
@alyssawilk Now the API is ready. When it is convenient for you, can you advance this work? 😄 |
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.
Looks great! this will be a really useful feature going forward :-)
@@ -292,6 +293,46 @@ void loadBootstrap(absl::optional<uint32_t> bootstrap_version, | |||
throw EnvoyException(fmt::format("Unknown bootstrap version {}.", *bootstrap_version)); | |||
} | |||
} | |||
|
|||
bool canBeRegisteredAsInlineHeader(const Http::LowerCaseString& header_name) { |
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.
call out in API?
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.
get it.
string inline_header_name = 1 [(validate.rules).string = {min_len: 1}]; | ||
|
||
// The type of the header that is expected to be set as the inline header. | ||
InlineHeaderType inline_header_type = 2 [(validate.rules).enum = {defined_only: true}]; |
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.
vadd pgv for well_known_regex: HTTP_HEADER_NAME?
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.
get it.
inline_header.inline_header_name())); | ||
} | ||
switch (inline_header.inline_header_type()) { | ||
case envoy::config::bootstrap::v3::CustomInlineHeader::REQUEST_HEADER: |
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.
Can one add as a custom inline header a header which is already an inline header? I think it's worth a unit test for this.
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.
Can one add as a custom inline header a header which is already an inline header?
Yes.
I think it's worth a unit test for this.
I think this scenario has been verified in the test of CustomInlineHeaderRegistry::registerInlineHeader
itself. We can register the header with the same name as the inline header repeatedly without any negative effects.
envoy/test/common/http/header_map_impl_test.cc
Lines 365 to 368 in d483098
Http::RegisterCustomInlineHeader<Http::CustomInlineHeaderRegistry::Type::RequestHeaders> | |
custom_header_1(Http::LowerCaseString{"foo_custom_header"}); | |
Http::RegisterCustomInlineHeader<Http::CustomInlineHeaderRegistry::Type::RequestHeaders> | |
custom_header_1_copy(Http::LowerCaseString{"foo_custom_header"}); |
envoy/test/common/http/header_map_impl_test.cc
Lines 389 to 399 in d483098
// Make sure that the same header registered twice points to the same location. | |
TEST_P(HeaderMapImplTest, CustomRegisteredHeaders) { | |
TestRequestHeaderMapImpl headers; | |
EXPECT_EQ(custom_header_1.handle(), custom_header_1_copy.handle()); | |
EXPECT_EQ(nullptr, headers.getInline(custom_header_1.handle())); | |
EXPECT_EQ(nullptr, headers.getInline(custom_header_1_copy.handle())); | |
headers.setInline(custom_header_1.handle(), 42); | |
EXPECT_EQ("42", headers.getInlineValue(custom_header_1_copy.handle())); | |
EXPECT_EQ("foo_custom_header", | |
headers.getInline(custom_header_1.handle())->key().getStringView()); | |
} |
is_registered = true; | ||
} | ||
|
||
EXPECT_TRUE( |
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.
how about an integration test (protocol integration test?) that the headers / trailers end up elided?
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.
get it. I think we can verify this problem with a few simple lines of tests in existing test cases.
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.
Where did we land on this? Don't see an integration test
Signed-off-by: wbpcode <[email protected]>
/retest |
Retrying Azure Pipelines: |
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.
Looks great! Throwing over to @snowp for second pass
Also @adisuissa can you do another API stamp? |
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.
/lgtm api
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.
This LGTM, just one question re adding an integration test
@snowp Thanks. @alyssawilk's suggestion is to verify that a header or trailer registered as an inline header can be folded correctly. In practice, integration tests are not necessarily required to verify this problem.
|
/retest |
Retrying Azure Pipelines: |
/retest |
Retrying Azure Pipelines: |
Signed-off-by: wbpcode <[email protected]>
I think normally we encourage adding an integration test even if it's not strictly necessary since they tend to catch unexpected issues (or provide more reliable regression tests). That said it seems like we're okay skipping it in this case, so let's get this 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.
Thanks!
…bridge-stream * upstream/main: (140 commits) quiche: remove google quic support (envoyproxy#17465) runtime: removing envoy.reloadable_features.check_ocsp_policy (envoyproxy#17524) upstream: not trying to do HTTP/3 where not configured (envoyproxy#17454) api: Remove confusing line about auto-generation (envoyproxy#17536) v2: removing bootstrap (envoyproxy#17523) connpool: Fix crash in pool removal if the cluster was already deleted (envoyproxy#17522) Enhance the comments clearly (envoyproxy#17517) mysql proxy: connection attributes parsing (envoyproxy#17209) [ci] fix false positive CVE scan from node (envoyproxy#17510) Fixing Envoy Mobile factory strings (envoyproxy#17509) http3: validating codec (envoyproxy#17452) quic: add QUIC upstream stream reset error stats (envoyproxy#17496) thrift proxy: move UpstreamRequest into its own file (envoyproxy#17498) docs: Fixed FaultDelay docs. (envoyproxy#17495) updates links to jaegertracing-plugin.tar.gz (envoyproxy#17497) http: make custom inline headers bootstrap configurable (envoyproxy#17330) deps: update yaml-cpp to latest master (envoyproxy#17489) improving tracer coverage (envoyproxy#17493) Increase buffer size of `Win32RedirectRecords` (envoyproxy#17471) ext_proc: Fix problem with buffered body mode with empty or no body (envoyproxy#17430) ... Signed-off-by: Garrett Bourg <[email protected]>
Commit Message: ensure that the inline cookie header will be folded correctly Additional Description: This PR is a supplement to #17330 and #14969 and will finally close #17234. This PR mainly did following works: update insertByKey to choose suitable delimiter for inline header. update parseCookie to avoid unnecessary iteration for parsing cookie value. Risk Level: Low. Testing: Add. Docs Changes: N/A. Release Notes: N/A. Signed-off-by: wbpcode <[email protected]>
…7330) Signed-off-by: wbpcode <[email protected]>
…roxy#17560) Commit Message: ensure that the inline cookie header will be folded correctly Additional Description: This PR is a supplement to envoyproxy#17330 and envoyproxy#14969 and will finally close envoyproxy#17234. This PR mainly did following works: update insertByKey to choose suitable delimiter for inline header. update parseCookie to avoid unnecessary iteration for parsing cookie value. Risk Level: Low. Testing: Add. Docs Changes: N/A. Release Notes: N/A. Signed-off-by: wbpcode <[email protected]>
Signed-off-by: wbpcode [email protected]
Commit Message: make custom inline headers bootstrap configurable
Additional Description:
Make custom inline headers bootstrap configurable. Check #17234 for more background info.
Risk Level: Mid.
Testing: Added.
Docs Changes: N/A.
Release Notes: Wait.