From 85ac5b81e7b78a40fce1a2ce166c780e2390274d Mon Sep 17 00:00:00 2001 From: ti-srebot <66930949+ti-srebot@users.noreply.github.com> Date: Fri, 25 Dec 2020 10:17:29 +0800 Subject: [PATCH] cherry pick #1358 to release-2.0 (#1361) --- dm/ctl/master/purge_relay.go | 16 ++++++++-------- tests/dmctl_basic/check_list/purge_relay.sh | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dm/ctl/master/purge_relay.go b/dm/ctl/master/purge_relay.go index a5c5fe917d..3bff959574 100644 --- a/dm/ctl/master/purge_relay.go +++ b/dm/ctl/master/purge_relay.go @@ -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, } @@ -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 } @@ -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 { diff --git a/tests/dmctl_basic/check_list/purge_relay.sh b/tests/dmctl_basic/check_list/purge_relay.sh index 9dd9965a5d..ed38b34321 100644 --- a/tests/dmctl_basic/check_list/purge_relay.sh +++ b/tests/dmctl_basic/check_list/purge_relay.sh @@ -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() {