Skip to content
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

pd-ctl: add error code reporting in the store command #8788

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tools/pd-ctl/pdctl/command/store_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func NewDeleteStoreByAddrCommand() *cobra.Command {
d := &cobra.Command{
Use: "addr <address>",
Short: "delete store by its address",
Run: deleteStoreCommandByAddrFunc,
RunE: deleteStoreCommandByAddrFunc,
}
return d
}
Expand Down Expand Up @@ -378,19 +378,19 @@ func deleteStoreCommandFunc(cmd *cobra.Command, args []string) {
cmd.Println("Success!")
}

func deleteStoreCommandByAddrFunc(cmd *cobra.Command, args []string) {
func deleteStoreCommandByAddrFunc(cmd *cobra.Command, args []string) error {
id := getStoreID(cmd, args, false)
if id == -1 {
return
return fmt.Errorf("Store not find.")
}
// delete store by its ID
prefix := fmt.Sprintf(storePrefix, id)
_, err := doRequest(cmd, prefix, http.MethodDelete, http.Header{})
if err != nil {
cmd.Printf("Failed to delete store %s: %s\n", args[0], err)
return
return fmt.Errorf("Failed to delete store.")
}
cmd.Println("Success!")
return nil
}

func cancelDeleteStoreCommandFunc(cmd *cobra.Command, args []string) {
Expand Down
Loading