Skip to content

Commit 4fc8b45

Browse files
committed
chore: some tiny error
1 parent ac7feac commit 4fc8b45

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

vermeer/apps/master/bl/scheduler_bl.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package bl
1919

2020
import (
2121
"errors"
22+
"fmt"
2223
"strconv"
2324
"time"
2425
"vermeer/apps/common"
@@ -201,7 +202,9 @@ func (s *ScheduleBl) tryScheduleInner(softSchedule bool, noLock ...bool) error {
201202
case s.startChan <- task:
202203
logrus.Infof("task '%d' sent to start channel", task.ID)
203204
default:
204-
logrus.Warnf("start channel is full, task '%d' could not be sent", task.ID)
205+
errMsg := fmt.Sprintf("start channel is full, cannot schedule task %d", task.ID)
206+
logrus.Errorf(errMsg)
207+
taskMgr.SetError(task, errMsg)
205208
}
206209
}
207210

@@ -368,7 +371,7 @@ func (s *ScheduleBl) ChangeWorkerStatus(workerName string, status schedules.Work
368371
func (s *ScheduleBl) waitingStartedTask() {
369372
for taskInfo := range s.startChan {
370373
if taskInfo == nil {
371-
logrus.Warnf("recieved a nil task from startChan")
374+
logrus.Warnf("received a nil task from startChan")
372375
continue
373376
}
374377

vermeer/apps/master/bl/task_bl.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package bl
2020
import (
2121
"errors"
2222
"fmt"
23+
"math"
2324
"sort"
2425
"strconv"
2526
"strings"
@@ -74,6 +75,9 @@ func (tb *TaskBl) CreateTaskInfo(
7475
if p < 0 {
7576
return nil, fmt.Errorf("priority should be non-negative")
7677
}
78+
if p > math.MaxInt32 {
79+
return nil, fmt.Errorf("priority exceeds maximum value: %d", math.MaxInt32)
80+
}
7781
taskInfo.Priority = int32(p)
7882
} else {
7983
logrus.Warnf("priority convert to int32 error:%v", err)
@@ -85,7 +89,7 @@ func (tb *TaskBl) CreateTaskInfo(
8589
for _, preorder := range preorderList {
8690
if pid, err := strconv.ParseInt(preorder, 10, 32); err == nil {
8791
if taskMgr.GetTaskByID(int32(pid)) == nil {
88-
return nil, fmt.Errorf("preorder task id %d not exists", pid)
92+
return nil, fmt.Errorf("preorder task with ID %d does not exist", pid)
8993
}
9094
taskInfo.Preorders = append(taskInfo.Preorders, int32(pid))
9195
} else {

vermeer/apps/master/schedules/scheduler_task_manager.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package schedules
22

33
import (
44
"errors"
5+
"vermeer/apps/common"
56
"vermeer/apps/structure"
67

78
"github.com/sirupsen/logrus"
@@ -86,6 +87,10 @@ func (t *SchedulerTaskManager) RefreshTaskToWorkerGroupMap() {
8687
* @Return error
8788
*/
8889
func (t *SchedulerTaskManager) AddTaskStartSequence(taskID int32) error {
90+
if common.GetConfig("debug_mode").(string) != "debug" {
91+
logrus.Warn("TaskStartSequence called but debug features are disabled")
92+
return nil
93+
}
8994
if _, exists := t.allTaskMap[taskID]; !exists {
9095
return errors.New("task not found")
9196
}
@@ -202,7 +207,7 @@ func (t *SchedulerTaskManager) GetAllTasksNotComplete() []*structure.TaskInfo {
202207
return tasks
203208
}
204209

205-
func (t *SchedulerTaskManager) GetAllTasksWaitng() []*structure.TaskInfo {
210+
func (t *SchedulerTaskManager) GetAllTasksWaiting() []*structure.TaskInfo {
206211
tasks := make([]*structure.TaskInfo, 0, len(t.allTaskMap))
207212
for _, task := range t.GetAllTasksNotComplete() {
208213
if task.State == structure.TaskStateWaiting {

0 commit comments

Comments
 (0)