1
0
mirror of https://github.com/newnius/YAO-scheduler.git synced 2025-06-07 14:21:55 +00:00

bugfix, validate submited jobs; avoid divide by zero error when update quota in fair scheduler

This commit is contained in:
Newnius 2020-07-11 00:08:52 +08:00
parent e67a81198e
commit ee34e09f7f
2 changed files with 14 additions and 1 deletions

View File

@ -54,10 +54,19 @@ func serverAPI(w http.ResponseWriter, r *http.Request) {
log.Debug("job_submit") log.Debug("job_submit")
msgSubmit := MsgSubmit{Code: 0} msgSubmit := MsgSubmit{Code: 0}
err := json.Unmarshal([]byte(string(r.PostFormValue("job"))), &job) err := json.Unmarshal([]byte(string(r.PostFormValue("job"))), &job)
log.Info("Submit job ", job.Name, " at ", time.Now())
if err != nil { if err != nil {
msgSubmit.Code = 1 msgSubmit.Code = 1
msgSubmit.Error = err.Error() 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 { } else {
job.Name = job.Name + "-" job.Name = job.Name + "-"
job.Name += strconv.FormatInt(time.Now().UnixNano(), 10) job.Name += strconv.FormatInt(time.Now().UnixNano(), 10)

View File

@ -558,6 +558,10 @@ func (scheduler *SchedulerFair) UpdateQuota() {
} }
sort.Sort(sort.Reverse(scheduler.queues[queue])) 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 { if quota, ok := scheduler.queuesQuota[queue]; ok && quota.NumberGPU >= request.NumberGPU*1000 {
continue continue
} }