Skip to content

http: add removeIf() header map function#12160

Merged
mattklein123 merged 3 commits intomasterfrom
headers_remove_if
Jul 20, 2020
Merged

http: add removeIf() header map function#12160
mattklein123 merged 3 commits intomasterfrom
headers_remove_if

Conversation

@mattklein123
Copy link
Member

To be used by out of tree extensions.

Risk Level: Low
Testing: New tests and existing
Docs Changes: N/A
Release Notes: N/A

To be used by out of tree extensions.

Signed-off-by: Matt Klein <mklein@lyft.com>
@mattklein123
Copy link
Member Author

cc @jessicayuen @LisaLudique

jmarantz
jmarantz previously approved these changes Jul 18, 2020
Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

Couple of minor comments; I'm fine leaving things as they are too.

Signed-off-by: Matt Klein <mklein@lyft.com>
Signed-off-by: Matt Klein <mklein@lyft.com>
@mattklein123
Copy link
Member Author

@jmarantz updated

@mattklein123 mattklein123 merged commit 10fed47 into master Jul 20, 2020
@mattklein123 mattklein123 deleted the headers_remove_if branch July 20, 2020 20:09
@rgs1
Copy link
Member

rgs1 commented Jul 22, 2020

Hmm I am seeing appends in the :Authority header (e.g.: :authority = foo,bar -- which did not happened before) after this change... could it be related?

@rgs1
Copy link
Member

rgs1 commented Jul 22, 2020

Just confirmed -- reverting this change makes the appends in :authority go away. I'll dig in.

Clarification:

The issue started somewhere between these changes:

Added watchdog support for a Multi-Kill threshold. #12108
direct response filter: added unit test cases #12064
make header_order.py python3 #12193
dev: remove pcap workaround from devcontainer #12191
Revert "tcp: switching to the new pool #12180" #12192
security: add weekly patches #12156
fuzz: fix oss-fuzz crash in route_fuzz_test due to validation #12176
cleanup: removing tracer well_known_name file #12187
hds: change HdsCluster::cluster_ to a value instead of reference #12137
http: add removeIf() header map function #12160
cleanup: clang tidy naming #12181

I am going to revert just #12160 locally, to confirm it's causing this.

@rgs1
Copy link
Member

rgs1 commented Jul 22, 2020

Ok -- per @fishcakez this is probably related to the fact that we historically used request_headers_to_add to manipulate the host header, when we should have used host_rewrite.

So that's probably the issue, I'll confirm in a bit. We might still want to do something about this, since it might bite others.

@mattklein123
Copy link
Member Author

Hmm, I wouldn't think there would be a behavior change here but remove() did change slightly to not check for it being an O(1) header and to do a full scan. I can fix this if we think this is going to be an issue. @rgs1 can you provide a more complete description of the flow causing the issue?

@rgs1
Copy link
Member

rgs1 commented Jul 22, 2020

Instead of using host_rewrite we had:

             "request_headers_to_add": [
              {
                "append": false,
                "header": {
                  "key": "host",
                  "value": "api.foo.com"
                }
              },

After this change, append: false isn't honored anymore and we get :authority = foo,bar.

I think it's more of our mistake for manipulating the host header directly instead of using host_rewrite, than
a regression since this is technically an incorrect way of doing a host rewrite.

If we don't fix it we could at least clarify the docs or disallow referencing the host header
in requests_headers_to_add? Happy to send a PR for either one.

@mattklein123
Copy link
Member Author

OK let me look at this a bit and get back to you.

@mattklein123
Copy link
Member Author

OK I see the issue, basically the old path was doing the host -> authority translation and the new path is not.

@rgs1 I agree to be on the safe side I will go ahead and fix this. Can I fix this tomorrow or do you need this reverted urgently?

@rgs1
Copy link
Member

rgs1 commented Jul 23, 2020

OK I see the issue, basically the old path was doing the host -> authority translation and the new path is not.

@rgs1 I agree to be on the safe side I will go ahead and fix this. Can I fix this tomorrow or do you need this reverted urgently?

No rush on our end, we got unblocked by moving over to using host_rewrite. Thanks for the quick return!

mattklein123 added a commit that referenced this pull request Jul 23, 2020
#12160 changed
the behavior of remove() to not first look in the inline
header map for a header. This is a subtle change in
behavior that specifically breaks attempting to remove
":authority" via the "host" mapping. This restores that
behavior and is thus a bug fix and low risk.

Signed-off-by: Matt Klein <mklein@lyft.com>
mattklein123 added a commit that referenced this pull request Jul 23, 2020
#12160 changed
the behavior of remove() to not first look in the inline
header map for a header. This is a subtle change in
behavior that specifically breaks attempting to remove
":authority" via the "host" mapping. This restores that
behavior and is thus a bug fix and low risk.

Signed-off-by: Matt Klein <mklein@lyft.com>
KBaichoo pushed a commit to KBaichoo/envoy that referenced this pull request Jul 30, 2020
To be used by out of tree extensions.

Signed-off-by: Matt Klein <mklein@lyft.com>
Signed-off-by: Kevin Baichoo <kbaichoo@google.com>
KBaichoo pushed a commit to KBaichoo/envoy that referenced this pull request Jul 30, 2020
envoyproxy#12160 changed
the behavior of remove() to not first look in the inline
header map for a header. This is a subtle change in
behavior that specifically breaks attempting to remove
":authority" via the "host" mapping. This restores that
behavior and is thus a bug fix and low risk.

Signed-off-by: Matt Klein <mklein@lyft.com>
Signed-off-by: Kevin Baichoo <kbaichoo@google.com>
scheler pushed a commit to scheler/envoy that referenced this pull request Aug 4, 2020
To be used by out of tree extensions.

Signed-off-by: Matt Klein <mklein@lyft.com>
Signed-off-by: scheler <santosh.cheler@appdynamics.com>
chaoqin-li1123 pushed a commit to chaoqin-li1123/envoy that referenced this pull request Aug 7, 2020
envoyproxy#12160 changed
the behavior of remove() to not first look in the inline
header map for a header. This is a subtle change in
behavior that specifically breaks attempting to remove
":authority" via the "host" mapping. This restores that
behavior and is thus a bug fix and low risk.

Signed-off-by: Matt Klein <mklein@lyft.com>
Signed-off-by: chaoqinli <chaoqinli@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.

3 participants