Skip to content

Commit 14167c4

Browse files
chore: remove deadline from running workspaces on ttl change
1 parent fc7a7df commit 14167c4

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

coderd/workspaces.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,25 @@ func (api *API) putWorkspaceTTL(rw http.ResponseWriter, r *http.Request) {
10291029
return xerrors.Errorf("update workspace time until shutdown: %w", err)
10301030
}
10311031

1032+
// If autostop has been disabled, we want to remove the deadline from the
1033+
// existing workspace build (if there is one).
1034+
if !dbTTL.Valid {
1035+
build, err := s.GetLatestWorkspaceBuildByWorkspaceID(ctx, workspace.ID)
1036+
if err != nil {
1037+
return xerrors.Errorf("get latest workspace build: %w", err)
1038+
}
1039+
1040+
if build.Transition == database.WorkspaceTransitionStart {
1041+
if err = s.UpdateWorkspaceBuildDeadlineByID(ctx, database.UpdateWorkspaceBuildDeadlineByIDParams{
1042+
ID: build.ID,
1043+
Deadline: time.Time{},
1044+
MaxDeadline: build.MaxDeadline,
1045+
}); err != nil {
1046+
return xerrors.Errorf("update workspace build deadline: %w", err)
1047+
}
1048+
}
1049+
}
1050+
10321051
return nil
10331052
}, nil)
10341053
if err != nil {

site/src/pages/WorkspaceSettingsPage/WorkspaceSchedulePage/WorkspaceSchedulePage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ export const WorkspaceSchedulePage: FC = () => {
118118

119119
await submitScheduleMutation.mutateAsync(data);
120120

121-
if (data.autostopChanged) {
121+
if (
122+
data.autostopChanged &&
123+
getAutostop(workspace).autostopEnabled
124+
) {
122125
setIsConfirmingApply(true);
123126
}
124127
}}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy