Skip to content

[server] Separate instance creation from instance starting (again) #18642

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 2 commits into from
Sep 4, 2023

Conversation

geropl
Copy link
Member

@geropl geropl commented Sep 1, 2023

Description

In preparation of making sure we don't break workspace starts during rollouts, this PR does some cleanup in WorkspaceStarter. Most importantly, we ensure that after a WorkspaceInstance is stored in the DB, we can start a workspace from it. 👍 (also, makes the code cleaner).

Short summary to make the changes easier to digest:

  • introduced buildImageAndStartWorkspace to "mark" that separation, but also for usage in upcoming PRs
  • remove options.rethrow: not used anymore
  • instead of piping lastValidWorkspaceInstanceId through multiple layers for a simple check, condense it into fromBackup right away
  • persist the parts of ideConfig that we need during workspace start into instance.configuration.ideSetup
Summary generated by Copilot

🤖 Generated by Copilot at f4fa9fd

This pull request adds a new interface for IDE setup, refactors the workspace-starter and ide-service modules, and makes the configuration field mandatory for workspace instances.

Related Issue(s)

Related to EXP-549
Depends on: #18641

How to test

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

@geropl geropl force-pushed the gpl/ws-starter branch 4 times, most recently from 15ab10f to bd3a5a7 Compare September 1, 2023 12:15
Base automatically changed from gpl/ws-starter to main September 1, 2023 12:39
@roboquat roboquat added size/XL and removed size/L labels Sep 1, 2023
@@ -101,7 +101,7 @@ export class DBWorkspaceInstance implements WorkspaceInstance {
type: "simple-json",
nullable: true,
})
configuration?: WorkspaceInstanceConfiguration;
configuration: WorkspaceInstanceConfiguration;
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 checked the DB: We have 0 instances where this field is NULL or "".

// Beware: this field was added retroactively and not all instances have valid
// values here.
configuration?: WorkspaceInstanceConfiguration;
configuration: WorkspaceInstanceConfiguration;
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 checked the DB: We have 0 instances where this field is NULL or "".

@@ -129,7 +130,6 @@ import { SYSTEM_USER } from "../authorization/authorizer";
import { ResolvedEnvVars } from "../user/env-var-service";

export interface StartWorkspaceOptions extends GitpodServer.StartWorkspaceOptions {
Copy link
Member Author

Choose a reason for hiding this comment

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

rethrow was never anywhere anymore.

@@ -308,6 +308,7 @@ export class WorkspaceStarter {
project,
options.excludeFeatureFlags || [],
ideConfig,
options.region,
Copy link
Member Author

Choose a reason for hiding this comment

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

With this change, after instance creation, there is no need for any further lookup: The instance shape contains everything that is needed to start a workspace.

Only exception that is up for discussion: envVars. Ideally we should store those as well, but I refrained because we might store unencrypted passwords or similar.
Open for comments and ideas here!

Copy link
Member

Choose a reason for hiding this comment

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

Is it because JSON stored unencrypted? i.e. how is it different to value in env var tables?

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.e. how is it different to value in env var tables?

There we use an encrypting transformer (source).

): Promise<{ initializer: WorkspaceInitializer; disposable: Disposable }> {
let result = new WorkspaceInitializer();
const disp = new DisposableCollection();

if (lastValidWorkspaceInstanceId != "") {
if (fromBackup) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This check was the only reason we piped lastValidWorkspaceInstanceId: string through 4 layers... 🙈

@geropl geropl marked this pull request as ready for review September 1, 2023 13:00
@geropl geropl requested a review from a team as a code owner September 1, 2023 13:00
@geropl geropl requested a review from akosyakov September 1, 2023 13:08
@geropl
Copy link
Member Author

geropl commented Sep 1, 2023

@akosyakov Would be great to get your feedback for the changes around ideConfig. I assumed that ideConfig.tasks or .envvars never contain secrets or similar, but would be great if you could confirm. 🙏

@akosyakov
Copy link
Member

@geropl You can check here:

func (s *IDEServiceServer) ResolveWorkspaceConfig(ctx context.Context, req *api.ResolveWorkspaceConfigRequest) (resp *api.ResolveWorkspaceConfigResponse, err error) {
I think we don't have any tasks anymore, we added them for JB prebuild, but they moved to supervisor by now. There are couple env vars but they are not secrets.

@akosyakov
Copy link
Member

akosyakov commented Sep 4, 2023

/gh run recreate-vm=true

Comment triggered a workflow run

Started workflow run: 6069970179

  • recreate_vm: true

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 smoke tested that workspace with custom settings still can be started. Code changes also look reasonable.

@akosyakov
Copy link
Member

@geropl Prebuilds are another path right? We will need to take care about them separately from PrebuildManager?

@geropl
Copy link
Member Author

geropl commented Sep 4, 2023

Prebuilds are another path right?

Prebuilds are using this path as well (source).

@geropl
Copy link
Member Author

geropl commented Sep 4, 2023

/unhold

@roboquat roboquat merged commit 86fa3ba into main Sep 4, 2023
@roboquat roboquat deleted the gpl/ws-starter-2 branch September 4, 2023 07:33
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.

3 participants