-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[installer] Allow to set default workspace timeout #8576
Conversation
Codecov Report
@@ Coverage Diff @@
## main #8576 +/- ##
========================================
- Coverage 7.34% 7.32% -0.02%
========================================
Files 32 32
Lines 2234 2238 +4
========================================
Hits 164 164
- Misses 2067 2071 +4
Partials 3 3
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
ac8b378
to
9e73691
Compare
public workspaceTimeoutToDuration(timeout: WorkspaceTimeoutDuration): string { | ||
switch (timeout) { | ||
case WORKSPACE_TIMEOUT_DEFAULT_SHORT: | ||
return "30m"; | ||
case WORKSPACE_TIMEOUT_DEFAULT_LONG: | ||
return this.config.workspaceDefaults.timeoutDefault || "60m"; | ||
case WORKSPACE_TIMEOUT_EXTENDED: | ||
case WORKSPACE_TIMEOUT_EXTENDED_ALT: | ||
return this.config.workspaceDefaults.timeoutExtended || "180m"; | ||
} | ||
} | ||
|
||
public durationToWorkspaceTimeout(duration: string): WorkspaceTimeoutDuration { | ||
switch (duration) { | ||
case "30m": | ||
return WORKSPACE_TIMEOUT_DEFAULT_SHORT; | ||
case this.config.workspaceDefaults.timeoutDefault || "60m": | ||
return WORKSPACE_TIMEOUT_DEFAULT_LONG; | ||
case this.config.workspaceDefaults.timeoutExtended || "180m": | ||
return WORKSPACE_TIMEOUT_EXTENDED_ALT; | ||
default: | ||
return WORKSPACE_TIMEOUT_DEFAULT_SHORT; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if user-service
is a good place for these functions. I was too miserly to create a dedicated service for this that does nothing but provide these values. However, I'm very open to proposals for better places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also have no idea if user-service
is a good place for this, but if nobody has an opinion on this, then let's say it is a good place. 🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did not test but code changes lgtm
Could you file a follow-up issue for VS Code please? 🙏 and add to IDE team inbox |
I wonder why the PR is marked wit @mads-hartmann Should we remove this label? Or the deploy labeller is a smart enough to check only for teams which actually affected? |
@akosyakov I requested a review from the IDE team due to the IDE flaws with timeout extends. Just wanted to make sure that the IDE team has a look that is does not break the communication with the IDE. |
@akosyakov The label gets added when a team is requested as reviewers - the intention is that CODEOWNERS defines reviewers, but for cases like this where you just want a 2nd pair of eyes I agree it isn't ideal. Removing the label is these cases is the best way forward :) |
A review from webapp team is required here to land correct? cc @geropl |
@akosyakov I don't think there's much point at the moment as there's some conflicted files. I'll leave this today in the hope that @corneliusludmann is feeling better by tomorrow, otherwise I'll do my best at resolving the conflicts |
39906ef
9e73691
to
39906ef
Compare
Looks good. Can you update the |
39906ef
to
ee9e7bb
Compare
Done. |
Many thanks for this contribution! Taking a look on behalf of team WebApp 👀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The WebApp component changes look good to me! ✨
I've also tested the latest deployment, and it seems to work flawlessly. 🥇
I've added a few comments/thoughts/questions in-line (mostly about naming things and better understanding this change, but please feel free to dismiss my comments and/or open follow-up issues to be addressed later without blocking your PR).
As a side note, this reminds me that I've always wanted to also make the Prebuild timeouts more "dynamic" (i.e. not necessarily configurable by installers as in your PR, but it would be nice -- in addition to the default 1h timeout -- to also have a 4h timeout for long-building projects, e.g. only for base prebuilds when you have Incremental Prebuilds enabled). No action required here, but sharing my thoughts as they seem somewhat related.
Adding a hold in case you'd like to address some comments, but feel free to unhold any time:
/hold
public workspaceTimeoutToDuration(timeout: WorkspaceTimeoutDuration): string { | ||
switch (timeout) { | ||
case WORKSPACE_TIMEOUT_DEFAULT_SHORT: | ||
return "30m"; | ||
case WORKSPACE_TIMEOUT_DEFAULT_LONG: | ||
return this.config.workspaceDefaults.timeoutDefault || "60m"; | ||
case WORKSPACE_TIMEOUT_EXTENDED: | ||
case WORKSPACE_TIMEOUT_EXTENDED_ALT: | ||
return this.config.workspaceDefaults.timeoutExtended || "180m"; | ||
} | ||
} | ||
|
||
public durationToWorkspaceTimeout(duration: string): WorkspaceTimeoutDuration { | ||
switch (duration) { | ||
case "30m": | ||
return WORKSPACE_TIMEOUT_DEFAULT_SHORT; | ||
case this.config.workspaceDefaults.timeoutDefault || "60m": | ||
return WORKSPACE_TIMEOUT_DEFAULT_LONG; | ||
case this.config.workspaceDefaults.timeoutExtended || "180m": | ||
return WORKSPACE_TIMEOUT_EXTENDED_ALT; | ||
default: | ||
return WORKSPACE_TIMEOUT_DEFAULT_SHORT; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also have no idea if user-service
is a good place for this, but if nobody has an opinion on this, then let's say it is a good place. 🙌
} | ||
} | ||
|
||
public durationToWorkspaceTimeout(duration: string): WorkspaceTimeoutDuration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the types a little confusing in these method signatures:
duration
is astring
, and the returnedTimeout
is aWorkspaceTimeoutDuration
? 🤔- Also
workspaceTimeoutToDuration
takes aWorkspaceTimeoutDuration
and turns it into astring
(would expect the other way around)
I feel like duration
should be of type ...Duration
, and timeout
of type ...Timeout
. 💭
Maybe this could be a follow-up issue though. ⏩
|
||
return client.setTimeout(ctx, req); | ||
}), | ||
); | ||
|
||
const req = new SetTimeoutRequest(); | ||
req.setId(runningInstance.id); | ||
req.setDuration(duration); | ||
req.setDuration(this.userService.workspaceTimeoutToDuration(duration)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Micro-nit: Unfortunate variable naming 🙈 somethingElseToDuration(duration)
("...wait, isn't it already a duration?")
@@ -352,7 +355,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl { | |||
|
|||
const client = await this.workspaceManagerClientProvider.get(runningInstance.region); | |||
const desc = await client.describeWorkspace(ctx, req); | |||
const duration = desc.getStatus()!.getSpec()!.getTimeout() as WorkspaceTimeoutDuration; | |||
const duration = this.userService.durationToWorkspaceTimeout(desc.getStatus()!.getSpec()!.getTimeout()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Micro-nit: Same here, we're calling somethingElseToTimeout(...getTimeout())
🙈 (as in, turn a timeout into a timeout?)
But let's not fix this now. I understand this came up for historical reasons, and I don't have a good suggestion on how to improve it now.
Thanks, @jankeromnes for your great feedback! Since your comments are more very useful improvements and no blockers, as suggested, I'll let this pull request merge now and handle your comments in follow-up issues/pull requests. That makes the review process easier because we don't need approval from the other teams for the proposed changes. Thanks again! 🙏 /unhold |
Hi @corneliusludmann , how can I setting Default workspace CustomTime after install via kots? |
Description
This is a proposal that allows to set custom timeouts for the workspaces. It adds the following config values:
Related Issue(s)
Fixes #8528
How to test
Add the following patch to
deploy-to-preview-environment.ts
:And run a werft build like this:
NOTE: I did this already. As long as the preview env hasn't been removed in the meantime, the preview should be deployed like this.
With this configuration you can observe the following timeouts:
When you start a workspace, it times out after 3 minutes of inactivity. You can see this value when you run (change your workspace ID):
You'll also see the current timeout when you hover over the clock in your workspace status bar:
When you extend your workspace timeout (click on the clock), the new timeout will be 6 minutes (check again with
kubectl
or the hover message).When you close the browser, the workspace times out after 10 seconds. (Note: The value that you see with
kubectl
will not change but you can see that the pod disappears after 10 seconds and the Gitpod dashboard shows stopping.)The workspace will be stopped after 9 minutes. Even if there is activity. It will stop in every case.
Discussion and Limitations
I tried to eliminate the hard-coded values in the code and add “classes” of timeouts (short, long, and extended). However, the VS Code IDE sends always
180m
as a timeout value when a user clicks on the clock. That's why I kept the180m
constant as an alternative value forextended
. In the long term, it would make sense to sendextended
instead.When the user extends the workspace, the message always says it's extended to “three hours”. That should be changed to a more general wording.
The hover text always shows the proper timeout value but the color of the clock is checked by comparing it with the hard-coded value of
180m
. The problem is, that we don't know at this point what the extended timeout value is. Instead of readinglistener.info.latestInstance
, we could also callinstead. That always returns
180m
as timeout as constant for the extended value (should be probably changed toextended
in the long term, see above). However, I don't know if that has a performance impact.All of these are little UI flaws that shouldn't be real blockers, in my opinion.
/cc @akosyakov
Release Notes