Skip to content
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

Add Set field to HTTPRequestHeaderFilter #475

Merged
merged 4 commits into from
Dec 20, 2020
Merged

Add Set field to HTTPRequestHeaderFilter #475

merged 4 commits into from
Dec 20, 2020

Conversation

nak3
Copy link
Member

@nak3 nak3 commented Nov 24, 2020

This patch adds Set field to HTTPRequestHeaderFilter.

Currently Add(append) and Remove are available in
HTTPRequestHeaderFilter. But it is not possible to overwrite a
header.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 24, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @nak3. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 24, 2020
Copy link
Contributor

@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

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

LGTM

//
// Support: Extended
// +optional
Set map[string]string `json:"set,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to this change.
One concern. Can most implementations differentiate between addition and override?

Copy link
Member

@robscott robscott Nov 24, 2020

Choose a reason for hiding this comment

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

From what I can tell, adding headers is pretty widely supported among other implementations, but setting/overwriting headers is certainly trickier. HAProxy has a very clear differentiation that would match this config closely (add-header and set-header). The distinction is less clear with nginx (add_header and proxy_set_header but defined in different modules), but fairly straightforward with envoy. and I think you might need a custom filter to overwrite a header with envoy.

With all that said, I think this is a good addition for the implementations that can support it, and the extended support level feels appropriate.

@hbagdi
Copy link
Contributor

hbagdi commented Nov 24, 2020

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 24, 2020
@robscott
Copy link
Member

robscott commented Nov 24, 2020

Thanks for this addition @nak3! We're still trying to figure out what we'd like to include in updates to the v1alpha1 API vs new work on the v1alpha2 API. We should be able to discuss this more at our community meeting next week. Until then, I'd like to hold this change to ensure we're not adding more than we want to to v1alpha1.

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 24, 2020
@howardjohn
Copy link
Contributor

howardjohn commented Nov 24, 2020 via email

@robscott
Copy link
Member

We discussed this a bit further yesterday and this seemed like a reasonable change. We also got #492 merged in yesterday which clarifies that we can make additive changes to an existing API. With that I think this is mostly good to go.

/hold cancel
/retest

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 10, 2020
@robscott
Copy link
Member

I'm going to approve this and wait for a final LGTM from @hbagdi or @jpeach.

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nak3, robscott

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 10, 2020
Copy link
Contributor

@hbagdi hbagdi left a comment

Choose a reason for hiding this comment

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

This is very close. I've a couple of small documentation improvements.

//
// Input:
// GET /foo HTTP/1.1
// My-Header: ABC
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we lower case this?
Header field names are case-insensitive but keeping this example consistent throughout the documentation would be ideal.

// Support: Extended
// +optional
Set map[string]string `json:"set,omitempty"`

// Add adds the given header (name, value) to the request
Copy link
Contributor

Choose a reason for hiding this comment

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

Since now we have Add and Set, we should clarify here what happens when a header already exists in the Add case.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 14, 2020
@@ -456,16 +476,16 @@ type HTTPRequestHeaderFilter struct {
//
// Input:
// GET /foo HTTP/1.1
// My-Header1: ABC
// My-Header2: DEF
// My-Header2: GHI
Copy link
Member Author

Choose a reason for hiding this comment

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

I believe this is a typo. Fixed by s/My-Header2/My-Heade3 in this PR.

//
// Output:
// GET /foo HTTP/1.1
// my-header: foo bar
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems incorrect. Header values are allowed to contain whitespaces.
The usual textual representation for multiple headers is:

	//   GET /foo HTTP/1.1
	//   my-header: foo
	//   my-header: bar

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you! Updated.

@hbagdi
Copy link
Contributor

hbagdi commented Dec 15, 2020

/lgtm

@jpeach How does #475 (comment) sound to you? We had discussed in the office hours to track the ordering bug separately.
/hold
Please cancel the hold if that is resolved.

There is another minor thing where if the PR was based on the latest master then the PR description could add release notes. This is minor enough that we can ignore.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 15, 2020
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 15, 2020
@nak3
Copy link
Member Author

nak3 commented Dec 18, 2020

@jpeach Friendly ping. Could you please check above comment?

@jpeach
Copy link
Contributor

jpeach commented Dec 20, 2020

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 20, 2020
@k8s-ci-robot k8s-ci-robot merged commit 8a8b4e7 into kubernetes-sigs:master Dec 20, 2020
@nak3 nak3 deleted the add-set branch January 23, 2021 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants