Skip to content
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

[server] incremental workspaces (1 of 2) #14303

Closed
wants to merge 1 commit into from
Closed

Conversation

svenefftinge
Copy link
Member

@svenefftinge svenefftinge commented Oct 31, 2022

Attention

Please review and approve #14461 which includes these changes

Description

This change adds a project preference that allows to generally use previous prebuilds and incrementally update the workspace when creating a workspace:

Screenshot 2022-11-06 at 21 38 35

Related Issue(s)

See #12582

How to test

  • create a team and a project
  • enable the project setting
  • start a prebuild on that project
  • start a workspace while a prebuild is running and see that you get a workspace starting from git.
  • wait for the prebuild to finish
  • add a commit on top so that a prebuild is running again
  • start a workspace while a prebuild is running and see that you get a workspace starting from git.
  • change the new preference in project settings
  • start a workspace while the prebuild is running and see that you get a workspace based on the previous prebuild.

Release Notes

Introduces new project setting to use old prebuilds on workspace start

Documentation

Werft options:

  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-integration-tests=all
    Valid options are all, workspace, webapp, ide

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-se-inc-ws.1 because the annotations in the pull request description changed
(with .werft/ from main)

@@ -57,7 +57,6 @@ export default function SelectWorkspaceClass(props: SelectWorkspaceClassProps) {
} else {
return (
<div>
<h3 className="mt-12">Workspaces</h3>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to the call site

getGitpodService()
.server.getWorkspace(workspaceId)
.then((ws) => {
if (ws.latestInstance?.status?.phase === "stopped") {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polling here every 2 secs is much simpler (and actually works). Listening to events has a problem where we could have missed the 'stopped' event and then hang forever

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this! I'm a huge fan of this simpler approach, and it also aligns much better with where we are looking to go with Pub API.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with either way. Can we use repeat or any other mechnaims that ensures we cannot pile up requests here? ☁️

@@ -1065,70 +1067,8 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
return;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everything deleted below is no longer needed because we are now polling for prebuild finish. See above ☝️

@svenefftinge svenefftinge marked this pull request as ready for review October 31, 2022 23:59
@svenefftinge svenefftinge requested a review from a team October 31, 2022 23:59
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Oct 31, 2022
Copy link
Member

@easyCZ easyCZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I would recommend splitting up the polling changes from the rest of the incremental workspaces feature.

/hold if you'd like a review from someone else also, I may not have 100% of the context here

@geropl
Copy link
Member

geropl commented Nov 4, 2022

Starting to review now.

@@ -262,7 +265,9 @@ export default class CreateWorkspace extends React.Component<CreateWorkspaceProp
</>
</div>
<div className="flex justify-end mt-6">
<button onClick={() => this.createWorkspace(CreateWorkspaceMode.Default)}>New Workspace</button>
<button onClick={() => this.createWorkspace({ ignoreRunningWorkspaceOnSameCommit: true })}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -148,7 +151,7 @@ export default class CreateWorkspace extends React.Component<CreateWorkspaceProp
<button
className=""
onClick={() => {
this.createWorkspace(CreateWorkspaceMode.Default, true);
this.createWorkspace({ forceDefaultConfig: true });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -421,7 +420,12 @@ export namespace GitpodServer {
}
export interface CreateWorkspaceOptions {
contextUrl: string;
mode?: CreateWorkspaceMode;
// whether running prebuilds should be ignored.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧡

@@ -211,6 +211,12 @@ export interface AdditionalUserData {
dotfileRepo?: string;
// preferred workspace classes
workspaceClasses?: WorkspaceClasses;
// whether running prebuilds should be ignored on start
ignoreRunnningPrebuilds?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to encapsulate these options in a sub-shape ala workspaceStartOptions or so? That would make some of the other code shorter as well, and help keeping this one clean(er).

@@ -1070,7 +1068,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
normalizedContextUrl = this.contextParser.normalizeContextURL(contextUrl);
let runningForContextPromise: Promise<WorkspaceInfo[]> = Promise.resolve([]);
const contextPromise = this.contextParser.handle(ctx, user, normalizedContextUrl);
if (mode === CreateWorkspaceMode.SelectIfRunning) {
if (!options.ignoreRunningWorkspaceOnSameCommit) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -1153,14 +1151,20 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
}
}

if (mode === CreateWorkspaceMode.SelectIfRunning && context.forceCreateNewWorkspace !== true) {
if (!options.ignoreRunningWorkspaceOnSameCommit && !context.forceCreateNewWorkspace) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -998,23 +998,29 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
prebuiltWorkspace = await this.workspaceDb
.trace(ctx)
.findPrebuiltWorkspaceByCommit(cloneUrl, commitSHAs);
if (prebuiltWorkspace?.state !== "available" && allowUsingPreviousPrebuilds) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This slight change in behavior (never starting based on previous prebuilds for OpenPrebuildContext) makes sense 💯

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to change this to prebuiltWorkspace?.state !== "available" && ignoreRunningPrebuild && allowUsingPreviousPrebuilds?
Otherwise exposing the ignoreRunningPrebuild option to users makes less sense, because it is not independent of allowUsingPreviousPrebuild, and we would have to explain that connection. 😕

@geropl
Copy link
Member

geropl commented Nov 4, 2022

Code LGTM, starting testing now.

@geropl
Copy link
Member

geropl commented Nov 4, 2022

/werft run

👍 started the job as gitpod-build-se-inc-ws.3
(with .werft/ from main)

@geropl
Copy link
Member

geropl commented Nov 4, 2022

Because of the missing preview env and failing build I took the liberty to rebase on latest main with the goal to test...

@geropl
Copy link
Member

geropl commented Nov 4, 2022

@svenefftinge Can you explain why you think exposing the ignoreRunningWorkspaceOnSameCommit option make sense? To me it feels like an implementation detail of the API, which is offers a nice catch-all for potentially bad UX flows. Or am I missing sth? 🤔
image

@geropl
Copy link
Member

geropl commented Nov 4, 2022

I tested back and forth, and it seems to mostly just work (TM) 🙂
Except when "Never wait for running prebuilds" = false && "Allow incremental workspaces" = true I never get to see the prebuild waiting screen.

Update:
Ok, found it here.

@geropl
Copy link
Member

geropl commented Nov 4, 2022

@svenefftinge Given the last two comments [1, 2] I think it would make sense to just expose a single option: the incremental workspace one. Motivation: the other options are hard to explain, add less additional value, and are not independent.
WDYT?

BTW I'd love to approve a PR that "just" replaces the mode with the option fields, that alone is 🧡 🙃

@svenefftinge
Copy link
Member Author

svenefftinge commented Nov 4, 2022

Thanks @geropl ! I've worked a bit on this with @mbrevoort as well and we agreed that we should only have the incremental prebuild setting. I'm moving this to the project level also, to make it easier enabling it for everyone.
We also believe that waiting for non-available prebuilds is never useful, so would like to remove this path entirely. WDYT?

@svenefftinge
Copy link
Member Author

svenefftinge commented Nov 4, 2022

@svenefftinge Can you explain why you think exposing the ignoreRunningWorkspaceOnSameCommit option make sense?

Yeah, it doesn't make sense. I think I did it because I could 😅 Have removed it.

@svenefftinge svenefftinge marked this pull request as draft November 4, 2022 17:50
@svenefftinge svenefftinge force-pushed the se/inc-ws branch 2 times, most recently from 9f52ac1 to 09fcd52 Compare November 6, 2022 20:37
@svenefftinge svenefftinge marked this pull request as ready for review November 6, 2022 20:38
@svenefftinge svenefftinge changed the title [server] incremental workspaces [server] incremental workspaces (1 of 2) Nov 7, 2022
</div>
</Modal>
);
} else if (result?.runningWorkspacePrebuild) {
return (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put this behind a feature flag, just to decouple it from the rollout of the "incremental workspace" feature?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could make the removal of runningWorkspacePrebuild a separate PR, that we merge first. But I'm not sure that buys us a lot. Would be super helpful to dive into the uncertainty a bit more and figure out if there is something we missed. I can't think of any issues that the removal of this feature could have on existing workflows or deployment.

Copy link
Member

@geropl geropl Nov 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the core, the concern I have is: What happens to a high-frequency repo, that did not enable incremental workspaces yet, once we roll this out? To me it feels they'd just never benefit from Prebuilds anymore. Until they understand that there is Incremental Workspaces, and validate that it works for them. This feels like a bad spot for us to be in, and it feels unnecessary as well.

Alternatively, we could leave the screen as-is, maybe tied to !opts.incrementalWorkspace. That way, people can still try to manually fall back to "Use last successful prebuild" (current code) if they want to.
Plus it gives us an obvious spot where to out the advertisement for the "Incremental Workspaces" option, which people can learn about and "migrate" to. 🧘

Copy link
Member Author

@svenefftinge svenefftinge Nov 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it feels they'd just never benefit from Prebuilds anymore

Why? They would have the same prebuilds as before, just don't get interrupted constantly by a running prebuild when starting a workspace.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus it gives us an obvious spot where to out the advertisement for the "Incremental Workspaces" option, which people can learn about and "migrate" to.

I would like to make this the default behavior once we have used it a little and verified it does what we hope it does.

@geropl
Copy link
Member

geropl commented Nov 7, 2022

we agreed that we should only have the incremental prebuild setting. I'm moving this to the project level also

💯 d'accord: project level also is nice because it_s a property of the project whether it supports incremental build

We also believe that waiting for non-available prebuilds is never useful

@svenefftinge I believe the same, but would be a bit more cautios with rolling out this change. Can we put this behind a feature flag? Just in case there are issues, e.g. unexpecte UX flow bugs etc.? Also, it would feel way better to keep the rollout separate from the other change. 🙂

Copy link
Contributor

@gtsiolis gtsiolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey everyone! Saw this new setting a left a drive-by comment below which can be also tackled in a follow-up issue. 😁

@svenefftinge
Copy link
Member Author

let's go for #14461

@svenefftinge svenefftinge deleted the se/inc-ws branch December 9, 2022 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants