Thanks to visit codestin.com
Credit goes to github.com

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

+19
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

+4-1
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)