-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Write Pod- & ServiceProxy Test - +12 endpoint coverage #94786
Conversation
/assign @heyste |
4e62fce
to
47e46c9
Compare
/test pull-kubernetes-e2e-gce-ubuntu-containerd |
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.
/cc @oomichi
/retest
test/e2e/network/proxy.go
Outdated
framework.ExpectNoError(err, "processing response") | ||
defer resp.Body.Close() | ||
|
||
framework.Logf("Processing %s request...", httpVerb) |
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: This Logf seems redundant because httpVerb is output on the following line 334.
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.
Agree
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.
Removed
test/e2e/network/proxy.go
Outdated
framework.Logf("Request String: %v", r.URL().String()) | ||
// Request returns 500 status - Can this be diabled? | ||
_, err := r.Do(context.Background()).StatusCode(&statusCode).Raw() | ||
framework.Logf("RESTClient() StatusCode: %d", statusCode) |
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.
just a question: Do we expect 500 as a status code here?
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 was hoping to use the normal RESTClient
to check that each request was being redirected. As the RESTClient
auto follows the redirection it looks like using the http.Client
is the only option to catch the 301 status code.
I'll remove that section of the test as it was more for reference/discussion point on why http.Client
was needed.
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 is a good idea. The removal will be able to make the test more clear and simple.
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.
Removed
98114d3
to
c07d671
Compare
IPv6 does not work because apiserver panics
cc: @liggitt |
Thanks for the pointer @aojea Looks like the following code (from Line 294) doesn't work for IPv6. 😕
Looking at the IPv4 logs, the response codes is what it should be.
but, IPv6 doesn't look like it's returning a 301 and just "auto follows" and then breaks
|
issue is here: kubernetes/staging/src/k8s.io/apimachinery/pkg/util/proxy/upgradeaware.go Lines 165 to 168 in 19706d9
introduced in https://github.com/kubernetes/kubernetes/pull/52065/files#diff-16a26bb0d342318c6eb3d03e6c5756e9 something about the passed-in URL will not parse correctly, the error is not checked, and the parsed URL is nil |
added debug logging in #94832 |
apart from the test failure/panic issues, I am not sure these are tests we'd want in conformance. 301 proxy redirect is something being debated in kubernetes/enhancements#1908, and 301 responses on non-GET requests probably don't make sense to return, let alone add to conformance |
strangely, got a pass on the debug PR that added logging /retest pull-kubernetes-e2e-kind-ipv6 |
/remove-sig testing |
test/e2e/network/proxy.go
Outdated
Transport: restTransport, | ||
} | ||
|
||
// All methods for Pod ProxyWithPath return 200 |
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 ProxyWithPath a leftover from using the test as base of this?
framework.ConformanceIt("A set of valid responses are returned for both pod and service ProxyWithPath", func() {
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.
Good spotting. Will update that comment.
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.
Fixed
test/e2e/network/proxy.go
Outdated
|
||
resp, err := client.Do(request) | ||
framework.ExpectNoError(err, "processing response") | ||
defer resp.Body.Close() |
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 will not close the Body until we exit the test, right?
There is also another client.Do
below, should this be enclosed on brackets so the defer close the body before we move to the next step?
{
resp, err := client.Do(request)
framework.ExpectNoError(err, "processing response")
defer resp.Body.Close()
framework.Logf("http.Client request:%s StatusCode:%d", redirectVerb, resp.StatusCode)
framework.ExpectEqual(resp.StatusCode, 301, "The resp.StatusCode returned: %d", resp.StatusCode)
}
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.
After testing defer
within a set of brackets they are processed still at the end of the function. I'll look at creating another function to contain each request to the pod and service endpoints.
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.
Each request is now done from a new function validateRedirectRequest
2026f0a
to
260288c
Compare
/test pull-kubernetes-e2e-kind
|
test/e2e/network/proxy.go
Outdated
framework.Logf("Starting http.Client for %s", urlString) | ||
|
||
pollErr := wait.PollImmediate(requestRetryPeriod, requestRetryTimeout, validateProxyVerbRequest(client, urlString, httpVerb, msg)) | ||
framework.ExpectNoError(err, "Pod didn't start within time out period. %v", pollErr) |
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.
framework.ExpectNoError(err, "Pod didn't start within time out period. %v", pollErr) | |
framework.ExpectNoError(pollErr, "Pod didn't start within time out period. %v", pollErr) |
we should check pollErr
, right?
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.
Fixed
260288c
to
8e39630
Compare
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: liggitt, Riaankl 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 |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PR adds a test to test the following untested endpoints:
connectCoreV1DeleteNamespacedPodProxy
connectCoreV1DeleteNamespacedServiceProxy
connectCoreV1OptionsNamespacedPodProxy
connectCoreV1OptionsNamespacedServiceProxy
connectCoreV1PatchNamespacedPodProxy
connectCoreV1PatchNamespacedServiceProxy
connectCoreV1PostNamespacedPodProxy
connectCoreV1PostNamespacedServiceProxy
connectCoreV1PutNamespacedPodProxy
connectCoreV1PutNamespacedServiceProxy
connectCoreV1HeadNamespacedPodProxy
onnectCoreV1HeadNamespacedServiceProxy
Which issue(s) this PR fixes:
Fixes #92949
Testgrid Link:
Special notes for your reviewer:
Adds +12 endpoint test coverage (good for conformance)
Does this PR introduce a user-facing change?:
Release note:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
/sig testing
/sig architecture
/area conformance