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
pdctl/command: add scheduler command #537
Conversation
29c82c5
to
264db94
Compare
Well done! |
264db94
to
c7ccfd9
Compare
PTAL @siddontang @disksing |
pdctl/command/scheduler.go
Outdated
_, err := doRequest(cmd, prefix, http.MethodDelete) | ||
if err != nil { | ||
fmt.Println(err) | ||
return |
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.
No need return.
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 it's more consistent.
pdctl/command/scheduler.go
Outdated
@@ -0,0 +1,158 @@ | |||
// Copyright 2016 PingCAP, Inc. |
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.
2017
pdctl/command/scheduler.go
Outdated
return | ||
} | ||
|
||
prefix := schedulersPrefix + "/" + args[0] |
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 path or uri would be a better variable name than prefix.
LGTM |
return | ||
} | ||
defer r.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.
should read all r.Body, I remember if not, the connection may be leak even close the body.
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 can't find any resource about why I must read r.Body
, any link?
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.
because we can't know whether the body has data or not.
In most of the cases, PUT returns no body, but it is still valid that PUT returns body.
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.
So the safest way here is to read body and discard 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.
Rest LGTM
Add command to show, add and remove schedulers.
f6d6b42
to
807f20b
Compare
Add command to show, add and remove schedulers.
Close #492