Fix /api/jobs/start_job duplicate check

This commit is contained in:
Lou Knauer 2022-03-21 13:04:57 +01:00
parent 954d59a093
commit 220758dae1

View File

@ -285,13 +285,10 @@ func (api *RestApi) startJob(rw http.ResponseWriter, r *http.Request) {
// Check if combination of (job_id, cluster_id, start_time) already exists: // Check if combination of (job_id, cluster_id, start_time) already exists:
job, err := api.JobRepository.Find(&req.JobID, &req.Cluster, nil) job, err := api.JobRepository.Find(&req.JobID, &req.Cluster, nil)
if err != nil && err != sql.ErrNoRows {
if err != nil {
handleError(fmt.Errorf("checking for duplicate failed: %w", err), http.StatusInternalServerError, rw) handleError(fmt.Errorf("checking for duplicate failed: %w", err), http.StatusInternalServerError, rw)
return return
} } else if err == nil {
if err != sql.ErrNoRows {
if (req.StartTime - job.StartTimeUnix) < 86400 { if (req.StartTime - job.StartTimeUnix) < 86400 {
handleError(fmt.Errorf("a job with that jobId, cluster and startTime already exists: dbid: %d", job.ID), http.StatusUnprocessableEntity, rw) handleError(fmt.Errorf("a job with that jobId, cluster and startTime already exists: dbid: %d", job.ID), http.StatusUnprocessableEntity, rw)
return return