jobqueue: allow canceling jobs
This is not exposed to a worker yet. It will continue the job and get an error when it tries to update the job's status to finished.
This commit is contained in:
parent
b795ca25a2
commit
27e8e4b5d5
5 changed files with 139 additions and 28 deletions
|
|
@ -79,14 +79,17 @@ func (s *Server) Enqueue(manifest *osbuild.Manifest, targets []*target.Target) (
|
|||
}
|
||||
|
||||
func (s *Server) JobStatus(id uuid.UUID) (state common.ComposeState, queued, started, finished time.Time, err error) {
|
||||
var canceled bool
|
||||
var result OSBuildJobResult
|
||||
|
||||
queued, started, finished, err = s.jobs.JobStatus(id, &result)
|
||||
queued, started, finished, canceled, err = s.jobs.JobStatus(id, &result)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if !finished.IsZero() {
|
||||
if canceled {
|
||||
state = common.CFailed
|
||||
} else if !finished.IsZero() {
|
||||
if result.OSBuildOutput.Success {
|
||||
state = common.CFinished
|
||||
} else {
|
||||
|
|
@ -102,15 +105,18 @@ func (s *Server) JobStatus(id uuid.UUID) (state common.ComposeState, queued, sta
|
|||
}
|
||||
|
||||
func (s *Server) JobResult(id uuid.UUID) (common.ComposeState, *common.ComposeResult, error) {
|
||||
var canceled bool
|
||||
var result OSBuildJobResult
|
||||
|
||||
_, started, finished, err := s.jobs.JobStatus(id, &result)
|
||||
_, started, finished, canceled, err := s.jobs.JobStatus(id, &result)
|
||||
if err != nil {
|
||||
return common.CWaiting, nil, err
|
||||
}
|
||||
|
||||
state := common.CWaiting
|
||||
if !finished.IsZero() {
|
||||
if canceled {
|
||||
state = common.CFailed
|
||||
} else if !finished.IsZero() {
|
||||
if result.OSBuildOutput.Success {
|
||||
state = common.CFinished
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue