fix: Check for job status on another incoming (#1117)

If a job silently failed, it wasn't possible for another one
to execute. This fixes it by using the API status to return
active state.
This commit is contained in:
Kyle Carberry
2022-04-24 21:22:36 -05:00
committed by GitHub
parent db7ed4d019
commit 23295f7f07
3 changed files with 12 additions and 3 deletions

View File

@ -166,7 +166,7 @@ func (api *api) postWorkspaceBuilds(rw http.ResponseWriter, r *http.Request) {
priorHistory, err := api.Database.GetWorkspaceBuildByWorkspaceIDWithoutAfter(r.Context(), workspace.ID)
if err == nil {
priorJob, err := api.Database.GetProvisionerJobByID(r.Context(), priorHistory.JobID)
if err == nil && !priorJob.CompletedAt.Valid {
if err == nil && convertProvisionerJob(priorJob).Status.Active() {
httpapi.Write(rw, http.StatusConflict, httpapi.Response{
Message: "a workspace build is already active",
})