Allow jobs to be submitted in paused
status
#104322
@ -91,8 +91,12 @@ func (f *Flamenco) SubmitJob(e echo.Context) error {
|
|||||||
|
|
||||||
logger = logger.With().Str("job_id", authoredJob.JobID).Logger()
|
logger = logger.With().Str("job_id", authoredJob.JobID).Logger()
|
||||||
|
|
||||||
// TODO: check whether this job should be queued immediately or start paused.
|
submittedJob := api.SubmittedJob(job)
|
||||||
authoredJob.Status = api.JobStatusQueued
|
initialStatus := api.JobStatusQueued
|
||||||
David-Zhang-10 marked this conversation as resolved
Outdated
|
|||||||
|
if submittedJob.InitialStatus != nil {
|
||||||
|
initialStatus = *submittedJob.InitialStatus
|
||||||
|
}
|
||||||
David-Zhang-10 marked this conversation as resolved
Outdated
Sybren A. Stüvel
commented
This will cause a job with
If you want to do more validation you could, but I don't think it's necessary. In that case, a global variable declared at the top could help:
This will cause a job with `initialStatus: "failed"` to be accepted, and silently its initial status will be overwritten. I don't this is a good approach. I think this is sufficient:
```go
initialStatus := api.JobStatusQueued
if (submittedJob.InitialStatus != nil) {
initialStatus = *submittedJob.InitialStatus
}
authoredJob.Status = initialStatus
```
If you want to do more validation you could, but I don't think it's necessary. In that case, a global variable declared at the top could help:
```go
var validInitialJobStatuses = map[api.JobStatus]bool{
api.JobStatusQueued: true,
api.JobStatusPaused: true,
}
// ...
if !validInitialJobStatuses[initialStatus] {
// .. reject submitted job with appropriate HTTP error status code
}
```
|
|||||||
|
authoredJob.Status = initialStatus
|
||||||
|
|
||||||
if err := f.persist.StoreAuthoredJob(ctx, *authoredJob); err != nil {
|
if err := f.persist.StoreAuthoredJob(ctx, *authoredJob); err != nil {
|
||||||
logger.Error().Err(err).Msg("error persisting job in database")
|
logger.Error().Err(err).Msg("error persisting job in database")
|
||||||
|
Loading…
Reference in New Issue
Block a user
If
submittedJob.InitialStatus
isnil
, dereferencing the pointer will cause a panic.