diff --git a/dm/ctl/common/util.go b/dm/ctl/common/util.go index 215c8d7b69..a497088719 100644 --- a/dm/ctl/common/util.go +++ b/dm/ctl/common/util.go @@ -72,7 +72,7 @@ func PrintLines(format string, a ...interface{}) { func PrettyPrintResponse(resp proto.Message) { s, err := marshResponseToString(resp) if err != nil { - PrintLines(errors.ErrorStack(err)) + PrintLines("%v", err) } else { fmt.Println(s) } @@ -82,7 +82,7 @@ func PrettyPrintResponse(resp proto.Message) { func PrettyPrintInterface(resp interface{}) { s, err := json.MarshalIndent(resp, "", " ") if err != nil { - PrintLines(errors.ErrorStack(err)) + PrintLines("%v", err) } else { fmt.Println(string(s)) } @@ -147,7 +147,7 @@ func PrettyPrintResponseWithCheckTask(resp proto.Message, subStr string) bool { } if err != nil { - fmt.Println(errors.ErrorStack(err)) + PrintLines("%v", err) } else { // add indent to make it prettily. replacedStr = strings.Replace(replacedStr, "detail: {", " \tdetail: {", 1) diff --git a/dm/ctl/master/check_task.go b/dm/ctl/master/check_task.go index ef4b49c40b..c73fb26fac 100644 --- a/dm/ctl/master/check_task.go +++ b/dm/ctl/master/check_task.go @@ -17,7 +17,6 @@ import ( "context" "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/checker" @@ -44,7 +43,7 @@ func checkTaskFunc(cmd *cobra.Command, _ []string) { } content, err := common.GetFileContent(cmd.Flags().Arg(0)) if err != nil { - common.PrintLines("get file content error:\n%v", errors.ErrorStack(err)) + common.PrintLines("get file content error:\n%v", err) return } @@ -57,7 +56,7 @@ func checkTaskFunc(cmd *cobra.Command, _ []string) { Task: string(content), }) if err != nil { - common.PrintLines("fail to check task:\n%v", errors.ErrorStack(err)) + common.PrintLines("fail to check task:\n%v", err) return } diff --git a/dm/ctl/master/list_member.go b/dm/ctl/master/list_member.go index 2ce17cafac..dc0cbe848b 100644 --- a/dm/ctl/master/list_member.go +++ b/dm/ctl/master/list_member.go @@ -17,7 +17,6 @@ import ( "context" "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -73,7 +72,7 @@ func listMemberFunc(cmd *cobra.Command, _ []string) { leader, master, worker, err := convertListMemberType(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) } ctx, cancel := context.WithCancel(context.Background()) @@ -88,7 +87,7 @@ func listMemberFunc(cmd *cobra.Command, _ []string) { }) if err != nil { - common.PrintLines("list member failed, error:\n%v", errors.ErrorStack(err)) + common.PrintLines("list member failed, error:\n%v", err) return } common.PrettyPrintResponse(resp) diff --git a/dm/ctl/master/migrate_relay.go b/dm/ctl/master/migrate_relay.go index ea63a2af94..f753df16ba 100644 --- a/dm/ctl/master/migrate_relay.go +++ b/dm/ctl/master/migrate_relay.go @@ -18,7 +18,6 @@ import ( "os" "strconv" - "github.com/pingcap/errors" "github.com/spf13/cobra" "go.uber.org/zap" @@ -49,7 +48,7 @@ func migrateRelayFunc(cmd *cobra.Command, _ []string) { binlogName := cmd.Flags().Arg(1) binlogPos, err := strconv.Atoi(cmd.Flags().Arg(2)) if err != nil { - common.PrintLines(errors.ErrorStack(err)) + common.PrintLines("%v", err) } ctx, cancel := context.WithCancel(context.Background()) diff --git a/dm/ctl/master/offline_member.go b/dm/ctl/master/offline_member.go index 488c05f377..69959cac80 100644 --- a/dm/ctl/master/offline_member.go +++ b/dm/ctl/master/offline_member.go @@ -65,12 +65,12 @@ func offlineMemberFunc(cmd *cobra.Command, _ []string) { offlineType, err := convertOfflineMemberType(cmd) if err != nil { - common.PrintLines("get offline type failed, error:\n%v", errors.ErrorStack(err)) + common.PrintLines("get offline type failed, error:\n%v", err) return } name, err := cmd.Flags().GetString("name") if err != nil { - common.PrintLines("get offline name failed, error:\n%v", errors.ErrorStack(err)) + common.PrintLines("get offline name failed, error:\n%v", err) return } else if name == "" { common.PrintLines("a member name must be specified") @@ -85,11 +85,12 @@ func offlineMemberFunc(cmd *cobra.Command, _ []string) { Name: name, }) if err != nil { - common.PrintLines("offline member failed, error:\n%v", errors.ErrorStack(err)) + common.PrintLines("offline member failed, error:\n%v", err) return } if !resp.Result { common.PrintLines("offline member failed:\n%v", resp.Msg) + return } common.PrettyPrintResponse(resp) } diff --git a/dm/ctl/master/operate_leader.go b/dm/ctl/master/operate_leader.go index 9efa881fa2..9af88bffe8 100644 --- a/dm/ctl/master/operate_leader.go +++ b/dm/ctl/master/operate_leader.go @@ -17,7 +17,6 @@ import ( "context" "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -70,7 +69,7 @@ func operateLeaderFunc(cmd *cobra.Command, _ []string) { Op: op, }) if err != nil { - common.PrintLines("fail to operate leader:\n%v", errors.ErrorStack(err)) + common.PrintLines("fail to operate leader:\n%v", err) return } diff --git a/dm/ctl/master/operate_source.go b/dm/ctl/master/operate_source.go index fa87dc4bec..ee97cbac6c 100644 --- a/dm/ctl/master/operate_source.go +++ b/dm/ctl/master/operate_source.go @@ -20,7 +20,6 @@ import ( "github.com/pingcap/dm/dm/ctl/common" "github.com/pingcap/dm/dm/pb" - "github.com/pingcap/errors" "github.com/spf13/cobra" ) @@ -59,7 +58,7 @@ func operateSourceFunc(cmd *cobra.Command, _ []string) { configFile := cmd.Flags().Arg(1) content, err := common.GetFileContent(configFile) if err != nil { - common.PrintLines("get file content error:\n%v", errors.ErrorStack(err)) + common.PrintLines("get file content error:\n%v", err) return } ctx, cancel := context.WithCancel(context.Background()) @@ -77,7 +76,7 @@ func operateSourceFunc(cmd *cobra.Command, _ []string) { Op: op, }) if err != nil { - common.PrintLines("can not update task:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not update task:\n%v", err) return } diff --git a/dm/ctl/master/pause_relay.go b/dm/ctl/master/pause_relay.go index 427b88fad0..f0c4e41965 100644 --- a/dm/ctl/master/pause_relay.go +++ b/dm/ctl/master/pause_relay.go @@ -17,7 +17,6 @@ import ( "fmt" "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -44,7 +43,7 @@ func pauseRelayFunc(cmd *cobra.Command, _ []string) { sources, err := common.GetSourceArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } if len(sources) == 0 { @@ -54,7 +53,7 @@ func pauseRelayFunc(cmd *cobra.Command, _ []string) { resp, err := common.OperateRelay(pb.RelayOp_PauseRelay, sources) if err != nil { - common.PrintLines("can not pause relay unit:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not pause relay unit:\n%v", err) return } diff --git a/dm/ctl/master/pause_task.go b/dm/ctl/master/pause_task.go index 370be1c7b9..88ec1fdabb 100644 --- a/dm/ctl/master/pause_task.go +++ b/dm/ctl/master/pause_task.go @@ -16,7 +16,6 @@ package master import ( "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -44,13 +43,13 @@ func pauseTaskFunc(cmd *cobra.Command, _ []string) { sources, err := common.GetSourceArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } resp, err := common.OperateTask(pb.TaskOp_Pause, name, sources) if err != nil { - common.PrintLines("can not pause task %s:\n%v", name, errors.ErrorStack(err)) + common.PrintLines("can not pause task %s:\n%v", name, err) return } diff --git a/dm/ctl/master/purge_relay.go b/dm/ctl/master/purge_relay.go index 95a74bc68a..d8e290e65c 100644 --- a/dm/ctl/master/purge_relay.go +++ b/dm/ctl/master/purge_relay.go @@ -63,7 +63,7 @@ func purgeRelayFunc(cmd *cobra.Command, _ []string) { sources, err := common.GetSourceArgs(cmd) if err != nil { - fmt.Println(errors.ErrorStack(err)) + common.PrintLines("%v", err) return } if len(sources) == 0 { @@ -145,7 +145,7 @@ func purgeRelayFunc(cmd *cobra.Command, _ []string) { SubDir: subDir, }) if err != nil { - common.PrintLines("can not purge relay log files: \n%s", errors.ErrorStack(err)) + common.PrintLines("can not purge relay log files: \n%v", err) return } diff --git a/dm/ctl/master/query_error.go b/dm/ctl/master/query_error.go index ee12b0447e..859b485ed3 100644 --- a/dm/ctl/master/query_error.go +++ b/dm/ctl/master/query_error.go @@ -19,7 +19,6 @@ import ( "github.com/pingcap/dm/dm/ctl/common" "github.com/pingcap/dm/dm/pb" - "github.com/pingcap/dm/pkg/terror" "github.com/spf13/cobra" ) @@ -45,7 +44,7 @@ func queryErrorFunc(cmd *cobra.Command, _ []string) { sources, err := common.GetSourceArgs(cmd) if err != nil { - common.PrintLines("%s", terror.Message(err)) + common.PrintLines("%v", err) return } @@ -64,7 +63,7 @@ func queryErrorFunc(cmd *cobra.Command, _ []string) { if len(sources) > 0 { common.PrintLines("sources: %v", sources) } - common.PrintLines("error: %s", terror.Message(err)) + common.PrintLines("error: %v", err) return } diff --git a/dm/ctl/master/query_status.go b/dm/ctl/master/query_status.go index 0f308ad10c..d5fc3531e8 100644 --- a/dm/ctl/master/query_status.go +++ b/dm/ctl/master/query_status.go @@ -22,7 +22,6 @@ import ( "github.com/pingcap/dm/dm/ctl/common" "github.com/pingcap/dm/dm/pb" - "github.com/pingcap/dm/pkg/terror" ) const stageError = "Error" @@ -61,7 +60,7 @@ func queryStatusFunc(cmd *cobra.Command, _ []string) { sources, err := common.GetSourceArgs(cmd) if err != nil { - common.PrintLines("%s", terror.Message(err)) + common.PrintLines("%v", err) return } @@ -73,13 +72,13 @@ func queryStatusFunc(cmd *cobra.Command, _ []string) { Sources: sources, }) if err != nil { - common.PrintLines("can not query %s task's status(in sources %v):\n%s", taskName, sources, terror.Message(err)) + common.PrintLines("can not query %s task's status(in sources %v):\n%v", taskName, sources, err) return } more, err := cmd.Flags().GetBool("more") if err != nil { - common.PrintLines("%s", terror.Message(err)) + common.PrintLines("%v", err) return } diff --git a/dm/ctl/master/resume_relay.go b/dm/ctl/master/resume_relay.go index 54ac1e89ac..9de40d7a7d 100644 --- a/dm/ctl/master/resume_relay.go +++ b/dm/ctl/master/resume_relay.go @@ -17,7 +17,6 @@ import ( "fmt" "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -44,7 +43,7 @@ func resumeRelayFunc(cmd *cobra.Command, _ []string) { sources, err := common.GetSourceArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } if len(sources) == 0 { @@ -54,7 +53,7 @@ func resumeRelayFunc(cmd *cobra.Command, _ []string) { resp, err := common.OperateRelay(pb.RelayOp_ResumeRelay, sources) if err != nil { - common.PrintLines("can not resume relay unit:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not resume relay unit:\n%v", err) return } diff --git a/dm/ctl/master/resume_task.go b/dm/ctl/master/resume_task.go index 86c8c150cb..c9711645eb 100644 --- a/dm/ctl/master/resume_task.go +++ b/dm/ctl/master/resume_task.go @@ -16,7 +16,6 @@ package master import ( "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -44,13 +43,13 @@ func resumeTaskFunc(cmd *cobra.Command, _ []string) { sources, err := common.GetSourceArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } resp, err := common.OperateTask(pb.TaskOp_Resume, name, sources) if err != nil { - common.PrintLines("can not resume task %s:\n%v", name, errors.ErrorStack(err)) + common.PrintLines("can not resume task %s:\n%v", name, err) return } diff --git a/dm/ctl/master/show_ddl_locks.go b/dm/ctl/master/show_ddl_locks.go index fcc5b02c4a..c078fcd22c 100644 --- a/dm/ctl/master/show_ddl_locks.go +++ b/dm/ctl/master/show_ddl_locks.go @@ -20,7 +20,6 @@ import ( "github.com/pingcap/dm/dm/ctl/common" "github.com/pingcap/dm/dm/pb" - "github.com/pingcap/errors" "github.com/spf13/cobra" ) @@ -45,7 +44,7 @@ func showDDLLocksFunc(cmd *cobra.Command, _ []string) { sources, err := common.GetSourceArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } @@ -57,7 +56,7 @@ func showDDLLocksFunc(cmd *cobra.Command, _ []string) { Sources: sources, }) if err != nil { - common.PrintLines("can not show DDL locks for task %s and sources %v:\n%s", taskName, sources, errors.ErrorStack(err)) + common.PrintLines("can not show DDL locks for task %s and sources %v:\n%v", taskName, sources, err) return } diff --git a/dm/ctl/master/sql_inject.go b/dm/ctl/master/sql_inject.go index 5345c6d323..de750ea3e2 100644 --- a/dm/ctl/master/sql_inject.go +++ b/dm/ctl/master/sql_inject.go @@ -18,7 +18,6 @@ import ( "os" "strings" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -45,7 +44,7 @@ func sqlInjectFunc(cmd *cobra.Command, _ []string) { sources, err := common.GetSourceArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } if len(sources) != 1 { @@ -62,13 +61,13 @@ func sqlInjectFunc(cmd *cobra.Command, _ []string) { extraArgs := cmd.Flags().Args()[1:] realSQLs, err := common.ExtractSQLsFromArgs(extraArgs) if err != nil { - common.PrintLines("check sqls err %s", errors.ErrorStack(err)) + common.PrintLines("check sqls err %v", err) return } for _, sql := range realSQLs { isDDL, err2 := common.IsDDL(sql) if err2 != nil { - common.PrintLines("check sql err %s", errors.ErrorStack(err2)) + common.PrintLines("check sql err %v", err2) return } if !isDDL { @@ -87,7 +86,7 @@ func sqlInjectFunc(cmd *cobra.Command, _ []string) { Source: sources[0], }) if err != nil { - common.PrintLines("can not inject sql:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not inject sql:\n%v", err) return } diff --git a/dm/ctl/master/sql_replace.go b/dm/ctl/master/sql_replace.go index 83a1ec0341..aa745c0848 100644 --- a/dm/ctl/master/sql_replace.go +++ b/dm/ctl/master/sql_replace.go @@ -21,7 +21,6 @@ import ( "github.com/pingcap/dm/dm/ctl/common" "github.com/pingcap/dm/dm/pb" - "github.com/pingcap/errors" "github.com/spf13/cobra" ) @@ -55,7 +54,7 @@ func sqlReplaceFunc(cmd *cobra.Command, _ []string) { var source string sources, err := common.GetSourceArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } if sharding { @@ -79,7 +78,7 @@ func sqlReplaceFunc(cmd *cobra.Command, _ []string) { extraArgs := cmd.Flags().Args()[1:] realSQLs, err := common.ExtractSQLsFromArgs(extraArgs) if err != nil { - common.PrintLines("check SQLs error: %s", errors.ErrorStack(err)) + common.PrintLines("check SQLs error: %v", err) return } @@ -96,7 +95,7 @@ func sqlReplaceFunc(cmd *cobra.Command, _ []string) { Sharding: sharding, }) if err != nil { - common.PrintLines("can not replace SQL:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not replace SQL:\n%v", err) return } diff --git a/dm/ctl/master/sql_skip.go b/dm/ctl/master/sql_skip.go index 89d49037df..719f279250 100644 --- a/dm/ctl/master/sql_skip.go +++ b/dm/ctl/master/sql_skip.go @@ -18,7 +18,6 @@ import ( "os" "strings" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -55,7 +54,7 @@ func sqlSkipFunc(cmd *cobra.Command, _ []string) { var source string sources, err := common.GetSourceArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } if sharding { @@ -89,7 +88,7 @@ func sqlSkipFunc(cmd *cobra.Command, _ []string) { Sharding: sharding, }) if err != nil { - common.PrintLines("can not skip SQL:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not skip SQL:\n%v", err) return } diff --git a/dm/ctl/master/start_task.go b/dm/ctl/master/start_task.go index 0335d24e6b..2203920786 100644 --- a/dm/ctl/master/start_task.go +++ b/dm/ctl/master/start_task.go @@ -17,13 +17,11 @@ import ( "context" "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/checker" "github.com/pingcap/dm/dm/ctl/common" "github.com/pingcap/dm/dm/pb" - "github.com/pingcap/dm/pkg/terror" ) // NewStartTaskCmd creates a StartTask command @@ -46,19 +44,19 @@ func startTaskFunc(cmd *cobra.Command, _ []string) { } content, err := common.GetFileContent(cmd.Flags().Arg(0)) if err != nil { - common.PrintLines("get file content error:\n%v", errors.ErrorStack(err)) + common.PrintLines("get file content error:\n%v", err) return } sources, err := common.GetSourceArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } removeMeta, err := cmd.Flags().GetBool("remove-meta") if err != nil { - common.PrintLines("%s", terror.Message(err)) + common.PrintLines("%v", err) return } @@ -73,7 +71,7 @@ func startTaskFunc(cmd *cobra.Command, _ []string) { RemoveMeta: removeMeta, }) if err != nil { - common.PrintLines("can not start task:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not start task:\n%v", err) return } diff --git a/dm/ctl/master/stop_task.go b/dm/ctl/master/stop_task.go index f4babf9ff0..4b82c06274 100644 --- a/dm/ctl/master/stop_task.go +++ b/dm/ctl/master/stop_task.go @@ -16,7 +16,6 @@ package master import ( "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -44,13 +43,13 @@ func stopTaskFunc(cmd *cobra.Command, _ []string) { sources, err := common.GetSourceArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } resp, err := common.OperateTask(pb.TaskOp_Stop, name, sources) if err != nil { - common.PrintLines("can not stop task %s:\n%v", name, errors.ErrorStack(err)) + common.PrintLines("can not stop task %s:\n%v", name, err) return } diff --git a/dm/ctl/master/switch_relay_master.go b/dm/ctl/master/switch_relay_master.go index 320c4a5c03..f67469f9b3 100644 --- a/dm/ctl/master/switch_relay_master.go +++ b/dm/ctl/master/switch_relay_master.go @@ -18,7 +18,6 @@ import ( "fmt" "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -45,7 +44,7 @@ func switchRelayMasterFunc(cmd *cobra.Command, _ []string) { sources, err := common.GetSourceArgs(cmd) if err != nil { - fmt.Println(errors.ErrorStack(err)) + common.PrintLines("%v", err) return } if len(sources) == 0 { @@ -60,7 +59,7 @@ func switchRelayMasterFunc(cmd *cobra.Command, _ []string) { Sources: sources, }) if err != nil { - common.PrintLines("can not switch relay's master server (in sources %v):\n%s", sources, errors.ErrorStack(err)) + common.PrintLines("can not switch relay's master server (in sources %v):\n%v", sources, err) return } diff --git a/dm/ctl/master/unlock_ddl_lock.go b/dm/ctl/master/unlock_ddl_lock.go index cf4c3244ed..f181ed33e2 100644 --- a/dm/ctl/master/unlock_ddl_lock.go +++ b/dm/ctl/master/unlock_ddl_lock.go @@ -21,7 +21,6 @@ import ( "github.com/pingcap/dm/dm/ctl/common" "github.com/pingcap/dm/dm/pb" - "github.com/pingcap/errors" "github.com/spf13/cobra" ) @@ -46,7 +45,7 @@ func unlockDDLLockFunc(cmd *cobra.Command, _ []string) { } owner, err := cmd.Flags().GetString("owner") if err != nil { - fmt.Println(errors.ErrorStack(err)) + common.PrintLines("%v", err) return } @@ -60,7 +59,7 @@ func unlockDDLLockFunc(cmd *cobra.Command, _ []string) { forceRemove, err := cmd.Flags().GetBool("force-remove") if err != nil { - fmt.Println(errors.ErrorStack(err)) + common.PrintLines("%v", err) return } diff --git a/dm/ctl/master/update_masterconfig.go b/dm/ctl/master/update_masterconfig.go index 9a533d6895..1ddf9621bf 100644 --- a/dm/ctl/master/update_masterconfig.go +++ b/dm/ctl/master/update_masterconfig.go @@ -20,7 +20,6 @@ import ( "github.com/pingcap/dm/dm/ctl/common" "github.com/pingcap/dm/dm/pb" - "github.com/pingcap/errors" "github.com/spf13/cobra" ) @@ -42,7 +41,7 @@ func updateMasterConfigFunc(cmd *cobra.Command, _ []string) { } content, err := common.GetFileContent(cmd.Flags().Arg(0)) if err != nil { - common.PrintLines("get file content error:\n%v", errors.ErrorStack(err)) + common.PrintLines("get file content error:\n%v", err) return } @@ -54,7 +53,7 @@ func updateMasterConfigFunc(cmd *cobra.Command, _ []string) { Config: string(content), }) if err != nil { - common.PrintLines("can not update master config:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not update master config:\n%v", err) return } diff --git a/dm/ctl/master/update_relay.go b/dm/ctl/master/update_relay.go index 4ebf28dc0d..4cb840bf24 100644 --- a/dm/ctl/master/update_relay.go +++ b/dm/ctl/master/update_relay.go @@ -18,7 +18,6 @@ import ( "fmt" "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -45,7 +44,7 @@ func updateRelayFunc(cmd *cobra.Command, _ []string) { content, err := common.GetFileContent(cmd.Flags().Arg(0)) if err != nil { - common.PrintLines("get file content error:\n%v", errors.ErrorStack(err)) + common.PrintLines("get file content error:\n%v", err) return } @@ -65,7 +64,7 @@ func updateRelayFunc(cmd *cobra.Command, _ []string) { }) if err != nil { - common.PrintLines("can not update relay config:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not update relay config:\n%v", err) return } diff --git a/dm/ctl/master/update_task.go b/dm/ctl/master/update_task.go index bd30e4b6b7..6387672320 100644 --- a/dm/ctl/master/update_task.go +++ b/dm/ctl/master/update_task.go @@ -17,7 +17,6 @@ import ( "context" "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/checker" @@ -44,13 +43,13 @@ func updateTaskFunc(cmd *cobra.Command, _ []string) { } content, err := common.GetFileContent(cmd.Flags().Arg(0)) if err != nil { - common.PrintLines("get file content error:\n%v", errors.ErrorStack(err)) + common.PrintLines("get file content error:\n%v", err) return } sources, err := common.GetSourceArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } @@ -64,7 +63,7 @@ func updateTaskFunc(cmd *cobra.Command, _ []string) { Sources: sources, }) if err != nil { - common.PrintLines("can not update task:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not update task:\n%v", err) return } diff --git a/dm/master/scheduler/scheduler.go b/dm/master/scheduler/scheduler.go index 1ae480bdb8..0fa038abd8 100644 --- a/dm/master/scheduler/scheduler.go +++ b/dm/master/scheduler/scheduler.go @@ -561,7 +561,7 @@ func (s *Scheduler) RemoveWorker(name string) error { if !ok { return terror.ErrSchedulerWorkerNotExist.Generate(name) } else if w.Stage() != WorkerOffline { - return terror.ErrSchedulerWorkerOnline.Generate() + return terror.ErrSchedulerWorkerOnline.Generate(name) } // delete the info in etcd. diff --git a/dm/master/server.go b/dm/master/server.go index 4271db7221..7ed5063316 100644 --- a/dm/master/server.go +++ b/dm/master/server.go @@ -281,7 +281,7 @@ func (s *Server) RegisterWorker(ctx context.Context, req *pb.RegisterWorkerReque if err != nil { return &pb.RegisterWorkerResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), }, nil } log.L().Info("register worker successfully", zap.String("name", req.Name), zap.String("address", req.Address)) @@ -310,7 +310,7 @@ func (s *Server) OfflineMember(ctx context.Context, req *pb.OfflineMemberRequest if err != nil { return &pb.OfflineMemberResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), }, nil } } else if req.Type == common.Master { @@ -318,7 +318,7 @@ func (s *Server) OfflineMember(ctx context.Context, req *pb.OfflineMemberRequest if err != nil { return &pb.OfflineMemberResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), }, nil } } else { @@ -383,7 +383,7 @@ func (s *Server) StartTask(ctx context.Context, req *pb.StartTaskRequest) (*pb.S resp := &pb.StartTaskResponse{} cfg, stCfgs, err := s.generateSubTask(ctx, req.Task) if err != nil { - resp.Msg = errors.ErrorStack(err) + resp.Msg = err.Error() return resp, nil } log.L().Info("", zap.String("task name", cfg.Name), zap.Stringer("task", cfg), zap.String("request", "StartTask")) @@ -432,7 +432,7 @@ func (s *Server) StartTask(ctx context.Context, req *pb.StartTaskRequest) (*pb.S err = s.scheduler.AddSubTasks(subtaskCfgPointersToInstances(stCfgs...)...) s.removeMetaLock.Unlock() if err != nil { - resp.Msg = errors.ErrorStack(err) + resp.Msg = err.Error() return resp, nil } resp.Result = true @@ -487,7 +487,7 @@ func (s *Server) OperateTask(ctx context.Context, req *pb.OperateTaskRequest) (* err = s.scheduler.UpdateExpectSubTaskStage(expect, req.Name, sources...) } if err != nil { - resp.Msg = errors.ErrorStack(err) + resp.Msg = err.Error() return resp, nil } @@ -513,7 +513,7 @@ func (s *Server) UpdateTask(ctx context.Context, req *pb.UpdateTaskRequest) (*pb if err != nil { return &pb.UpdateTaskResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), }, nil } log.L().Info("update task", zap.String("task name", cfg.Name), zap.Stringer("task", cfg)) @@ -753,7 +753,7 @@ func (s *Server) UnlockDDLLock(ctx context.Context, req *pb.UnlockDDLLockRequest err := s.pessimist.UnlockLock(ctx, req.ID, req.ReplaceOwner, req.ForceRemove) if err != nil { resp.Result = false - resp.Msg = terror.Message(err) + resp.Msg = err.Error() } return resp, nil @@ -777,7 +777,7 @@ func (s *Server) HandleSQLs(ctx context.Context, req *pb.HandleSQLsRequest) (*pb if err != nil { return &pb.HandleSQLsResponse{ Result: false, - Msg: fmt.Sprintf("save request with --sharding error:\n%s", errors.ErrorStack(err)), + Msg: fmt.Sprintf("save request with --sharding error:\n%v", err), }, nil } log.L().Info("handle sqls request was saved", zap.String("task name", req.Name), zap.String("request", "HandleSQLs")) @@ -816,7 +816,7 @@ func (s *Server) HandleSQLs(ctx context.Context, req *pb.HandleSQLsRequest) (*pb response, err := worker.SendRequest(ctx, subReq, s.cfg.RPCTimeout) workerResp := &pb.CommonWorkerResponse{} if err != nil { - workerResp = errorCommonWorkerResponse(errors.ErrorStack(err), req.Source, worker.BaseInfo().Name) + workerResp = errorCommonWorkerResponse(err.Error(), req.Source, worker.BaseInfo().Name) } else { workerResp = response.HandleSubTaskSQLs } @@ -861,7 +861,7 @@ func (s *Server) PurgeWorkerRelay(ctx context.Context, req *pb.PurgeWorkerRelayR resp, err := worker.SendRequest(ctx, workerReq, s.cfg.RPCTimeout) workerResp := &pb.CommonWorkerResponse{} if err != nil { - workerResp = errorCommonWorkerResponse(errors.ErrorStack(err), source, worker.BaseInfo().Name) + workerResp = errorCommonWorkerResponse(err.Error(), source, worker.BaseInfo().Name) } else { workerResp = resp.PurgeRelay } @@ -905,7 +905,7 @@ func (s *Server) SwitchWorkerRelayMaster(ctx context.Context, req *pb.SwitchWork handleErr := func(err error, source string) { log.L().Error("response error", zap.Error(err)) - resp := errorCommonWorkerResponse(errors.ErrorStack(err), source, "") + resp := errorCommonWorkerResponse(err.Error(), source, "") workerRespCh <- resp } @@ -928,7 +928,7 @@ func (s *Server) SwitchWorkerRelayMaster(ctx context.Context, req *pb.SwitchWork resp, err := worker.SendRequest(ctx, request, s.cfg.RPCTimeout) workerResp := &pb.CommonWorkerResponse{} if err != nil { - workerResp = errorCommonWorkerResponse(errors.ErrorStack(err), sourceID, worker.BaseInfo().Name) + workerResp = errorCommonWorkerResponse(err.Error(), sourceID, worker.BaseInfo().Name) } else { workerResp = resp.SwitchRelayMaster } @@ -987,7 +987,7 @@ func (s *Server) OperateWorkerRelayTask(ctx context.Context, req *pb.OperateWork } err := s.scheduler.UpdateExpectRelayStage(expect, req.Sources...) if err != nil { - resp.Msg = errors.ErrorStack(err) + resp.Msg = err.Error() return resp, nil } resp.Result = true @@ -1020,7 +1020,7 @@ func (s *Server) getStatusFromWorkers(ctx context.Context, sources []string, tas log.L().Error("response error", zap.Error(err)) resp := &pb.QueryStatusResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), SourceStatus: &pb.SourceStatus{ Source: source, }, @@ -1046,7 +1046,7 @@ func (s *Server) getStatusFromWorkers(ctx context.Context, sources []string, tas if err != nil { workerStatus = &pb.QueryStatusResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), SourceStatus: &pb.SourceStatus{}, } } else { @@ -1076,7 +1076,7 @@ func (s *Server) getErrorFromWorkers(ctx context.Context, sources []string, task log.L().Error("response error", zap.Error(err)) resp := &pb.QueryErrorResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), SourceError: &pb.SourceError{ Source: source, }, @@ -1103,7 +1103,7 @@ func (s *Server) getErrorFromWorkers(ctx context.Context, sources []string, task if err != nil { workerError = &pb.QueryErrorResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), SourceError: &pb.SourceError{}, } } else { @@ -1154,7 +1154,7 @@ func (s *Server) UpdateMasterConfig(ctx context.Context, req *pb.UpdateMasterCon s.Unlock() return &pb.UpdateMasterConfigResponse{ Result: false, - Msg: "Failed to write config to local file. detail: " + errors.ErrorStack(err), + Msg: "Failed to write config to local file. detail: " + err.Error(), }, nil } log.L().Info("saved dm-master config file", zap.String("config file", s.cfg.ConfigFile), zap.String("request", "UpdateMasterConfig")) @@ -1166,7 +1166,7 @@ func (s *Server) UpdateMasterConfig(ctx context.Context, req *pb.UpdateMasterCon s.Unlock() return &pb.UpdateMasterConfigResponse{ Result: false, - Msg: fmt.Sprintf("Failed to parse configure from file %s, detail: ", cfg.ConfigFile) + errors.ErrorStack(err), + Msg: fmt.Sprintf("Failed to parse configure from file %s, detail: ", cfg.ConfigFile) + err.Error(), }, nil } log.L().Info("update dm-master config", zap.Stringer("config", cfg), zap.String("request", "UpdateMasterConfig")) @@ -1205,7 +1205,7 @@ func (s *Server) UpdateWorkerRelayConfig(ctx context.Context, req *pb.UpdateWork } resp, err := worker.SendRequest(ctx, request, s.cfg.RPCTimeout) if err != nil { - return errorCommonWorkerResponse(errors.ErrorStack(err), source, worker.BaseInfo().Name), nil + return errorCommonWorkerResponse(err.Error(), source, worker.BaseInfo().Name), nil } return resp.UpdateRelay, nil } @@ -1249,7 +1249,7 @@ func (s *Server) MigrateWorkerRelay(ctx context.Context, req *pb.MigrateWorkerRe } resp, err := worker.SendRequest(ctx, request, s.cfg.RPCTimeout) if err != nil { - return errorCommonWorkerResponse(errors.ErrorStack(err), source, worker.BaseInfo().Name), nil + return errorCommonWorkerResponse(err.Error(), source, worker.BaseInfo().Name), nil } return resp.MigrateRelay, nil } @@ -1270,7 +1270,7 @@ func (s *Server) CheckTask(ctx context.Context, req *pb.CheckTaskRequest) (*pb.C if err != nil { return &pb.CheckTaskResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), }, nil } @@ -1317,7 +1317,7 @@ func (s *Server) OperateSource(ctx context.Context, req *pb.OperateSourceRequest Result: false, } if err != nil { - resp.Msg = errors.ErrorStack(err) + resp.Msg = err.Error() return resp, nil } var w *scheduler.Worker @@ -1325,7 +1325,7 @@ func (s *Server) OperateSource(ctx context.Context, req *pb.OperateSourceRequest case pb.SourceOp_StartSource: err := s.scheduler.AddSourceCfg(*cfg) if err != nil { - resp.Msg = errors.ErrorStack(err) + resp.Msg = err.Error() return resp, nil } // for start source, we should get worker after start source @@ -1338,7 +1338,7 @@ func (s *Server) OperateSource(ctx context.Context, req *pb.OperateSourceRequest w = s.scheduler.GetWorkerBySource(cfg.SourceID) err := s.scheduler.RemoveSourceCfg(cfg.SourceID) if err != nil { - resp.Msg = errors.ErrorStack(err) + resp.Msg = err.Error() return resp, nil } default: @@ -1632,7 +1632,7 @@ func (s *Server) handleOperationResult(ctx context.Context, cli *scheduler.Worke var response *pb.CommonWorkerResponse queryResp, err := s.waitOperationOk(ctx, cli, taskName, sourceID, req) if err != nil { - response = errorCommonWorkerResponse(errors.ErrorStack(err), sourceID, cli.BaseInfo().Name) + response = errorCommonWorkerResponse(err.Error(), sourceID, cli.BaseInfo().Name) } else { response = &pb.CommonWorkerResponse{ Result: true, @@ -1699,7 +1699,7 @@ func (s *Server) listMemberMaster(ctx context.Context, names []string) (*pb.Memb memberList, err := s.etcdClient.MemberList(ctx) if err != nil { - resp.Master.Msg = errors.ErrorStack(err) + resp.Master.Msg = err.Error() return resp, nil } @@ -1749,7 +1749,7 @@ func (s *Server) listMemberWorker(ctx context.Context, names []string) (*pb.Memb workerAgents, err := s.scheduler.GetAllWorkers() if err != nil { - resp.Worker.Msg = errors.ErrorStack(err) + resp.Worker.Msg = err.Error() return resp, nil } @@ -1794,7 +1794,7 @@ func (s *Server) listMemberLeader(ctx context.Context, names []string) (*pb.Memb _, name, addr, err := s.election.LeaderInfo(ctx) if err != nil { - resp.Leader.Msg = errors.ErrorStack(err) + resp.Leader.Msg = err.Error() return resp, nil } @@ -1831,7 +1831,7 @@ func (s *Server) ListMember(ctx context.Context, req *pb.ListMemberRequest) (*pb if req.Leader { res, err := s.listMemberLeader(ctx, req.Names) if err != nil { - resp.Msg = errors.ErrorStack(err) + resp.Msg = err.Error() return resp, nil } members = append(members, &pb.Members{ @@ -1842,7 +1842,7 @@ func (s *Server) ListMember(ctx context.Context, req *pb.ListMemberRequest) (*pb if req.Master { res, err := s.listMemberMaster(ctx, req.Names) if err != nil { - resp.Msg = errors.ErrorStack(err) + resp.Msg = err.Error() return resp, nil } members = append(members, &pb.Members{ @@ -1853,7 +1853,7 @@ func (s *Server) ListMember(ctx context.Context, req *pb.ListMemberRequest) (*pb if req.Worker { res, err := s.listMemberWorker(ctx, req.Names) if err != nil { - resp.Msg = errors.ErrorStack(err) + resp.Msg = err.Error() return resp, nil } members = append(members, &pb.Members{ diff --git a/dm/tracer/server.go b/dm/tracer/server.go index a8f2ac69b8..62f768bbfe 100644 --- a/dm/tracer/server.go +++ b/dm/tracer/server.go @@ -19,7 +19,6 @@ import ( "sync" "time" - "github.com/pingcap/errors" "github.com/siddontang/go/sync2" "github.com/soheilhy/cmux" "go.uber.org/zap" @@ -139,7 +138,7 @@ func (s *Server) UploadSyncerBinlogEvent(ctx context.Context, req *pb.UploadSync if err != nil { return &pb.CommonUploadResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), }, nil } } @@ -157,7 +156,7 @@ func (s *Server) UploadSyncerJobEvent(ctx context.Context, req *pb.UploadSyncerJ if err != nil { return &pb.CommonUploadResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), }, nil } } diff --git a/dm/worker/server.go b/dm/worker/server.go index 604f5a8e39..73afe8b9ec 100644 --- a/dm/worker/server.go +++ b/dm/worker/server.go @@ -600,7 +600,7 @@ func (s *Server) OperateRelay(ctx context.Context, req *pb.OperateRelayRequest) err := w.OperateRelay(ctx, req) if err != nil { log.L().Error("fail to operate relay", zap.String("request", "OperateRelay"), zap.Stringer("payload", req), zap.Error(err)) - resp.Msg = errors.ErrorStack(err) + resp.Msg = err.Error() return resp, nil } @@ -663,7 +663,7 @@ func (s *Server) QueryWorkerConfig(ctx context.Context, req *pb.QueryWorkerConfi workerCfg, err := w.QueryConfig(ctx) if err != nil { resp.Result = false - resp.Msg = errors.ErrorStack(err) + resp.Msg = err.Error() log.L().Error("fail to query worker config", zap.String("request", "QueryWorkerConfig"), zap.Stringer("payload", req), zap.Error(err)) return resp, nil } @@ -671,7 +671,7 @@ func (s *Server) QueryWorkerConfig(ctx context.Context, req *pb.QueryWorkerConfi rawConfig, err := workerCfg.From.Toml() if err != nil { resp.Result = false - resp.Msg = errors.ErrorStack(err) + resp.Msg = err.Error() log.L().Error("fail to marshal worker config", zap.String("request", "QueryWorkerConfig"), zap.Stringer("worker from config", &workerCfg.From), zap.Error(err)) } @@ -808,7 +808,7 @@ func makeCommonWorkerResponse(reqErr error) *pb.CommonWorkerResponse { } if reqErr != nil { resp.Result = false - resp.Msg = errors.ErrorStack(reqErr) + resp.Msg = reqErr.Error() } return resp }