-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Conversation
@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. |
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 Once the patch is verified, the new status will be reflected by the 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. |
pkg/probe/http/http_test.go
Outdated
case "/redirect": | ||
http.Redirect(w, r, "/success", http.StatusFound) | ||
case "/success": | ||
if r.Host != hostHeader { |
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.
it seems this check will always pass?
r.Host
probably will be 127.0.0.1...
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.
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.
/release-note-none |
/sig node |
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 for adding this test :)
/lgtm
/ok-to-test
/assign @tallclair
pkg/probe/http/http_test.go
Outdated
headers := http.Header{} | ||
headers.Add("Host", test.hostHeader) | ||
t.Run(desc+"local", func(t *testing.T) { | ||
prober := New(false) |
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.
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.
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.
Done.
/retest |
1 similar comment
/retest |
I think this looks like what we want to prove. Thanks! /approve |
Thanks! /lgtm |
[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 |
… 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?: