mirror of
https://github.com/newnius/YAO-scheduler.git
synced 2025-06-06 05:51:54 +00:00
bugfix, validate submited jobs; avoid divide by zero error when update quota in fair scheduler
This commit is contained in:
parent
e67a81198e
commit
ee34e09f7f
11
src/main.go
11
src/main.go
@ -54,10 +54,19 @@ func serverAPI(w http.ResponseWriter, r *http.Request) {
|
||||
log.Debug("job_submit")
|
||||
msgSubmit := MsgSubmit{Code: 0}
|
||||
err := json.Unmarshal([]byte(string(r.PostFormValue("job"))), &job)
|
||||
log.Info("Submit job ", job.Name, " at ", time.Now())
|
||||
|
||||
if err != nil {
|
||||
msgSubmit.Code = 1
|
||||
msgSubmit.Error = err.Error()
|
||||
} else if len(job.Tasks) == 0 {
|
||||
msgSubmit.Code = 2
|
||||
msgSubmit.Error = "task not found in the job"
|
||||
} else if InstanceOfGroupManager().get(job.Group) == nil {
|
||||
msgSubmit.Code = 2
|
||||
msgSubmit.Error = "Queue not found"
|
||||
} else if len(job.Workspace) == 0 {
|
||||
msgSubmit.Code = 2
|
||||
msgSubmit.Error = "Docker image cannot be empty"
|
||||
} else {
|
||||
job.Name = job.Name + "-"
|
||||
job.Name += strconv.FormatInt(time.Now().UnixNano(), 10)
|
||||
|
@ -558,6 +558,10 @@ func (scheduler *SchedulerFair) UpdateQuota() {
|
||||
}
|
||||
sort.Sort(sort.Reverse(scheduler.queues[queue]))
|
||||
|
||||
/* minimum is 1, to avoid divide by zero error following */
|
||||
if request.NumberGPU == 0 {
|
||||
request.NumberGPU = 1
|
||||
}
|
||||
if quota, ok := scheduler.queuesQuota[queue]; ok && quota.NumberGPU >= request.NumberGPU*1000 {
|
||||
continue
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user