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

Migrate Prebuild settings – EXP-672 #18842

Merged
merged 24 commits into from
Oct 5, 2023
Merged

Conversation

AlexTugarev
Copy link
Member

@AlexTugarev AlexTugarev commented Sep 29, 2023

Description

This PR introduces a PrebuildSettings model to encapsulate prebuild settings of a project in Gitpod. Existing projects will get updated on access of the project, i.e. once the Project model is accesses, the settings are updated. The Project Settings page uses the new data structure to render and update prebuild settings.

As this is primarily a backend change, there are no UX changes to expect.

Regarding system behavior of this one time migration the noteworthy impact is the following:

  • Prebuilds will be explicitly disabled on pre-existing projects, if the project is not active and no prebuilds were registered in the past 7 days, which is the regular period Gitpod uses to start considering projects inactive.
    • Using this predicate allows to safely assume, that if we mark prebuilds as enabled, the underlying prebuild events are working on those projects.
    • We need to follow up with announcements and docs on the new prebuild settings, to make users aware of the new explicit enablement of prebuilds on projects.
Summary generated by Copilot

🤖 Generated by Copilot at 9024949

Refactor prebuild settings data model and logic to support more flexible and configurable prebuild options for projects. Update the UI, the protocol, the API, and the server components to use the new prebuilds property of the project settings, and migrate the existing settings of inactive projects.

Related Issue(s)

Fixes EXP-672

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

@roboquat roboquat added size/XXL and removed size/XL labels Sep 29, 2023
*/
prebuilds?: PrebuildSettings;

/** @deprecated see `Project.settings.prebuilds.enabled` instead. */
Copy link
Member Author

Choose a reason for hiding this comment

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

FYI, not removing here, as these are required for the migration phase

@@ -174,10 +172,7 @@ export class GitHubEnterpriseApp {
context,
});

const shouldRun = Project.hasPrebuildSettings(project)
? prebuildPrecondition.shouldRun
: this.appRules.shouldRunPrebuild(config, CommitContext.isDefaultBranch(context), false, false);
Copy link
Member Author

Choose a reason for hiding this comment

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

FYI, this does effectively disables comparable settings in .gitpod.yml, which we want to deprecate in #18788

@AlexTugarev
Copy link
Member Author

AlexTugarev commented Sep 29, 2023

Header Header
Screenshot 2023-09-29 at 18 16 11 Screenshot 2023-09-29 at 16 41 30

Briefly checked that the filtering feature is still working, e.g. build only on feature-* branches.

@AlexTugarev AlexTugarev changed the title Migrate Prebuild settings Migrate Prebuild settings – EXP-672 Sep 29, 2023
@AlexTugarev AlexTugarev marked this pull request as ready for review September 29, 2023 16:11
@svenefftinge
Copy link
Member

We should remove these three settings with this PR (at least from the UI) and turn the defaults from

Screenshot 2023-09-30 at 09 32 38

to
Screenshot 2023-09-30 at 09 35 40

export function getPrebuildSettings(project: Project): PrebuildSettingsWithDefaults {
const effective = {
...PREBUILD_SETTINGS_DEFAULTS,
...project.settings?.prebuilds,
Copy link
Member

Choose a reason for hiding this comment

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

This overrides properties that are set to undefined.
We need to filoter those properties out first.

    /**
     * Returns effective prebuild settings for the given project. The resulting settings
     * contain default values for properties which are not set explicitly for this project.
     */
    export function getPrebuildSettings(project: Project): PrebuildSettingsWithDefaults {
        const overrides = Object.fromEntries(
            Object.entries(project.settings?.prebuilds ?? {}).filter(([_, value]) => value !== undefined),
        );

        return {
            ...PREBUILD_SETTINGS_DEFAULTS,
            ...overrides,
        };
    }
    ```

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@svenefftinge
Copy link
Member

I propose to change the settings UI like this:
Screenshot 2023-09-30 at 10 02 15

@@ -805,7 +805,7 @@ export class TypeORMWorkspaceDBImpl extends TransactionalDBImpl<WorkspaceDB> imp
const repo = await this.getPrebuiltWorkspaceRepo();

let query = repo.createQueryBuilder("pws");
query = query.where("pws.projectId != :projectId", { projectId });
query = query.where("pws.projectId = :projectId", { projectId });
Copy link
Member

Choose a reason for hiding this comment

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

🙏

@AlexTugarev
Copy link
Member Author

Alright, let me try to add those changes.

@AlexTugarev
Copy link
Member Author

@svenefftinge, could we apply changes to the layout and inlining of settings in a separate PR 🙏🏻. This one is already 1K changes and it took a while to test ride it. The mentioned application of defaults is related but not affected by the settings migration in general. It wouldn't change much to do that separately.

@svenefftinge svenefftinge force-pushed the at/migrate-prebuild-settings branch from 1f1715d to b88a21f Compare October 5, 2023 08:30
@AlexTugarev AlexTugarev requested a review from a team as a code owner October 5, 2023 08:30
bool keep_outdated_prebuilds_running = 2;
bool use_previous_prebuilds = 3;
int32 prebuild_every_nth = 4;
reserved 1; // enable_incremental_prebuilds
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -328,22 +328,22 @@ func setupProjectsService(t *testing.T) (*protocol.MockAPIInterface, v1connect.P

func newProject(p *protocol.Project) *protocol.Project {
r := rand.Int()
b_false := false
Copy link
Member

Choose a reason for hiding this comment

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

[nit] Underscore is an anti-pattern in go. camelCase is the expected

@svenefftinge svenefftinge force-pushed the at/migrate-prebuild-settings branch from b88a21f to d0decdb Compare October 5, 2023 09:59
@loujaybee
Copy link
Member

Linking through the related documentation and changelog updates related to changing the prebuild settings.

Given the potential impact on users workflows from this change, I would suggest that we make sure to incorporate documentation of the changes into the linked docs pull request, so that users are aware of the impact and actions on their end. Some areas that we'll want to clarify in comms (questions are rhetorical, so don't need directly answering here):

  1. Will this impact only existing, or new projects?
  2. What actions will a user have to take (given the behavioural changes e.g by enabling incremental prebuilds)?
  3. What are the potential impacts on cost for these defaults? Whether adverse, or positive changes does it introduce?

... I will try to think through other impacts + questions.

Some further discussion, questions and clarifications in this internal slack thread.

@svenefftinge svenefftinge force-pushed the at/migrate-prebuild-settings branch from d0decdb to b6466c4 Compare October 5, 2023 10:20
@svenefftinge svenefftinge force-pushed the at/migrate-prebuild-settings branch from d29f3b8 to 63c3c6d Compare October 5, 2023 12:46
@svenefftinge
Copy link
Member

/unhold

@roboquat roboquat merged commit b2260d0 into main Oct 5, 2023
15 checks passed
@roboquat roboquat deleted the at/migrate-prebuild-settings branch October 5, 2023 14:37
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.

6 participants