MCPcopy Index your code
hub / github.com/coder/coder / Fail

Method Fail

provisionerd/runner/runner.go:269–289  ·  view source on GitHub ↗

Fail immediately halts updates and, if the job is not complete sends FailJob to the coder server. Running goroutines are canceled but complete asynchronously (although they are prevented from further updating the job to the coder server). The provided context sets how long to keep trying to send the

(ctx context.Context, f *proto.FailedJob)

Source from the content-addressed store, hash-verified

267// are canceled but complete asynchronously (although they are prevented from further updating the job to the coder
268// server). The provided context sets how long to keep trying to send the FailJob.
269func (r *Runner) Fail(ctx context.Context, f *proto.FailedJob) error {
270 f.JobId = r.job.JobId
271 r.mutex.Lock()
272 defer r.mutex.Unlock()
273 if !r.okToSend {
274 return nil // already done
275 }
276 r.Cancel()
277 if r.failedJob == nil {
278 r.failedJob = f
279 r.cond.Signal()
280 }
281 // here we keep the original failed reason if there already was one, but we hadn't yet sent it. It is likely more
282 // informative of the job failing due to some problem running it, whereas this function is used to externally
283 // force a Fail.
284 err := r.sender.FailJob(ctx, r.failedJob)
285 r.okToSend = false
286 r.stop()
287 close(r.done)
288 return err
289}
290
291// setComplete is an internal function to set the job to completed. This does not send the completedJob.
292func (r *Runner) setComplete(c *proto.CompletedJob) {

Callers 3

closeWithErrorMethod · 0.95
heartbeatRoutineMethod · 0.95

Calls 6

CancelMethod · 0.95
SignalMethod · 0.65
FailJobMethod · 0.65
stopMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by 1