feat: allow bumping workspace deadline (#1828)

* Adds a `bump` command to extend workspace build deadline
 * Reduces WARN-level logging spam from autobuild executor
 * Modifies `cli/ssh` notifications to read from workspace build deadline and to notify relative time instead (sidestepping the problem of figuring out a user's timezone across multiple OSes)
 * Shows workspace extension time in `coder list` output e.g.
    ```
    WORKSPACE        TEMPLATE  STATUS   LAST BUILT  OUTDATED  AUTOSTART        TTL        
    developer/test1  docker    Running  4m          false     0 9 * * MON-FRI  15m (+5m)  
    ```
This commit is contained in:
Cian Johnston
2022-05-27 20:04:33 +01:00
committed by GitHub
parent bde3779fec
commit ff542afe87
8 changed files with 383 additions and 38 deletions
@@ -88,7 +88,7 @@ func (e *Executor) runOnce(t time.Time) error {
}
if !priorJob.CompletedAt.Valid || priorJob.Error.String != "" {
e.log.Warn(e.ctx, "last workspace build did not complete successfully, skipping",
e.log.Debug(e.ctx, "last workspace build did not complete successfully, skipping",
slog.F("workspace_id", ws.ID),
slog.F("error", priorJob.Error.String),
)
@@ -107,13 +107,14 @@ func (e *Executor) runOnce(t time.Time) error {
)
continue
}
// Truncate to nearest minute for consistency with autostart behavior
nextTransition = priorHistory.Deadline.Truncate(time.Minute)
// For stopping, do not truncate. This is inconsistent with autostart, but
// it ensures we will not stop too early.
nextTransition = priorHistory.Deadline
case database.WorkspaceTransitionStop:
validTransition = database.WorkspaceTransitionStart
sched, err := schedule.Weekly(ws.AutostartSchedule.String)
if err != nil {
e.log.Warn(e.ctx, "workspace has invalid autostart schedule, skipping",
e.log.Debug(e.ctx, "workspace has invalid autostart schedule, skipping",
slog.F("workspace_id", ws.ID),
slog.F("autostart_schedule", ws.AutostartSchedule.String),
)