feat: optimize scope size is error (#1831)

Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
Gaius 2022-11-14 21:01:36 +08:00
parent 0f8b75808a
commit 02543c781d
No known key found for this signature in database
GPG Key ID: 8B4E5D1290FA2FFB
1 changed files with 10 additions and 4 deletions

View File

@ -91,10 +91,10 @@ func (s *Service) RegisterPeerTask(ctx context.Context, req *schedulerv1.PeerTas
// does not have a seed peer, it will back-to-source.
peer.NeedBackToSource.Store(needBackToSource)
sizeScope, err := task.SizeScope()
if err != nil || !task.FSM.Is(resource.TaskStateSucceeded) {
peer.Log.Infof("task can not be reused directly, because of task state is %s and %#v",
task.FSM.Current(), err)
if !task.FSM.Is(resource.TaskStateSucceeded) {
peer.Log.Infof("task can not be reused directly, because of task state is %s",
task.FSM.Current())
result, err := s.registerNormalTask(ctx, peer)
if err != nil {
peer.Log.Error(err)
@ -104,6 +104,12 @@ func (s *Service) RegisterPeerTask(ctx context.Context, req *schedulerv1.PeerTas
return result, nil
}
// If SizeScope is invalid, then register as SizeScope_NORMAL.
sizeScope, err := task.SizeScope()
if err != nil {
peer.Log.Warnf("scope size is invalid: %s", err.Error())
}
// The task state is TaskStateSucceeded and SizeScope is not invalid.
peer.Log.Info("task can be reused directly")
switch sizeScope {