internal/worker/server: return an error on depsolve timeout HMS-2989

Fixes the special case that if no worker is available and we
generate an internal timeout and cancel the depsolve including all
followup jobs, no error was propagated.
This commit is contained in:
Florian Schüller 2024-10-03 19:07:50 +02:00 committed by Sanne Raymaekers
parent 03e74e77b2
commit d3e3474fb7
7 changed files with 208 additions and 31 deletions

View file

@ -566,6 +566,20 @@ func (s *Server) Cancel(id uuid.UUID) error {
return s.jobs.CancelJob(id)
}
// SetFailed sets the given job id to "failed" with the given error
func (s *Server) SetFailed(id uuid.UUID, error *clienterrors.Error) error {
FailedJobErrorResult := JobResult{
JobError: error,
}
res, err := json.Marshal(FailedJobErrorResult)
if err != nil {
logrus.Errorf("error marshalling the error: %v", err)
return nil
}
return s.jobs.FailJob(id, res)
}
// Provides access to artifacts of a job. Returns an io.Reader for the artifact
// and the artifact's size.
func (s *Server) JobArtifact(id uuid.UUID, name string) (io.Reader, int64, error) {