Skip to content

Commit 18e9550

Browse files
chore: comment query
1 parent 190617c commit 18e9550

File tree

2 files changed

+52
-12
lines changed

2 files changed

+52
-12
lines changed

coderd/database/queries.sql.go

Lines changed: 26 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/workspaces.sql

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,11 @@ WHERE
580580
) AND
581581

582582
(
583-
-- isEligibleForAutostop
583+
-- A workspace may be eligible for autostop if the following are true:
584+
-- * The provisioner job has not failed.
585+
-- * The workspace is not dormant.
586+
-- * The workspace build was a start transition.
587+
-- * The workspace's owner is suspended OR the workspace build deadline has passed.
584588
(
585589
provisioner_jobs.job_status != 'failed'::provisioner_job_status AND
586590
workspaces.dormant_at IS NULL AND
@@ -592,22 +596,33 @@ WHERE
592596
)
593597
) OR
594598

595-
-- isEligibleForAutostart
599+
-- A workspace may be eligible for autostart if the following are true:
600+
-- * The workspace's owner is active.
601+
-- * The provisioner job did not failed.
602+
-- * The workspace build was a stop transition.
603+
-- * The workspace has an autostart schedule.
596604
(
597605
users.status = 'active'::user_status AND
598606
provisioner_jobs.job_status != 'failed'::provisioner_job_status AND
599607
workspace_builds.transition = 'stop'::workspace_transition AND
600608
workspaces.autostart_schedule IS NOT NULL
601609
) OR
602610

603-
-- isEligibleForDormantStop
611+
-- A workspace may be eligible for dormant stop if the following are true:
612+
-- * The workspace is not dormant.
613+
-- * The template has set a time til dormant.
614+
-- * The workspace has been unused for longer than the time til dormancy.
604615
(
605616
workspaces.dormant_at IS NULL AND
606617
templates.time_til_dormant > 0 AND
607618
(@now :: timestamptz) - workspaces.last_used_at > (INTERVAL '1 millisecond' * (templates.time_til_dormant / 1000000))
608619
) OR
609620

610-
-- isEligibleForDelete
621+
-- A workspace may be eligible for deletion if the following are true:
622+
-- * The workspace is dormant.
623+
-- * The workspace is scheduled to be deleted.
624+
-- * If there was a prior attempt to delete the workspace that failed:
625+
-- * This attempt was at least 24 hours ago>
611626
(
612627
workspaces.dormant_at IS NOT NULL AND
613628
workspaces.deleting_at IS NOT NULL AND
@@ -632,11 +647,16 @@ WHERE
632647
END
633648
) OR
634649

635-
-- isEligibleForFailedStop
650+
-- A workspace may be eligible for failed stop if the following are true:
651+
-- * The template has a failure ttl set.
652+
-- * The workspace build was a start transition.
653+
-- * The provisioner job failed.
654+
-- * The provisioner job had completed.
655+
-- * The provisioner job has been completed for longer than the failure ttl.
636656
(
637657
templates.failure_ttl > 0 AND
638-
provisioner_jobs.job_status = 'failed'::provisioner_job_status AND
639658
workspace_builds.transition = 'start'::workspace_transition AND
659+
provisioner_jobs.job_status = 'failed'::provisioner_job_status AND
640660
provisioner_jobs.completed_at IS NOT NULL AND
641661
(@now :: timestamptz) - provisioner_jobs.completed_at > (INTERVAL '1 millisecond' * (templates.failure_ttl / 1000000))
642662
)

0 commit comments

Comments
 (0)