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

Function isEligibleForDelete

coderd/autobuild/lifecycle_executor.go:657–672  ·  view source on GitHub ↗
(ws database.Workspace, templateSchedule schedule.TemplateScheduleOptions, lastBuild database.WorkspaceBuild, lastJob database.ProvisionerJob, currentTick time.Time)

Source from the content-addressed store, hash-verified

655}
656
657func isEligibleForDelete(ws database.Workspace, templateSchedule schedule.TemplateScheduleOptions, lastBuild database.WorkspaceBuild, lastJob database.ProvisionerJob, currentTick time.Time) bool {
658 eligible := ws.DormantAt.Valid && ws.DeletingAt.Valid &&
659 // Dormant workspaces should only be deleted if a time_til_dormant_autodelete value is specified.
660 templateSchedule.TimeTilDormantAutoDelete > 0 &&
661 // The workspace must breach the time_til_dormant_autodelete value.
662 currentTick.After(ws.DeletingAt.Time)
663
664 // If the last delete job failed we should wait 24 hours before trying again.
665 // Builds are resource-intensive so retrying every minute is not productive
666 // and will hold compute hostage.
667 if lastBuild.Transition == database.WorkspaceTransitionDelete && lastJob.JobStatus == database.ProvisionerJobStatusFailed {
668 return eligible && lastJob.Finished() && currentTick.Sub(lastJob.FinishedAt()) > time.Hour*24
669 }
670
671 return eligible
672}
673
674// isEligibleForFailedCleanup returns true if the workspace is eligible to be
675// stopped due to a failed build. A failed start is cleaned up by stopping it,

Callers 1

getNextTransitionFunction · 0.85

Calls 2

FinishedMethod · 0.80
FinishedAtMethod · 0.80

Tested by

no test coverage detected