@@ -175,7 +175,7 @@ func (e *Executor) runOnce(t time.Time) Stats {
175
175
}
176
176
}
177
177
178
- // Lock the workspace if it has breached the template's
178
+ // Transition the workspace to dormant if it has breached the template's
179
179
// threshold for inactivity.
180
180
if reason == database .BuildReasonAutolock {
181
181
ws , err = tx .UpdateWorkspaceDormantDeletingAt (e .ctx , database.UpdateWorkspaceDormantDeletingAtParams {
@@ -186,24 +186,24 @@ func (e *Executor) runOnce(t time.Time) Stats {
186
186
},
187
187
})
188
188
if err != nil {
189
- log .Error (e .ctx , "unable to lock workspace" ,
189
+ log .Error (e .ctx , "unable to transition workspace to dormant " ,
190
190
slog .F ("transition" , nextTransition ),
191
191
slog .Error (err ),
192
192
)
193
193
return nil
194
194
}
195
195
196
- log .Info (e .ctx , "locked workspace" ,
196
+ log .Info (e .ctx , "dormant workspace" ,
197
197
slog .F ("last_used_at" , ws .LastUsedAt ),
198
- slog .F ("inactivity_ttl " , templateSchedule .TimeTilDormant ),
198
+ slog .F ("time_til_dormant " , templateSchedule .TimeTilDormant ),
199
199
slog .F ("since_last_used_at" , time .Since (ws .LastUsedAt )),
200
200
)
201
201
}
202
202
203
203
if reason == database .BuildReasonAutodelete {
204
204
log .Info (e .ctx , "deleted workspace" ,
205
205
slog .F ("dormant_at" , ws .DormantAt .Time ),
206
- slog .F ("locked_ttl " , templateSchedule .TimeTilDormantAutoDelete ),
206
+ slog .F ("time_til_dormant_autodelete " , templateSchedule .TimeTilDormantAutoDelete ),
207
207
)
208
208
}
209
209
@@ -246,7 +246,7 @@ func (e *Executor) runOnce(t time.Time) Stats {
246
246
// for this function to return a nil error as well as an empty transition.
247
247
// In such cases it means no provisioning should occur but the workspace
248
248
// may be "transitioning" to a new state (such as an inactive, stopped
249
- // workspace transitioning to the locked state).
249
+ // workspace transitioning to the dormant state).
250
250
func getNextTransition (
251
251
ws database.Workspace ,
252
252
latestBuild database.WorkspaceBuild ,
@@ -265,13 +265,13 @@ func getNextTransition(
265
265
return database .WorkspaceTransitionStart , database .BuildReasonAutostart , nil
266
266
case isEligibleForFailedStop (latestBuild , latestJob , templateSchedule , currentTick ):
267
267
return database .WorkspaceTransitionStop , database .BuildReasonAutostop , nil
268
- case isEligibleForLockedStop (ws , templateSchedule , currentTick ):
268
+ case isEligibleForDormantStop (ws , templateSchedule , currentTick ):
269
269
// Only stop started workspaces.
270
270
if latestBuild .Transition == database .WorkspaceTransitionStart {
271
271
return database .WorkspaceTransitionStop , database .BuildReasonAutolock , nil
272
272
}
273
273
// We shouldn't transition the workspace but we should still
274
- // lock it.
274
+ // make it dormant .
275
275
return "" , database .BuildReasonAutolock , nil
276
276
277
277
case isEligibleForDelete (ws , templateSchedule , currentTick ):
@@ -288,7 +288,7 @@ func isEligibleForAutostart(ws database.Workspace, build database.WorkspaceBuild
288
288
return false
289
289
}
290
290
291
- // If the workspace is locked we should not autostart it.
291
+ // If the workspace is dormant we should not autostart it.
292
292
if ws .DormantAt .Valid {
293
293
return false
294
294
}
@@ -322,7 +322,7 @@ func isEligibleForAutostop(ws database.Workspace, build database.WorkspaceBuild,
322
322
return false
323
323
}
324
324
325
- // If the workspace is locked we should not autostop it.
325
+ // If the workspace is dormant we should not autostop it.
326
326
if ws .DormantAt .Valid {
327
327
return false
328
328
}
@@ -334,23 +334,23 @@ func isEligibleForAutostop(ws database.Workspace, build database.WorkspaceBuild,
334
334
! currentTick .Before (build .Deadline )
335
335
}
336
336
337
- // isEligibleForLockedStop returns true if the workspace should be locked
337
+ // isEligibleForDormantStop returns true if the workspace should be dormant
338
338
// for breaching the inactivity threshold of the template.
339
- func isEligibleForLockedStop (ws database.Workspace , templateSchedule schedule.TemplateScheduleOptions , currentTick time.Time ) bool {
340
- // Only attempt to lock workspaces not already locked .
339
+ func isEligibleForDormantStop (ws database.Workspace , templateSchedule schedule.TemplateScheduleOptions , currentTick time.Time ) bool {
340
+ // Only attempt against workspaces not already dormant .
341
341
return ! ws .DormantAt .Valid &&
342
- // The template must specify an inactivity TTL .
342
+ // The template must specify an time_til_dormant value .
343
343
templateSchedule .TimeTilDormant > 0 &&
344
- // The workspace must breach the inactivity TTL .
344
+ // The workspace must breach the time_til_dormant value .
345
345
currentTick .Sub (ws .LastUsedAt ) > templateSchedule .TimeTilDormant
346
346
}
347
347
348
348
func isEligibleForDelete (ws database.Workspace , templateSchedule schedule.TemplateScheduleOptions , currentTick time.Time ) bool {
349
- // Only attempt to delete locked workspaces.
349
+ // Only attempt to delete dormant workspaces.
350
350
return ws .DormantAt .Valid && ws .DeletingAt .Valid &&
351
- // Locked workspaces should only be deleted if a locked_ttl is specified.
351
+ // Dormant workspaces should only be deleted if a time_til_dormant_autodelete value is specified.
352
352
templateSchedule .TimeTilDormantAutoDelete > 0 &&
353
- // The workspace must breach the locked_ttl .
353
+ // The workspace must breach the time_til_dormant_autodelete value .
354
354
currentTick .After (ws .DeletingAt .Time )
355
355
}
356
356
0 commit comments