Skip to content

Commit

Permalink
feat(hatchery): release book in case of error (#6586)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlt committed Jul 11, 2023
1 parent 2e886d1 commit f1893ed
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sdk/hatchery/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ func spawnWorkerForJob(ctx context.Context, h Interface, j workerStarterRequest)
if err := h.CDSClient().WorkerModelSpawnError(j.model.Group.Name, j.model.Name, spawnError); err != nil {
log.Error(ctx, "error on call client.WorkerModelSpawnError on worker model %s for register: %s", j.model.Name, err)
}
if err := h.CDSClient().QueueJobRelease(ctx, j.id); err != nil {
log.ErrorWithStackTrace(ctx, sdk.WrapError(err, "cannot release job with id %d", j.id))
}
return false
}
arg.WorkerToken = jwt
Expand All @@ -222,6 +225,9 @@ func spawnWorkerForJob(ctx context.Context, h Interface, j workerStarterRequest)
Args: []interface{}{h.Service().Name, modelName, sdk.Round(time.Since(start), time.Second).String(), sdk.ExtractHTTPError(errSpawn).Error()},
})
log.ErrorWithStackTrace(ctx, sdk.WrapError(errSpawn, "hatchery %s cannot spawn worker %s for job %d", h.Service().Name, modelName, j.id))
if err := h.CDSClient().QueueJobRelease(ctx, j.id); err != nil {
log.ErrorWithStackTrace(ctx, sdk.WrapError(err, "cannot release job with id %d", j.id))
}
next()
return false
}
Expand Down

0 comments on commit f1893ed

Please sign in to comment.