Return 200 when to post an none schedule

1, Throw the error of job service to UI when to create job schedule.
2, Return 200 when to save none without schedule.

Fixed #7675

Signed-off-by: wang yan <wangyan@vmware.com>
This commit is contained in:
wang yan 2019-05-08 15:22:20 +08:00
parent cbbf2ea973
commit 5c12c7713d

View File

@ -219,6 +219,11 @@ func (aj *AJAPI) getLog(id int64) {
// submit submits a job to job service per request // submit submits a job to job service per request
func (aj *AJAPI) submit(ajr *models.AdminJobReq) { func (aj *AJAPI) submit(ajr *models.AdminJobReq) {
// when the schedule is saved as None without any schedule, just return 200 and do nothing.
if ajr.Schedule.Type == models.ScheduleNone {
return
}
// cannot post multiple schedule for admin job. // cannot post multiple schedule for admin job.
if ajr.IsPeriodic() { if ajr.IsPeriodic() {
jobs, err := dao.GetAdminJobs(&common_models.AdminJobQuery{ jobs, err := dao.GetAdminJobs(&common_models.AdminJobQuery{
@ -254,11 +259,7 @@ func (aj *AJAPI) submit(ajr *models.AdminJobReq) {
if err := dao.DeleteAdminJob(id); err != nil { if err := dao.DeleteAdminJob(id); err != nil {
log.Debugf("Failed to delete admin job, err: %v", err) log.Debugf("Failed to delete admin job, err: %v", err)
} }
if httpErr, ok := err.(*common_http.Error); ok && httpErr.Code == http.StatusConflict { aj.ParseAndHandleError("failed to submit admin job", err)
aj.SendConflictError(fmt.Errorf("conflict when triggering %s, please try again later", ajr.Name))
return
}
aj.SendInternalServerError(err)
return return
} }
if err := dao.SetAdminJobUUID(id, uuid); err != nil { if err := dao.SetAdminJobUUID(id, uuid); err != nil {