-
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
[server] Allow setting ws-class on project level #14535
Conversation
started the job as gitpod-build-sefftinge-allow-specification-of-10963.1 because the annotations in the pull request description changed |
2e8bf4a
to
a24635e
Compare
a24635e
to
5ea3bfd
Compare
5ea3bfd
to
8fe883a
Compare
@@ -8,29 +8,22 @@ import { useContext, useEffect, useState } from "react"; | |||
import { getGitpodService } from "../service/service"; |
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.
changes in this file are to extract the user-preference-specific code, making the component reusable in the project settings context.
@@ -46,8 +46,6 @@ import { ChargebeeService } from "./user/chargebee-service"; | |||
import { StripeService } from "./user/stripe-service"; | |||
import { EligibilityService } from "./user/eligibility-service"; | |||
import { AccountStatementProvider } from "./user/account-statement-provider"; | |||
import { WorkspaceStarterEE } from "./workspace/workspace-starter"; |
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.
WorkspaceStarterEE does no longer container any logic, so I deleted it and also removed the corresponding bindings.
@@ -259,7 +259,7 @@ export class PrebuildManager { | |||
} else { | |||
span.setTag("starting", true); | |||
const projectEnvVars = await projectEnvVarsPromise; | |||
await this.workspaceStarter.startWorkspace({ span }, workspace, user, [], projectEnvVars, { | |||
await this.workspaceStarter.startWorkspace({ span }, workspace, user, project, [], projectEnvVars, { |
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'm adding the optional project to the call graph of workspace starts in various places, so that we fetch the project once and pass it down instead of repeatedly asking the DB.
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.
Why is that important in the context of this PR?
Also, triggers "premature optimization?" reflex.
❓ Would the PR still work without this change?
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.
It's not only because of reducing db queries but also a principle of good software design to explicitly pass what is needed as an argument rather than fetching data internally from a global state (the DB). I.e. more functional and easier to understand when you see the signature.
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.
also a principle of good software design to explicitly pass what is needed as an argument rather than fetching data internally from a global state (the DB)
That is a bit too vague and general for my taste to count as an argument, honestly. Then we'd need to talk service/layer boundaries first IMO, and sometimes there are good arguments against it as well.
But let's not hold up this PR any longer, I think the change is good overall. If we disagree in style we should settle that outside of PRs. 🧘
classes: WorkspaceClassesConfig, | ||
entitlementService: EntitlementService, | ||
): Promise<string> { | ||
if (project?.settings?.workspaceClasses?.regular) { |
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.
(1/3) use of the new project setting (precedence over user setting)
config, | ||
entitlementService, | ||
); | ||
workspaceClass = WorkspaceClasses.selectClassForRegular(prebuildClass, userClass, config); | ||
} else if (project?.settings?.workspaceClasses?.regular) { |
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.
(2/3) use of the new project setting (precedence over user setting)
} else if (user.additionalData?.workspaceClasses?.regular) { | ||
workspaceClass = user.additionalData?.workspaceClasses?.regular; | ||
} | ||
} | ||
|
||
if (workspace.type == "prebuild") { | ||
if (user.additionalData?.workspaceClasses?.prebuild) { | ||
if (project?.settings?.workspaceClasses?.prebuild) { |
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.
(3/3) use of the new project setting (precedence over user setting)
@@ -326,6 +326,7 @@ async function execute(builder: WorkspaceClassTestBuilder, expectedClass: string | |||
workspace, | |||
previousInstance, | |||
user, | |||
undefined, |
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.
Should there be also a test which does pass in a Project?
@@ -2980,6 +2985,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { | |||
let user = this.checkAndBlockUser("getSupportedWorkspaceClasses"); | |||
let selectedClass = await WorkspaceClasses.getConfiguredOrUpgradeFromLegacy( | |||
user, | |||
undefined, |
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.
Why are we not passing the project here?
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.
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.
We don't have a project context
const projectPromise = workspace.projectId | ||
? this.projectDB.findProjectById(workspace.projectId) | ||
: Promise.resolve(undefined); |
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.
await syntax?
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.
This is an parallelization strategy.
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.
Yes, I'm creating a promise here and await it below, especially after the mayStartPromise
which takes the longest time.
@@ -21,6 +21,8 @@ export interface ProjectSettings { | |||
allowUsingPreviousPrebuilds?: boolean; | |||
// how many commits in the commit history a prebuild is good (undefined and 0 means every commit is prebuilt) | |||
prebuildEveryNthCommit?: number; | |||
// preferred workspace classes | |||
workspaceClasses?: WorkspaceClasses; |
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.
This is bit of a smell. Why is it plural workspaceClasses when we're not passing in a list?
Currently we look to only have a single preference, could we go with a list here (which is initially only 1 item long) and allow for the "preferences" to be a list?
I can imagine wanting to specify a priority list of classes I want to use. This also facilitates gradual migration away from one WS class to another over time - by changing the priorities (ordering)
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 think it make senses to reuse the shape and naming we already have in place. Although I agree WorkspaceClassConfig
or similar would have been a better choice in the first 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.
Besides that I copied the shape from user settings, I don't think it is smelly. As it represents multiple (currently two) workspace classes.
Wanted to test, but noticed the build was failing. |
8fe883a
to
984be6b
Compare
Looking at this now! 👀 |
Fixed and deployed it |
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.
UX LGTM! Thanks for the ping[1], @svenefftinge! 🏓
Left some non-blocking comments that can be tackled separately in follow-up issues if needed.
Also, good call on moving this to the workspace settings section.
<SelectWorkspaceClass | ||
workspaceClass={project.settings?.workspaceClasses?.regular} | ||
enabled={BillingMode.canSetWorkspaceClass(teamBillingMode)} | ||
setWorkspaceClass={setWorkspaceClass} | ||
/> |
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.
thought: It's a bit confusing that preview environments contain two quite different classes from what's on Gitpod.io and the order is also reversed, but that's out of the scope of these changes, see relevant discussion (internal).
@@ -142,8 +161,12 @@ export default function () { | |||
|
|||
{showPersistentVolumeClaimUI && ( | |||
<> | |||
<br></br> | |||
<h3 className="mt-12">Workspaces</h3> | |||
<SelectWorkspaceClass |
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.
praise: Nice component reuse! 😁
@@ -142,8 +161,12 @@ export default function () { | |||
|
|||
{showPersistentVolumeClaimUI && ( | |||
<> | |||
<br></br> | |||
<h3 className="mt-12">Workspaces</h3> |
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.
@@ -142,8 +161,12 @@ export default function () { | |||
|
|||
{showPersistentVolumeClaimUI && ( | |||
<> | |||
<br></br> | |||
<h3 className="mt-12">Workspaces</h3> | |||
<SelectWorkspaceClass |
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.
thought: Feels good to see we're working towards making Teams & Projects more useful.
<SelectWorkspaceClass | ||
workspaceClass={user?.additionalData?.workspaceClasses?.regular} | ||
enabled={BillingMode.canSetWorkspaceClass(userBillingMode)} | ||
setWorkspaceClass={setWorkspaceClass} | ||
/> |
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.
issue: The duplicate preference in user settings and project settings now poses a question on which preference overrides which. The workspace class scope could be something worth documenting if it's unclear but the project setting should override the user setting, correct?
Settings scope for workspace classes
Your project setting overrides the user setting.
<SelectWorkspaceClass | ||
workspaceClass={user?.additionalData?.workspaceClasses?.regular} | ||
enabled={BillingMode.canSetWorkspaceClass(userBillingMode)} | ||
setWorkspaceClass={setWorkspaceClass} | ||
/> |
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.
suggestion: Once this is merged, it could be worth updating the existing and soon outdated docs.
You can configure the workspace class that should be used for your workspaces in your user preferences.
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.
Tested and works.
👍 For George's comment about updating our docs ✨
Description
Introduces a project settings to specify the workspace class.
Related Issue(s)
Fixes #10963
How to test
Release Notes
Documentation
Werft options:
If enabled this will build
install/preview
Valid options are
all
,workspace
,webapp
,ide