Skip to content

Commit

Permalink
feat: add time out when register (#588)
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Ma <majinjing3@gmail.com>
  • Loading branch information
jim3ma authored Aug 30, 2021
1 parent 863e943 commit 261ff0b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions client/daemon/peer/peertask_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,20 @@ func newStreamPeerTask(ctx context.Context,
logger.Debugf("request overview, pid: %s, url: %s, filter: %s, meta: %s, tag: %s",
request.PeerId, request.Url, request.UrlMeta.Filter, request.UrlMeta, request.UrlMeta.Tag)
// trace register
regCtx, regSpan := tracer.Start(ctx, config.SpanRegisterTask)
regCtx, cancel := context.WithTimeout(ctx, schedulerOption.ScheduleTimeout.Duration)
defer cancel()
regCtx, regSpan := tracer.Start(regCtx, config.SpanRegisterTask)
logger.Infof("step 1: peer %s start to register", request.PeerId)
result, err := schedulerClient.RegisterPeerTask(regCtx, request)
regSpan.RecordError(err)
regSpan.End()

var needBackSource bool
if err != nil {
logger.Errorf("step 1: peer %s register failed: err", request.PeerId, err)
if err == context.DeadlineExceeded {
logger.Errorf("scheduler did not response in %s", schedulerOption.ScheduleTimeout.Duration)
}
logger.Errorf("step 1: peer %s register failed: %s", request.PeerId, err)
if schedulerOption.DisableAutoBackSource {
logger.Errorf("register peer task failed: %s, peer id: %s, auto back source disabled", err, request.PeerId)
span.RecordError(err)
Expand Down

0 comments on commit 261ff0b

Please sign in to comment.