Skip to content

Add default workspace image to org setting #18723

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

Merged
merged 27 commits into from
Sep 19, 2023
Merged

Add default workspace image to org setting #18723

merged 27 commits into from
Sep 19, 2023

Conversation

mustard-mh
Copy link
Contributor

@mustard-mh mustard-mh commented Sep 15, 2023

Description

Summary generated by Copilot

🤖 Generated by Copilot at f347e3b

This pull request adds support for setting a default workspace image for an organization, which affects the workspace config for projects and prebuilds that belong to that organization. It also refactors some dashboard components and adds some error handling and UI logic for the organization settings page. It modifies the data model, the database migration, the server API, the client hooks, and the prebuild integrations to implement this feature.

Related Issue(s)

Fixes EXP-614

How to test

Dashboard UX

Workspace Image

GP-CLI gp validate

  • When using gp validate [doc] , it should align to section Workspace Image above too

Private ECR

Documentation

Preview status

Gitpod was successfully deployed to your preview environment.

Build Options

Build
  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer
  • analytics=segment
  • with-dedicated-emulation
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated
Preview Environment / Integration Tests
  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh. If enabled, with-preview and with-large-vm will be enabled.
  • with-monitoring

/hold

@roboquat roboquat added size/XXL and removed size/L labels Sep 15, 2023
@mustard-mh mustard-mh marked this pull request as ready for review September 15, 2023 20:16
@mustard-mh mustard-mh requested a review from a team as a code owner September 15, 2023 20:16
@mustard-mh mustard-mh marked this pull request as draft September 15, 2023 20:17
@mustard-mh mustard-mh marked this pull request as ready for review September 15, 2023 21:47
@mustard-mh mustard-mh marked this pull request as draft September 15, 2023 22:19
Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

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

I tested and generally it works.

/hold

there are some discussions though have we can surface issues with access to the default image to members and owners. see https://gitpod.slack.com/archives/C05H5UQBW6Q/p1695027536449729?thread_ts=1695026341.413039&cid=C05H5UQBW6Q

@mustard-mh
Copy link
Contributor Author

Unit tests added, try it with exec yarn mocha --opts mocha.opts './**/config-provider.spec.js' --exclude './node_modules/**' on components/server
image

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.

Thanks for adding this, @mustard-mh. 🌮

I've added below a few comments on UX—most importantly a suggestion for adding a message for users when their workspace could break because of the custom default image set.

We can improve the UX more around this feature in later iterations:

  1. Better checks
  2. Better form UX
  3. Include auth for private registries
  4. ...

d = []byte(`# List the start up tasks. Learn more: https://www.gitpod.io/docs/configure/workspaces/tasks
defaultImage, err := getDefaultWorkspaceImage(ctx)
if err != nil {
fmt.Printf("failed to get organization default workspace image: %v\n", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Not the best line to comment on this, but org users can easily run into non-functional workspace start flow if image is inaccessible, tags are missing, etc. See relevant discussion (internal). Cc @akosyakov

Error 1 Error 2 ...
Screenshot 2023-09-18 at 12 08 08 Screenshot 2023-09-18 at 11 53 25

@@ -2507,6 +2509,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
const user = await this.checkAndBlockUser("updateOrgSettings");
traceAPIParams(ctx, { orgId, userId: user.id });
await this.guardTeamOperation(orgId, "update");
// TODO: call ImageBuilder ResolveBaseImage to dry test if we can access this image
Copy link
Contributor

Choose a reason for hiding this comment

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

thought: This could be out of the scope of this PR, but from the relevant discussion (internal) with @akosyakov, an idea could be to try to validate the image on load, and nudge org owners when something is wrong. This could be surfacing also in the dashboard as global alert. 💡

Checking Error OK
Frame 1882 Frame 1883 Frame 1884

Later on, we could improve UX by also moving the help text and also this status check above the text input.

Proposed UX for help text placement, out of the scope of this PR
Frame 1881

Comment on lines +239 to +246
<TextInputField
label="Default Image"
// TODO: Provide document links
hint="Use any official Gitpod Docker image, or Docker image reference"
value={defaultWorkspaceImage}
onChange={setDefaultWorkspaceImage}
disabled={isLoading || !org?.isOwner}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

issue(non-blocking): Minor UX issue, but could we use a placeholder for now when someone is deleting the text input_ here? Feels a bit unintuitive when you delete all text and click save that there's a default value overriding the empty text input. Could be improved later.

orgIdEnv.setName("GITPOD_WORKSPACE_DEFAULT_IMAGE");
orgIdEnv.setValue(await this.configProvider.getDefaultImage(workspace.organizationId));
sysEnvvars.push(orgIdEnv);

const spec = new StartWorkspaceSpec();
Copy link
Contributor

@gtsiolis gtsiolis Sep 18, 2023

Choose a reason for hiding this comment

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

suggestion: Definitely not the best line to comment about this, but since setting a non-reachable or non-functional workspace image could break UX for many org users, we could at least inform users why their workspace is broken.

From relevant discussion (internal):

Otherwise, users would be left in blank if they don't have organization settings access. I don't think users can guess there's something wrong with the custom image, right?

What do you think of adding an error alert in the workspace start, when a custom default image, and ideally we could check if it's accessible or not? If we can't check if the image is reachable, we could tone down the error as we do with the last editor warning and warn users that there's a custom set image that could be responsible for this workspace error.

What do you think?

Error alert Warning alert
Frame 1885 Frame 1886

☝️ Copy for the warning could be improved.
☝️ We use that area for the latest editor warning, which could be nice if we replaced. In the future, we could hide the latest editor warning all together or tone down the message.

Copy link
Member

Choose a reason for hiding this comment

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

@mustard-mh can we do something here?

@mustard-mh
Copy link
Contributor Author

mustard-mh commented Sep 18, 2023

📔 To summarize:

Going to smoke test this PR, and only push necessary changes then.

@akosyakov
Copy link
Member

akosyakov commented Sep 18, 2023

on Dashboard when change org settings @gtsiolis [https://github.com//pull/18723#discussion_r1328482602] EXP-630

It is not only on change of default workspace image, but whenever someone to see it as well. There can be other conditions why it fails not only when default image is changing.

on GP-CLI gp init gp validate @gtsiolis [https://github.com//pull/18723#discussion_r1328461586] EXP-632

Here we don't need to do anyhting. It is outside of Gitpod control. User has to docker login and so on.

@mustard-mh
Copy link
Contributor Author

mustard-mh commented Sep 18, 2023

It is not only on change of default workspace image, but whenever someone to see it as well. There can be other conditions why it fails not only when default image is changing.

@akosyakov Could you explain this in detail?

Here we don't need to do anyhting. It is outside of Gitpod control. User has to docker login and so on.

User who has private ECR permission on workspace start don't have that permission on in workspace docker pull, it's because we don't attach related env to workspace for security issues.

@akosyakov So you mean that it's ok if we just left docker pull output to them

@akosyakov
Copy link
Member

akosyakov commented Sep 18, 2023

@akosyakov Could you explain this in detail?

Someone did some external change which broke default image pull, i.e. changed auth to registry, deleted a tag or so. In #18723 (comment) is proposed to validate on page load, so owner can go to this page and see whether everything is alright with the default image. The indicator is not part of changing org settings, but decoupled check which happens always, does not prevent from update the setting. They are not coupled. Org service does not need to know about image builder.

@akosyakov So you mean that it's ok if we just left docker pull output to them

yes

@mustard-mh
Copy link
Contributor Author

@akosyakov I see, Linear updated 🙏

@akosyakov
Copy link
Member

Do we still need to do anything of rest can be addressed with follow-up PRs? @gtsiolis @mustard-mh @loujaybee

@mustard-mh mustard-mh force-pushed the hw/org-img branch 2 times, most recently from 1faf203 to 22cca8d Compare September 18, 2023 17:55
@mustard-mh
Copy link
Contributor Author

mustard-mh commented Sep 19, 2023

Smoke tested test cases, going to unhold ✅

@laushinka
Copy link
Contributor

Thanks for this great progress, @mustard-mh! In case we're going very back and forth on the validation aspect, let's move that to a different PR, and focus this one on adding the setting.

@mustard-mh
Copy link
Contributor Author

/unhold

🎉

@roboquat roboquat merged commit 04e576f into main Sep 19, 2023
@roboquat roboquat deleted the hw/org-img branch September 19, 2023 12:52
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.

8 participants