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

Method doCleanFinish

provisionerd/runner/runner.go:379–420  ·  view source on GitHub ↗

doCleanFinish wraps a call to do() with cleaning up the job and setting the terminal messages

(ctx context.Context)

Source from the content-addressed store, hash-verified

377
378// doCleanFinish wraps a call to do() with cleaning up the job and setting the terminal messages
379func (r *Runner) doCleanFinish(ctx context.Context) {
380 var (
381 failedJob *proto.FailedJob
382 completedJob *proto.CompletedJob
383 )
384
385 // push the fail/succeed write onto the defer stack before the cleanup, so
386 // that cleanup happens before this.
387 defer func() {
388 _, span := r.startTrace(ctx, tracing.FuncName())
389 defer span.End()
390
391 if failedJob != nil {
392 r.setFail(failedJob)
393 return
394 }
395 r.setComplete(completedJob)
396 }()
397
398 var err error
399 r.session, err = r.provisioner.Session(ctx)
400 if err != nil {
401 failedJob = r.failedJobf("open session: %s", err)
402 return
403 }
404 defer r.session.Close()
405
406 defer func() {
407 ctx, span := r.startTrace(ctx, tracing.FuncName())
408 defer span.End()
409
410 r.queueLog(ctx, &proto.Log{
411 Source: proto.LogSource_PROVISIONER_DAEMON,
412 Level: sdkproto.LogLevel_INFO,
413 Stage: "Cleaning Up",
414 CreatedAt: time.Now().UnixMilli(),
415 })
416 r.flushQueuedLogs(ctx)
417 }()
418
419 completedJob, failedJob = r.do(ctx)
420}
421
422// do actually does the work of running the job
423func (r *Runner) do(ctx context.Context) (*proto.CompletedJob, *proto.FailedJob) {

Callers 1

RunMethod · 0.95

Calls 10

startTraceMethod · 0.95
setFailMethod · 0.95
setCompleteMethod · 0.95
failedJobfMethod · 0.95
queueLogMethod · 0.95
flushQueuedLogsMethod · 0.95
doMethod · 0.95
FuncNameFunction · 0.92
SessionMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected