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

Commit

Permalink
remove stack err msg of response msg
Browse files Browse the repository at this point in the history
  • Loading branch information
GMHDBJD committed Jun 16, 2020
1 parent 92a8b5e commit f84068d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 32 deletions.
1 change: 1 addition & 0 deletions dm/ctl/master/offline_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func offlineMemberFunc(cmd *cobra.Command, _ []string) {
}
if !resp.Result {
common.PrintLines("offline member failed:\n%v", resp.Msg)
return
}
common.PrettyPrintResponse(resp)
}
64 changes: 32 additions & 32 deletions dm/master/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: terror.Message(err),
}, nil
}
log.L().Info("register worker successfully", zap.String("name", req.Name), zap.String("address", req.Address))
Expand Down Expand Up @@ -310,15 +310,15 @@ func (s *Server) OfflineMember(ctx context.Context, req *pb.OfflineMemberRequest
if err != nil {
return &pb.OfflineMemberResponse{
Result: false,
Msg: errors.ErrorStack(err),
Msg: terror.Message(err),
}, nil
}
} else if req.Type == common.Master {
err := s.deleteMasterByName(ctx, req.Name)
if err != nil {
return &pb.OfflineMemberResponse{
Result: false,
Msg: errors.ErrorStack(err),
Msg: terror.Message(err),
}, nil
}
} else {
Expand Down Expand Up @@ -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 = terror.Message(err)
return resp, nil
}
log.L().Info("", zap.String("task name", cfg.Name), zap.Stringer("task", cfg), zap.String("request", "StartTask"))
Expand Down Expand Up @@ -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 = terror.Message(err)
return resp, nil
}
resp.Result = true
Expand Down Expand Up @@ -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 = terror.Message(err)
return resp, nil
}

Expand All @@ -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: terror.Message(err),
}, nil
}
log.L().Info("update task", zap.String("task name", cfg.Name), zap.Stringer("task", cfg))
Expand Down Expand Up @@ -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%s", terror.Message(err)),
}, nil
}
log.L().Info("handle sqls request was saved", zap.String("task name", req.Name), zap.String("request", "HandleSQLs"))
Expand Down Expand Up @@ -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(terror.Message(err), req.Source, worker.BaseInfo().Name)
} else {
workerResp = response.HandleSubTaskSQLs
}
Expand Down Expand Up @@ -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(terror.Message(err), source, worker.BaseInfo().Name)
} else {
workerResp = resp.PurgeRelay
}
Expand Down Expand Up @@ -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(terror.Message(err), source, "")
workerRespCh <- resp
}

Expand All @@ -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(terror.Message(err), sourceID, worker.BaseInfo().Name)
} else {
workerResp = resp.SwitchRelayMaster
}
Expand Down Expand Up @@ -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 = terror.Message(err)
return resp, nil
}
resp.Result = true
Expand Down Expand Up @@ -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: terror.Message(err),
SourceStatus: &pb.SourceStatus{
Source: source,
},
Expand All @@ -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: terror.Message(err),
SourceStatus: &pb.SourceStatus{},
}
} else {
Expand Down Expand Up @@ -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: terror.Message(err),
SourceError: &pb.SourceError{
Source: source,
},
Expand All @@ -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: terror.Message(err),
SourceError: &pb.SourceError{},
}
} else {
Expand Down Expand Up @@ -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: " + terror.Message(err),
}, nil
}
log.L().Info("saved dm-master config file", zap.String("config file", s.cfg.ConfigFile), zap.String("request", "UpdateMasterConfig"))
Expand All @@ -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) + terror.Message(err),
}, nil
}
log.L().Info("update dm-master config", zap.Stringer("config", cfg), zap.String("request", "UpdateMasterConfig"))
Expand Down Expand Up @@ -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(terror.Message(err), source, worker.BaseInfo().Name), nil
}
return resp.UpdateRelay, nil
}
Expand Down Expand Up @@ -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(terror.Message(err), source, worker.BaseInfo().Name), nil
}
return resp.MigrateRelay, nil
}
Expand All @@ -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: terror.Message(err),
}, nil
}

Expand Down Expand Up @@ -1317,15 +1317,15 @@ func (s *Server) OperateSource(ctx context.Context, req *pb.OperateSourceRequest
Result: false,
}
if err != nil {
resp.Msg = errors.ErrorStack(err)
resp.Msg = terror.Message(err)
return resp, nil
}
var w *scheduler.Worker
switch req.Op {
case pb.SourceOp_StartSource:
err := s.scheduler.AddSourceCfg(*cfg)
if err != nil {
resp.Msg = errors.ErrorStack(err)
resp.Msg = terror.Message(err)
return resp, nil
}
// for start source, we should get worker after start source
Expand All @@ -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 = terror.Message(err)
return resp, nil
}
default:
Expand Down Expand Up @@ -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(terror.Message(err), sourceID, cli.BaseInfo().Name)
} else {
response = &pb.CommonWorkerResponse{
Result: true,
Expand Down Expand Up @@ -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 = terror.Message(err)
return resp, nil
}

Expand Down Expand Up @@ -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 = terror.Message(err)
return resp, nil
}

Expand Down Expand Up @@ -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 = terror.Message(err)
return resp, nil
}

Expand Down Expand Up @@ -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 = terror.Message(err)
return resp, nil
}
members = append(members, &pb.Members{
Expand All @@ -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 = terror.Message(err)
return resp, nil
}
members = append(members, &pb.Members{
Expand All @@ -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 = terror.Message(err)
return resp, nil
}
members = append(members, &pb.Members{
Expand Down

0 comments on commit f84068d

Please sign in to comment.