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

Function isEligibleForAutostop

coderd/autobuild/lifecycle_executor.go:625–644  ·  view source on GitHub ↗

isEligibleForAutostop returns true if the workspace should be autostopped.

(user database.User, ws database.Workspace, build database.WorkspaceBuild, job database.ProvisionerJob, currentTick time.Time)

Source from the content-addressed store, hash-verified

623
624// isEligibleForAutostop returns true if the workspace should be autostopped.
625func isEligibleForAutostop(user database.User, ws database.Workspace, build database.WorkspaceBuild, job database.ProvisionerJob, currentTick time.Time) bool {
626 if job.JobStatus == database.ProvisionerJobStatusFailed {
627 return false
628 }
629
630 // If the workspace is dormant we should not autostop it.
631 if ws.DormantAt.Valid {
632 return false
633 }
634
635 if build.Transition == database.WorkspaceTransitionStart && user.Status == database.UserStatusSuspended {
636 return true
637 }
638
639 // A workspace must be started in order for it to be auto-stopped.
640 return build.Transition == database.WorkspaceTransitionStart &&
641 !build.Deadline.IsZero() &&
642 // We do not want to stop a workspace prior to it breaching its deadline.
643 !currentTick.Before(build.Deadline)
644}
645
646// isEligibleForDormantStop returns true if the workspace should be dormant
647// for breaching the inactivity threshold of the template.

Callers 1

getNextTransitionFunction · 0.85

Calls 1

IsZeroMethod · 0.45

Tested by

no test coverage detected