-
Notifications
You must be signed in to change notification settings - Fork 23
[kn-admin] support downloading profiling data for knative components #72
Conversation
Hi @lanceliuu. Thanks for your PR. I'm waiting for a knative 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. |
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.
Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -name '*.pb.go' -prune -o -type f -name '*.go' -print)
goimports -w $(find -name '*.go' | grep -v vendor | grep -v third_party | grep -v .pb.go | grep -v wire_gen.go)
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.
Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -name '*.pb.go' -prune -o -type f -name '*.go' -print)
goimports -w $(find -name '*.go' | grep -v vendor | grep -v third_party | grep -v .pb.go | grep -v wire_gen.go)
/ok-to-test |
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.
Various feedback... I know this is DRAFT but please start adding tests (unit and e2e). At least make sure you have a plan. Perhaps have tests with empty bodies to start with?
// ProfileType enums for all supported profiles | ||
type ProfileType int | ||
|
||
const secondsKey = "seconds" |
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.
why is this not in the const block above?
type Downloader struct { | ||
podName string | ||
namespace string | ||
// Close this will trigger closing for the endCh create by our own and then cancel all sub goroutines |
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.
Not sure I understand this comment? "Close ..." you mean closing the stopCh
channel?
err := fw.ForwardPorts() | ||
// if the func ForwardPorts() returns, the connection should not be available. | ||
if err != nil { | ||
// TODO: Log for error? |
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, definitely add logging support. Perhaps retries IF/WHEN it makes sense.
} | ||
|
||
// ProfilingTime is option to add a seconds param in the http request | ||
type ProfilingTime time.Duration |
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.
Does it make sense to separate this (and methods) into its own file? Might make things easier to navigate and manage in the long run...
|
||
// Download specific type of profile with options | ||
func (d *Downloader) Download(t ProfileType, output io.Writer, options ...DownloadOptions) error { | ||
if t <= ProfileTypeUnknown || t >= ProfileType(len(ProfileEndpoints)) { |
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.
Hmm, this condition reads odd to me. The value ProfileTypeUnknown
as per type above is a string. What would t <= another string result to? Maybe I am reading this wrong...
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.
ProfileType is enum type of int. So ProfileTypeUnknown is the default value 0. There is an array declared at line 40 to map ProfileType to the coressponding string.
"k8s.io/client-go/tools/clientcmd" | ||
) | ||
|
||
// DO NOT COMMIT |
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.
"DO NOT COMMIT" and it's in the PR!! :)
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 is just sample code for reference as I need to co-work with @chaozbj. This file will NOT exist in the final PR.
if err != nil { | ||
log.Fatal(err) | ||
} | ||
f1, _ := ioutil.TempFile("", "") |
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.
Why are we ignoring errors 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.
same as above
@maximilien I will fill up tests and then request for review. Thanks for your comments! |
/retest |
@lanceliuu: The
Use In response to this:
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, @lanceliuu, is this ready for new review? Does not seem like PROW ran any tests? Please tag me when ready for another review. Thanks. |
/retest |
@maximilien @zhanggbj This PR is ready for review. Thanks! |
Hi @lanceliuu @chaozbj , already LGTM, would you please help to rebase it? Thanks! |
Signed-off-by: Lance Liu <[email protected]>
Signed-off-by: Lance Liu <[email protected]>
Signed-off-by: chaozbj <[email protected]>
Signed-off-by: chaozbj <[email protected]>
Signed-off-by: chaozbj <[email protected]>
Signed-off-by: chaozbj <[email protected]>
Signed-off-by: chaozbj <[email protected]>
add interface to downloader add tests to downloader split downloadOptions to seperate file Signed-off-by: Lance Liu <[email protected]>
Signed-off-by: Lance Liu <[email protected]>
fix some UT for downloader Signed-off-by: Lance Liu <[email protected]>
Signed-off-by: Lance Liu <[email protected]>
Signed-off-by: Lance Liu <[email protected]>
Signed-off-by: Lance Liu <[email protected]>
Signed-off-by: Lance Liu <[email protected]>
Signed-off-by: chaozbj <[email protected]>
Signed-off-by: Lance Liu <[email protected]>
@zhanggbj Rebase done. Thank you. |
/lgtm |
This is a draft PR for @chaozbj and I to co-work to implement a
profiling
subcommand for kn-admin plugin.Details refer to #66