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

Added a unit test to verify that host header is preserved after probe… #77978

Merged
merged 3 commits into from
May 18, 2019

Conversation

ahg-g
Copy link
Member

@ahg-g ahg-g commented May 16, 2019

… redirect.

What type of PR is this?
/kind feature

What this PR does / why we need it:
Adds a unit test to capture possible regressions in preserving host header after probe redirect

Which issue(s) this PR fixes:

Fixes #71592

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


@k8s-ci-robot
Copy link
Contributor

@ahg-g: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

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 do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 16, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @ahg-g. Thanks for your PR.

I'm waiting for a kubernetes 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.

case "/redirect":
http.Redirect(w, r, "/success", http.StatusFound)
case "/success":
if r.Host != hostHeader {
Copy link
Member

Choose a reason for hiding this comment

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

it seems this check will always pass?
r.Host probably will be 127.0.0.1...

Copy link
Member Author

Choose a reason for hiding this comment

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

oops, I fixed the test and added another case to test probe failures.

note that r.URL.Host is different from r.Host, the former is the host part of the url (which in this case will be 127.0.0.1), the latter is the host header value.

@neolit123
Copy link
Member

/release-note-none

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels May 16, 2019
@neolit123
Copy link
Member

/sig node
/priority backlog

@k8s-ci-robot k8s-ci-robot added sig/node Categorizes an issue or PR as relevant to SIG Node. priority/backlog Higher priority than priority/awaiting-more-evidence. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels May 16, 2019
@k8s-ci-robot k8s-ci-robot assigned tallclair and unassigned tallclair May 17, 2019
Copy link
Contributor

@mattjmcnaughton mattjmcnaughton left a comment

Choose a reason for hiding this comment

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

Thanks for adding this test :)

/lgtm
/ok-to-test
/assign @tallclair

@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. lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 17, 2019
headers := http.Header{}
headers.Add("Host", test.hostHeader)
t.Run(desc+"local", func(t *testing.T) {
prober := New(false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind naming these variables (i.e. followNonLocalRedirects = false)?

I created https://github.com/kubernetes/kubernetes/pull/78031/files to make a similar change for other tests in this file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 17, 2019
@ahg-g
Copy link
Member Author

ahg-g commented May 17, 2019

/retest

1 similar comment
@ahg-g
Copy link
Member Author

ahg-g commented May 17, 2019

/retest

@thockin
Copy link
Member

thockin commented May 17, 2019

I think this looks like what we want to prove.

Thanks!

/approve

@thockin
Copy link
Member

thockin commented May 17, 2019

Thanks!

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 17, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahg-g, thockin

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 May 17, 2019
@k8s-ci-robot k8s-ci-robot merged commit ae132f6 into kubernetes:master May 18, 2019
@ahg-g ahg-g deleted the ahg-host-redirect branch January 10, 2020 15:38
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. kind/feature Categorizes issue or PR as related to a new feature. 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. priority/backlog Higher priority than priority/awaiting-more-evidence. release-note-none Denotes a PR that doesn't merit a release note. sig/node Categorizes an issue or PR as relevant to SIG Node. 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.

Probe httpHeaders "Host" is lost after redirect
6 participants