@@ -142,6 +142,28 @@ func (m *Manager) SetTimeout(ctx context.Context, req *api.SetTimeoutRequest) (r
142
142
return & api.SetTimeoutResponse {}, nil
143
143
}
144
144
145
+ // SetClosedTimeout changes the default closed timeout for a running workspace
146
+ func (m * Manager ) SetClosedTimeout (ctx context.Context , req * api.SetClosedTimeoutRequest ) (res * api.SetClosedTimeoutResponse , err error ) {
147
+ //nolint:ineffassign
148
+ span , ctx := tracing .FromContext (ctx , "SetClosedTimeout" )
149
+ tracing .ApplyOWI (span , log .OWI ("" , "" , req .Id ))
150
+ defer tracing .FinishSpan (span , & err )
151
+
152
+ if req .Duration != "-1" {
153
+ _ , err = time .ParseDuration (req .Duration )
154
+ if err != nil {
155
+ return nil , xerrors .Errorf ("invalid duration \" %s\" : %w" , req .Duration , err )
156
+ }
157
+ }
158
+
159
+ err = m .markWorkspace (ctx , req .Id , addMark (customClosedTimeoutAnnotation , req .Duration ))
160
+ if err != nil {
161
+ return nil , xerrors .Errorf ("cannot set workspace closed timeout: %w" , err )
162
+ }
163
+
164
+ return & api.SetClosedTimeoutResponse {}, nil
165
+ }
166
+
145
167
// BackupWorkspace attempts to create a backup of the workspace, ignoring its perceived current status as much as it can
146
168
func (m * Manager ) BackupWorkspace (ctx context.Context , req * api.BackupWorkspaceRequest ) (res * api.BackupWorkspaceResponse , err error ) {
147
169
span , ctx := tracing .FromContext (ctx , "BackupWorkspace" )
0 commit comments