-
Notifications
You must be signed in to change notification settings - Fork 725
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: verify pd address #528
Conversation
pdctl/command/global.go
Outdated
if err != nil { | ||
return err | ||
} | ||
if reps.StatusCode != http.StatusOK { |
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.
must read all response body and close
pdctl/ctl.go
Outdated
command.InitPDClient(rootCmd) | ||
err := command.InitPDClient(rootCmd) | ||
if err != nil { | ||
return err.Error(), err |
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 return err.Error()
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.
this string will print.
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 not check error and print the error directly?
@@ -87,7 +87,9 @@ func loop() { | |||
} | |||
continue | |||
} | |||
|
|||
if line == "exit" { |
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.
split it to another 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.
if InitPDClient
meet error, it will return error directly without execute the command. so I move exit
to here.
command.InitPDClient(rootCmd) | ||
err := command.InitPDClient(rootCmd) | ||
if err != nil { | ||
fmt.Println(err) |
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 exit here directly?
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.
LGTM
PTAL @disksing |
pdctl/command/global.go
Outdated
} | ||
defer reps.Body.Close() | ||
if reps.StatusCode != http.StatusOK { | ||
ioutil.ReadAll(reps.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.
You don't have to read 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.
If not read, the connection FD will not close even you call body close later. I remember this is a pitfall before, but don't know go improves it or not.
Btw, We should call ioutil.ReadAll(reps.Body)
before the status check.
LGTM |
close #507
PTAL @siddontang @overvenus @huachaohuang