@@ -50,9 +50,18 @@ func (e *Executor) Run() {
50
50
func (e * Executor )runOnce (t time.Time )error {
51
51
currentTick := t .Truncate (time .Minute )
52
52
return e .db .InTx (func (db database.Store )error {
53
- // XXX: if a workspace build is created when ttl != null and then ttl is unset,
54
- // autostop will still happen for this workspace build. Whether this is
55
- // expected behavior from a user's perspective is not yet known.
53
+ // TTL is set at the workspace level, and deadline at the workspace build level.
54
+ // When a workspace build is created, its deadline initially starts at zero.
55
+ // When provisionerd successfully completes a provision job, the deadline is
56
+ // set to now + TTL if the associated workspace has a TTL set. This deadline
57
+ // is what we compare against when performing autostop operations, rounded down
58
+ // to the minute.
59
+ //
60
+ // NOTE: Currently, if a workspace build is created with a given TTL and then
61
+ // the user either changes or unsets the TTL, the deadline for the workspace
62
+ // build will not have changed. So, autostop will still happen at the
63
+ // original TTL value from when the workspace build was created.
64
+ // Whether this is expected behavior from a user's perspective is not yet known.
56
65
eligibleWorkspaces ,err := db .GetWorkspacesAutostart (e .ctx )
57
66
if err != nil {
58
67
return xerrors .Errorf ("get eligible workspaces for autostart or autostop: %w" ,err )