Skip to content

Commit

Permalink
feat: if seed peer download task, return NeedBackToSource directly (#…
Browse files Browse the repository at this point in the history
…2980)

Signed-off-by: Gaius <gaius.qi@gmail.com>
  • Loading branch information
gaius-qi authored Dec 26, 2023
1 parent 5989a4d commit 086cb62
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scheduler/config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const (
DefaultSchedulerRetryLimit = 10

// DefaultSchedulerRetryInterval is default retry interval for scheduler.
DefaultSchedulerRetryInterval = 50 * time.Millisecond
DefaultSchedulerRetryInterval = 200 * time.Millisecond

// DefaultSchedulerPieceDownloadTimeout is default timeout of downloading piece.
DefaultSchedulerPieceDownloadTimeout = 30 * time.Minute
Expand Down
4 changes: 2 additions & 2 deletions scheduler/service/service_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ func (v *V2) SyncProbes(stream schedulerv2.Scheduler_SyncProbesServer) error {
// handleRegisterPeerRequest handles RegisterPeerRequest of AnnouncePeerRequest.
func (v *V2) handleRegisterPeerRequest(ctx context.Context, stream schedulerv2.Scheduler_AnnouncePeerServer, hostID, taskID, peerID string, req *schedulerv2.RegisterPeerRequest) error {
// Handle resource included host, task, and peer.
_, task, peer, err := v.handleResource(ctx, stream, hostID, taskID, peerID, req.GetDownload())
host, task, peer, err := v.handleResource(ctx, stream, hostID, taskID, peerID, req.GetDownload())
if err != nil {
return err
}
Expand All @@ -837,7 +837,7 @@ func (v *V2) handleRegisterPeerRequest(ctx context.Context, stream schedulerv2.S
blocklist.Add(peer.ID)
if !((task.FSM.Is(resource.TaskStateRunning) || task.FSM.Is(resource.TaskStateSucceeded)) && task.HasAvailablePeer(blocklist)) {
download := proto.Clone(req.Download).(*commonv2.Download)
if download.GetNeedBackToSource() {
if download.GetNeedBackToSource() || host.Type != types.HostTypeNormal {
peer.Log.Infof("peer need back to source")
peer.NeedBackToSource.Store(true)
} else {
Expand Down

0 comments on commit 086cb62

Please sign in to comment.