Skip to content

Commit

Permalink
Add a 24-hour timeout limit to workspace timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptronicek committed Feb 8, 2023
1 parent 8af4a7e commit 59be8d0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions components/gitpod-protocol/src/gitpod-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ export interface ClientHeaderFields {
clientRegion?: string;
}

const WORKSPACE_MAXIMUM_TIMEOUT_HOURS = 24;

export type WorkspaceTimeoutDuration = string;
export namespace WorkspaceTimeoutDuration {
export function validate(duration: string): WorkspaceTimeoutDuration {
Expand All @@ -369,6 +371,12 @@ export namespace WorkspaceTimeoutDuration {
if (isNaN(value) || value <= 0) {
throw new Error(`Invalid timeout value: ${duration}`);
}
if (
(unit === "h" && value > WORKSPACE_MAXIMUM_TIMEOUT_HOURS) ||
(unit === "m" && value > WORKSPACE_MAXIMUM_TIMEOUT_HOURS * 60)
) {
throw new Error(`Timeouts cannot extend to more than a day`);
}
return duration;
}
}
Expand Down

0 comments on commit 59be8d0

Please sign in to comment.