diff --git a/src/pkg/scheduler/scheduler.go b/src/pkg/scheduler/scheduler.go index bab6b43c0..1ac5dda3e 100644 --- a/src/pkg/scheduler/scheduler.go +++ b/src/pkg/scheduler/scheduler.go @@ -196,7 +196,13 @@ func (s *scheduler) UnScheduleByID(ctx context.Context, id int64) error { executionID := executions[0].ID // stop the execution if err = s.execMgr.StopAndWait(ctx, executionID, 10*time.Second); err != nil { - return err + if err == task.ErrTimeOut { + // Avoid return this error to the UI, log time out error and continue + // the execution will be finally stopped by jobservice + log.Debugf("time out when stopping the execution %d, but the execution will be stopped eventually", executionID) + } else { + return err + } } // delete execution if err = s.execMgr.Delete(ctx, executionID); err != nil { diff --git a/src/pkg/task/execution.go b/src/pkg/task/execution.go index 1f4d2f8a0..3d8582698 100644 --- a/src/pkg/task/execution.go +++ b/src/pkg/task/execution.go @@ -17,7 +17,6 @@ package task import ( "context" "encoding/json" - "fmt" "sync" "time" @@ -34,6 +33,7 @@ var ( // ExecMgr is a global execution manager instance ExecMgr = NewExecutionManager() executionSweeperCount = map[string]uint8{} + ErrTimeOut = errors.New("stopping the execution timeout") ) // ExecutionManager manages executions. @@ -333,7 +333,7 @@ func (e *executionManager) StopAndWait(ctx context.Context, id int64, timeout ti lock.Lock() overtime = true lock.Unlock() - return fmt.Errorf("stopping the execution %d timeout", id) + return ErrTimeOut case err := <-errChan: return err }