mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-26 05:19:05 +01:00
Reject jobs if start time is within 24h
This commit is contained in:
parent
728e119a0b
commit
0206303d98
@ -284,16 +284,19 @@ func (api *RestApi) startJob(rw http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// Check if combination of (job_id, cluster_id, start_time) already exists:
|
||||
job, err := api.JobRepository.Find(&req.JobID, &req.Cluster, &req.StartTime)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
job, err := api.JobRepository.Find(&req.JobID, &req.Cluster, nil)
|
||||
|
||||
if err != nil {
|
||||
handleError(fmt.Errorf("checking for duplicate failed: %w", err), http.StatusInternalServerError, rw)
|
||||
return
|
||||
}
|
||||
|
||||
if err != sql.ErrNoRows {
|
||||
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)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
id, err := api.JobRepository.Start(&req)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user