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
use context to check client closed instead of http.CloseNotifier in processing watch request #85408
use context to check client closed instead of http.CloseNotifier in processing watch request #85408
Conversation
Hi @answer1991. 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. |
18e6256
to
2976332
Compare
cc @wojtek-t PTAL |
0bbaed6
to
66b992b
Compare
/ok-to-test |
/test pull-kubernetes-bazel-test |
66b992b
to
de5331a
Compare
de5331a
to
252e24a
Compare
/test pull-kubernetes-integration |
} | ||
// Use context to check client closed instead of http.CloseNotifier. | ||
// Since http.CloseNotifier is deprecated, what's worse, | ||
// http.CloseNotifier will cost 1 more goruntine if proto is HTTP/2.x. |
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.
A lot of this comment belongs in the commit message, not in the code. The code comment could be // Use context instead of CloseNotifier as it's more efficient
, or simply nothing as there's not anything particularly tricky about this. (The tricky part is knowing to do it :)
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.
yes, I have removed comment. Thanks!
// Since http.CloseNotifier is deprecated, what's worse, | ||
// http.CloseNotifier will cost 1 more goruntine if proto is HTTP/2.x. | ||
ctx := req.Context() | ||
done := ctx.Done() |
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: squash the two lines above
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
252e24a
to
be0b966
Compare
cc @lavalamp |
t.Fatalf("Unexpected response: %#v\n%s", response, string(b)) | ||
} | ||
|
||
if err := response.Body.Close(); err != nil { |
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.
perhaps add a comment here saying // Close response without reading it to cause a cancel on the server
EDIT: Also, I am aware that this Github approval does not count as a k8s LGTM
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 have added comment, thanks
…rocessing watch request
be0b966
to
1daa08c
Compare
/test pull-kubernetes-e2e-gce |
/lgtm Many thanks for the test. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: answer1991, lavalamp 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 bug
What this PR does / why we need it:
Use context to check client closed instead of http.CloseNotifier. For two reasons:
https://github.com/golang/go/blob/2bde3c13f6e31662c682f1b5830c5e3fd9f5494c/src/net/http/h2_bundle.go#L6152
Which issue(s) this PR fixes:
Related issue: #84001
Special notes for your reviewer:
None
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
None