diff --git a/tools/pd-ctl/pdctl/command/store_command.go b/tools/pd-ctl/pdctl/command/store_command.go index 188d36e25de..b95af582c57 100644 --- a/tools/pd-ctl/pdctl/command/store_command.go +++ b/tools/pd-ctl/pdctl/command/store_command.go @@ -63,7 +63,7 @@ func NewDeleteStoreByAddrCommand() *cobra.Command { d := &cobra.Command{ Use: "addr
", Short: "delete store by its address", - Run: deleteStoreCommandByAddrFunc, + RunE: deleteStoreCommandByAddrFunc, } return d } @@ -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) {