mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-19 23:28:20 +01:00
Merge pull request #7736 from wy65701436/fix-7675
Return 200 when to post an none schedule
This commit is contained in:
commit
8e9b9f8942
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user