-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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 debugging transport for client #10032
Conversation
// IsClient is a global that indicates whether or not this process is a client or not. This is used to determined | ||
// whether body inspection should be allowed to disallowed. Only clients should set this value to true. Servers | ||
// should not, because body inspection breaks streams | ||
var IsClient = 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.
I want to call this out in particular. It is a global that I put it here for safety to avoid intercepting streaming input and output. Now I'm going to go hide from @smarterclayton
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.
Body inspection is probably too dangerous to do in the transport. Just move it up into pkg/client/request.go and call it a day.
----- Original Message -----
+import (
- "bytes"
- "fmt"
- "io/ioutil"
- "net/http"
- "time"
- "github.com/golang/glog"
- "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
+)
+// IsClient is a global that indicates whether or not this process is a
client or not. This is used to determined
+// whether body inspection should be allowed to disallowed. Only clients
should set this value to true. Servers
+// should not, because body inspection breaks streams
+var IsClient = falseI want to call this out in particular. It is a global that I put it here for
safety to avoid intercepting streaming input and output. Now I'm going to
go hide from @smarterclayton
Reply to this email directly or view it on GitHub:
https://github.com/GoogleCloudPlatform/kubernetes/pull/10032/files#r32752937
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.
Body inspection is probably too dangerous to do in the transport. Just move it up into pkg/client/request.go and call it a day.
I'm not sure that I think it's any safer to do somewhere else. Why does it matter where it's 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.
We should never inspect the returned body. Since the vast majority of use is from pkg/client/request.go, and those methods do read the body and have a []byte, it's safe there to let the debugging logic print the response. It is not safe to use a global value like this, and it's really not safe to read bodies.
----- Original Message -----
+import (
- "bytes"
- "fmt"
- "io/ioutil"
- "net/http"
- "time"
- "github.com/golang/glog"
- "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
+)
+// IsClient is a global that indicates whether or not this process is a
client or not. This is used to determined
+// whether body inspection should be allowed to disallowed. Only clients
should set this value to true. Servers
+// should not, because body inspection breaks streams
+var IsClient = falseBody inspection is probably too dangerous to do in the transport. Just
move it up into pkg/client/request.go and call it a day.I'm not sure that I think it's any safer to do somewhere else. Why does it
matter where it's done?
Reply to this email directly or view it on GitHub:
https://github.com/GoogleCloudPlatform/kubernetes/pull/10032/files#r32753587
5c41bc2
to
9b20000
Compare
comments addressed, updated the example in the description. |
@smarterclayton Can you give this a once over and sign off with the recent changes? |
Nit: pkg/client/debugging.go instead of repeating client |
The nit is optional, otherwise LGTM |
9b20000
to
54e0280
Compare
54e0280
to
bab0a61
Compare
renamed. |
transport = NewDebuggingRoundTripper(transport, JustURL, RequestHeaders, ResponseStatus, ResponseHeaders) | ||
case bool(glog.V(7)): | ||
transport = NewDebuggingRoundTripper(transport, JustURL, RequestHeaders, ResponseStatus) | ||
case bool(glog.V(6)): |
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'm ignorant of glog. Will glog.V(6) be true if I pass --v=7
to the command? Can you explain how these transports aren't getting quadruple wrapped at --v=9
without breaks?
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 used a switch/case, so only one case is executed.
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.
Ahhh okay thanks. Did not realize that about go switches. I feel like that's different than other switches...
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 feel like that's different than other switches...
The no explicit break
is required. If you want to fallthrough
, you have to ask for it.
LGTM |
lgtm |
@k8s-bot ok to test |
GCE e2e build/test failed for commit bab0a61. |
@k8s-bot ok to test |
add debugging transport for client
GCE e2e build/test passed for commit bab0a61. |
Fantastic. Thanks for the fast movement on this one. Waaayyyyy easier to debug stuff. |
Fixes #8610.
This dumps detailed information about REST request based on your logging level. Different levels produce different information. For instance