@@ -45,6 +45,7 @@ import {
45
45
Workspace ,
46
46
FindPrebuildsParams ,
47
47
TeamMemberRole ,
48
+ WORKSPACE_TIMEOUT_DEFAULT_SHORT ,
48
49
} from "@gitpod/gitpod-protocol" ;
49
50
import { ResponseError } from "vscode-jsonrpc" ;
50
51
import {
@@ -77,7 +78,7 @@ import {
77
78
import { Plans } from "@gitpod/gitpod-protocol/lib/plans" ;
78
79
import * as pThrottle from "p-throttle" ;
79
80
import { formatDate } from "@gitpod/gitpod-protocol/lib/util/date-time" ;
80
- import { FindUserByIdentityStrResult } from "../../../src/user/user-service" ;
81
+ import { FindUserByIdentityStrResult , UserService } from "../../../src/user/user-service" ;
81
82
import {
82
83
Accounting ,
83
84
AccountService ,
@@ -133,6 +134,8 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
133
134
134
135
@inject ( UserCounter ) protected readonly userCounter : UserCounter ;
135
136
137
+ @inject ( UserService ) protected readonly userService : UserService ;
138
+
136
139
initialize (
137
140
client : GitpodClient | undefined ,
138
141
user : User | undefined ,
@@ -312,15 +315,15 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
312
315
instancesWithReset . map ( ( i ) => {
313
316
const req = new SetTimeoutRequest ( ) ;
314
317
req . setId ( i . id ) ;
315
- req . setDuration ( defaultTimeout ) ;
318
+ req . setDuration ( this . userService . workspaceTimeoutToDuration ( defaultTimeout ) ) ;
316
319
317
320
return client . setTimeout ( ctx , req ) ;
318
321
} ) ,
319
322
) ;
320
323
321
324
const req = new SetTimeoutRequest ( ) ;
322
325
req . setId ( runningInstance . id ) ;
323
- req . setDuration ( duration ) ;
326
+ req . setDuration ( this . userService . workspaceTimeoutToDuration ( duration ) ) ;
324
327
await client . setTimeout ( ctx , req ) ;
325
328
326
329
return {
@@ -343,7 +346,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
343
346
const runningInstance = await this . workspaceDb . trace ( ctx ) . findRunningInstance ( workspaceId ) ;
344
347
if ( ! runningInstance ) {
345
348
log . warn ( { userId : user . id , workspaceId } , "Can only get keep-alive for running workspaces" ) ;
346
- return { duration : "30m" , canChange } ;
349
+ return { duration : WORKSPACE_TIMEOUT_DEFAULT_SHORT , canChange } ;
347
350
}
348
351
await this . guardAccess ( { kind : "workspaceInstance" , subject : runningInstance , workspace : workspace } , "get" ) ;
349
352
@@ -352,7 +355,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
352
355
353
356
const client = await this . workspaceManagerClientProvider . get ( runningInstance . region ) ;
354
357
const desc = await client . describeWorkspace ( ctx , req ) ;
355
- const duration = desc . getStatus ( ) ! . getSpec ( ) ! . getTimeout ( ) as WorkspaceTimeoutDuration ;
358
+ const duration = this . userService . durationToWorkspaceTimeout ( desc . getStatus ( ) ! . getSpec ( ) ! . getTimeout ( ) ) ;
356
359
return { duration, canChange } ;
357
360
}
358
361
0 commit comments