Skip to content

Commit

Permalink
feat: returns an scheduling error if the peer state is not PeerStateR…
Browse files Browse the repository at this point in the history
…unning (#1821)

Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Nov 9, 2022
1 parent 7c007b4 commit bde6496
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scheduler/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,20 @@ func (s *Service) handlePieceFail(ctx context.Context, peer *resource.Peer, piec
// Peer state is PeerStateRunning will be rescheduled.
if !peer.FSM.Is(resource.PeerStateRunning) {
peer.Log.Infof("peer can not be rescheduled because peer state is %s", peer.FSM.Current())

// Returns an scheduling error if the peer
// state is not PeerStateRunning.
stream, ok := peer.LoadStream()
if !ok {
peer.Log.Error("load stream failed")
return
}

if err := stream.Send(&schedulerv1.PeerPacket{Code: commonv1.Code_SchedError}); err != nil {
peer.Log.Errorf("send packet failed: %s", err.Error())
return
}

return
}

Expand Down

0 comments on commit bde6496

Please sign in to comment.