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

Function isEligibleForFailedCleanup

coderd/autobuild/lifecycle_executor.go:678–688  ·  view source on GitHub ↗

isEligibleForFailedCleanup returns true if the workspace is eligible to be stopped due to a failed build. A failed start is cleaned up by stopping it, and a failed stop is retried by issuing another stop. In both cases the remediation is a stop build.

(build database.WorkspaceBuild, job database.ProvisionerJob, templateSchedule schedule.TemplateScheduleOptions, currentTick time.Time)

Source from the content-addressed store, hash-verified

676// and a failed stop is retried by issuing another stop. In both cases the
677// remediation is a stop build.
678func isEligibleForFailedCleanup(build database.WorkspaceBuild, job database.ProvisionerJob, templateSchedule schedule.TemplateScheduleOptions, currentTick time.Time) bool {
679 // If the template has specified a failure TTL.
680 return templateSchedule.FailureTTL > 0 &&
681 // And the job resulted in failure.
682 job.JobStatus == database.ProvisionerJobStatusFailed &&
683 (build.Transition == database.WorkspaceTransitionStart ||
684 build.Transition == database.WorkspaceTransitionStop) &&
685 // And sufficient time has elapsed since the job has completed.
686 job.CompletedAt.Valid &&
687 currentTick.Sub(job.CompletedAt.Time) > templateSchedule.FailureTTL
688}
689
690type auditParams struct {
691 Old database.WorkspaceTable

Callers 1

getNextTransitionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected