Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
cherry pick #1358 to release-2.0 (#1361)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-srebot authored Dec 25, 2020
1 parent 91e5a67 commit 85ac5b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions dm/ctl/master/purge_relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewPurgeRelayCmd() *cobra.Command {
cmd := &cobra.Command{
//Use: "purge-relay <-w worker> [--inactive] [--time] [--filename] [--sub-dir]",
//Short: "purge dm-worker's relay log files, choose 1 of 2 methods",
Use: "purge-relay <-s source> [--filename] [--sub-dir]",
Use: "purge-relay <-s source> <-f filename> [--sub-dir directory]",
Short: "purge relay log files of the DM-worker according to the specified filename",
RunE: purgeRelayFunc,
}
Expand All @@ -59,24 +59,25 @@ func purgeRelayFunc(cmd *cobra.Command, _ []string) (err error) {

sources, err := common.GetSourceArgs(cmd)
if err != nil {
common.PrintLines("%v", err)
return
}
if len(sources) == 0 {
fmt.Println("must specify at least one source (`-s` / `--source`)")
err = errors.New("please check output to see error")
err = errors.New("must specify at least one source (`-s` / `--source`)")
return
}

filename, err := cmd.Flags().GetString("filename")
if err != nil {
common.PrintLines("error in parse `--filename`")
return
}

if len(filename) == 0 {
err = errors.New("must specify the name of the terminal file before which to purge relay log files. (`-f` / `--filename`)")
return
}

subDir, err := cmd.Flags().GetString("sub-dir")
if err != nil {
common.PrintLines("error in parse `--sub-dir`")
return
}

Expand All @@ -86,8 +87,7 @@ func purgeRelayFunc(cmd *cobra.Command, _ []string) (err error) {
}

if len(filename) > 0 && len(sources) > 1 {
fmt.Println("for --filename, can only specify one source per time")
err = errors.New("please check output to see error")
err = errors.New("for --filename, can only specify one source per time")
return
}
if len(subDir) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion tests/dmctl_basic/check_list/purge_relay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
function purge_relay_wrong_arg() {
run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"purge-relay wrong_arg" \
"purge-relay <-s source> \[--filename\] \[--sub-dir\] \[flags\]" 1
"purge-relay <-s source> <-f filename> \[--sub-dir directory\] \[flags\]" 1
}

function purge_relay_wihout_worker() {
Expand Down

0 comments on commit 85ac5b8

Please sign in to comment.