mirror of
https://github.com/coder/coder.git
synced 2025-07-18 14:17:22 +00:00
feat: allow removing deadline for running workspace (#16085)
Fixes https://github.com/coder/coder/issues/9775 When a workspace's TTL is removed, and the workspace is running, the deadline is removed from the workspace. This also modifies the frontend to not show a confirmation dialog when the change is to remove autostop.
This commit is contained in:
@ -1029,6 +1029,26 @@ func (api *API) putWorkspaceTTL(rw http.ResponseWriter, r *http.Request) {
|
||||
return xerrors.Errorf("update workspace time until shutdown: %w", err)
|
||||
}
|
||||
|
||||
// If autostop has been disabled, we want to remove the deadline from the
|
||||
// existing workspace build (if there is one).
|
||||
if !dbTTL.Valid {
|
||||
build, err := s.GetLatestWorkspaceBuildByWorkspaceID(ctx, workspace.ID)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("get latest workspace build: %w", err)
|
||||
}
|
||||
|
||||
if build.Transition == database.WorkspaceTransitionStart {
|
||||
if err = s.UpdateWorkspaceBuildDeadlineByID(ctx, database.UpdateWorkspaceBuildDeadlineByIDParams{
|
||||
ID: build.ID,
|
||||
Deadline: time.Time{},
|
||||
MaxDeadline: build.MaxDeadline,
|
||||
UpdatedAt: dbtime.Time(api.Clock.Now()),
|
||||
}); err != nil {
|
||||
return xerrors.Errorf("update workspace build deadline: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}, nil)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user