diff --git a/components/dashboard/src/admin/ProjectDetail.tsx b/components/dashboard/src/admin/ProjectDetail.tsx index c72d512eaaafa5..ab68d6926ba331 100644 --- a/components/dashboard/src/admin/ProjectDetail.tsx +++ b/components/dashboard/src/admin/ProjectDetail.tsx @@ -45,9 +45,6 @@ export default function ProjectDetail(props: { project: Project; owner: string |
- - {props.project.settings?.useIncrementalPrebuilds ? "Yes" : "No"} - {props.project.markedDeleted ? "Yes" : "No"}
diff --git a/components/dashboard/src/projects/ProjectSettings.tsx b/components/dashboard/src/projects/ProjectSettings.tsx index 7a3bd09ec011f2..ff5a1798dd4bb6 100644 --- a/components/dashboard/src/projects/ProjectSettings.tsx +++ b/components/dashboard/src/projects/ProjectSettings.tsx @@ -9,7 +9,6 @@ import { useCallback, useContext, useState, Fragment, useMemo, useEffect } from import { useHistory } from "react-router"; import { CheckboxInputField } from "../components/forms/CheckboxInputField"; import { PageWithSubMenu } from "../components/PageWithSubMenu"; -import PillLabel from "../components/PillLabel"; import { getGitpodService } from "../service/service"; import { ProjectContext, useCurrentProject } from "./project-context"; import { getProjectSettingsMenu, getProjectTabs } from "./projects.routes"; @@ -113,6 +112,7 @@ export default function ProjectSettingsView() { await updateProjectSettings({ prebuilds: { + ...project.settings?.prebuilds, enable: value, }, }); @@ -237,13 +237,12 @@ export default function ProjectSettingsView() { label="Enable prebuilds" hint={ - {prebuildSettings.enable ? ( - - Prebuilds will run for any before or init tasks. - - ) : ( - "Requires permissions to configure repository webhooks." - )}{" "} + + Prebuilds reduce wait time for new workspaces. + {!prebuildSettings.enable + ? " Enabling requires permissions to configure repository webhooks." + : ""} + {" "} {prebuildSettings.enable && ( <> - setPrebuildBranchStrategy(val as PrebuildSettings.BranchStrategy)} - > - - - - +
+
+ + setPrebuildInterval(target.value)} + /> +
+ The number of commits to be skipped between prebuild runs. +
+
+
+
+ setPrebuildBranchStrategy(val as PrebuildSettings.BranchStrategy)} + > + + + + +
+ Run prebuilds on the selected branches only. +
+
{prebuildSettings.branchStrategy === "matched-branches" && (
- Learn more - - - } - disabled={!prebuildSettings.enable} - checked={project.settings?.useIncrementalPrebuilds ?? false} - onChange={(checked) => updateProjectSettings({ useIncrementalPrebuilds: checked })} - /> - updateProjectSettings({ keepOutdatedPrebuildsRunning: !checked })} - /> - - Use Last Successful Prebuild{" "} - - Alpha - - - } - hint="Skip waiting for prebuilds in progress and use the last successful prebuild from previous - commits on the same branch." - disabled={!prebuildSettings.enable} - checked={!!project.settings?.allowUsingPreviousPrebuilds} - onChange={(checked) => - updateProjectSettings({ - allowUsingPreviousPrebuilds: checked, - // we are disabling prebuild cancellation when incremental workspaces are enabled - keepOutdatedPrebuildsRunning: - checked || project?.settings?.keepOutdatedPrebuildsRunning, - }) - } - /> -
-
- - setPrebuildInterval(target.value)} - /> -
- The number of commits to be skipped between prebuild runs. -
+
+ Use a smaller machine type for cost optimization.
-
+ )}
diff --git a/components/dashboard/src/service/public-api.ts b/components/dashboard/src/service/public-api.ts index 8b2e3efcd3b36a..e416363a475aab 100644 --- a/components/dashboard/src/service/public-api.ts +++ b/components/dashboard/src/service/public-api.ts @@ -107,9 +107,6 @@ export function projectToProtocol(project: Project): ProtocolProject { teamId: project.teamId, appInstallationId: "undefined", settings: { - allowUsingPreviousPrebuilds: project.settings?.prebuild?.usePreviousPrebuilds, - keepOutdatedPrebuildsRunning: project.settings?.prebuild?.keepOutdatedPrebuildsRunning, - useIncrementalPrebuilds: project.settings?.prebuild?.enableIncrementalPrebuilds, workspaceClasses: { regular: project.settings?.workspace?.workspaceClass?.regular || "", }, diff --git a/components/dashboard/src/workspaces/CreateWorkspacePage.tsx b/components/dashboard/src/workspaces/CreateWorkspacePage.tsx index d64dbbb52fc866..4ece679127efd8 100644 --- a/components/dashboard/src/workspaces/CreateWorkspacePage.tsx +++ b/components/dashboard/src/workspaces/CreateWorkspacePage.tsx @@ -172,7 +172,6 @@ export function CreateWorkspacePage() { // we already have shown running workspaces to the user opts.ignoreRunningWorkspaceOnSameCommit = true; - opts.ignoreRunningPrebuild = true; // if user received an INVALID_GITPOD_YML yml for their contextURL they can choose to proceed using default configuration if (workspaceContext.error?.code === ErrorCodes.INVALID_GITPOD_YML) { diff --git a/components/gitpod-protocol/go/gitpod-service.go b/components/gitpod-protocol/go/gitpod-service.go index c7e8ccbc0ac9f2..a471272f28ce2a 100644 --- a/components/gitpod-protocol/go/gitpod-service.go +++ b/components/gitpod-protocol/go/gitpod-service.go @@ -1678,19 +1678,9 @@ type Repository struct { // WorkspaceCreationResult is the WorkspaceCreationResult message type type WorkspaceCreationResult struct { - CreatedWorkspaceID string `json:"createdWorkspaceId,omitempty"` - ExistingWorkspaces []*WorkspaceInfo `json:"existingWorkspaces,omitempty"` - RunningPrebuildWorkspaceID string `json:"runningPrebuildWorkspaceID,omitempty"` - RunningWorkspacePrebuild *RunningWorkspacePrebuild `json:"runningWorkspacePrebuild,omitempty"` - WorkspaceURL string `json:"workspaceURL,omitempty"` -} - -// RunningWorkspacePrebuild is the RunningWorkspacePrebuild message type -type RunningWorkspacePrebuild struct { - PrebuildID string `json:"prebuildID,omitempty"` - SameCluster bool `json:"sameCluster,omitempty"` - Starting string `json:"starting,omitempty"` - WorkspaceID string `json:"workspaceID,omitempty"` + CreatedWorkspaceID string `json:"createdWorkspaceId,omitempty"` + ExistingWorkspaces []*WorkspaceInfo `json:"existingWorkspaces,omitempty"` + WorkspaceURL string `json:"workspaceURL,omitempty"` } // Workspace is the Workspace message type @@ -2027,8 +2017,6 @@ type CreateWorkspaceOptions struct { ContextURL string `json:"contextUrl,omitempty"` OrganizationId string `json:"organizationId,omitempty"` IgnoreRunningWorkspaceOnSameCommit bool `json:"ignoreRunningWorkspaceOnSameCommit,omitemopty"` - IgnoreRunningPrebuild bool `json:"ignoreRunningPrebuild,omitemopty"` - AllowUsingPreviousPrebuilds bool `json:"allowUsingPreviousPrebuilds,omitemopty"` ForceDefaultConfig bool `json:"forceDefaultConfig,omitemopty"` } @@ -2291,12 +2279,9 @@ type Project struct { } type ProjectSettings struct { - UseIncrementalPrebuilds bool `json:"useIncrementalPrebuilds,omitempty"` - UsePersistentVolumeClaim bool `json:"usePersistentVolumeClaim,omitempty"` - KeepOutdatedPrebuildsRunning bool `json:"keepOutdatedPrebuildsRunning,omitempty"` - AllowUsingPreviousPrebuilds bool `json:"allowUsingPreviousPrebuilds,omitempty"` - WorkspaceClasses *WorkspaceClassesSettings `json:"workspaceClasses,omitempty"` - PrebuildSettings *PrebuildSettings `json:"prebuilds,omitempty"` + UsePersistentVolumeClaim bool `json:"usePersistentVolumeClaim,omitempty"` + WorkspaceClasses *WorkspaceClassesSettings `json:"workspaceClasses,omitempty"` + PrebuildSettings *PrebuildSettings `json:"prebuilds,omitempty"` } type PrebuildSettings struct { Enable *bool `json:"enable,omitempty"` diff --git a/components/gitpod-protocol/src/gitpod-service.ts b/components/gitpod-protocol/src/gitpod-service.ts index 88633a78129b21..ebd6b624314e34 100644 --- a/components/gitpod-protocol/src/gitpod-service.ts +++ b/components/gitpod-protocol/src/gitpod-service.ts @@ -424,8 +424,6 @@ export namespace GitpodServer { // whether running workspaces on the same context should be ignored. If false (default) users will be asked. //TODO(se) remove this option and let clients do that check if they like. The new create workspace page does it already ignoreRunningWorkspaceOnSameCommit?: boolean; - ignoreRunningPrebuild?: boolean; - allowUsingPreviousPrebuilds?: boolean; forceDefaultConfig?: boolean; } diff --git a/components/gitpod-protocol/src/protocol.ts b/components/gitpod-protocol/src/protocol.ts index 976b1f96225286..b21fdeb6716d10 100644 --- a/components/gitpod-protocol/src/protocol.ts +++ b/components/gitpod-protocol/src/protocol.ts @@ -1500,16 +1500,7 @@ export interface WorkspaceCreationResult { createdWorkspaceId?: string; workspaceURL?: string; existingWorkspaces?: WorkspaceInfo[]; - runningWorkspacePrebuild?: { - prebuildID: string; - workspaceID: string; - instanceID: string; - starting: RunningWorkspacePrebuildStarting; - sameCluster: boolean; - }; - runningPrebuildWorkspaceID?: string; } -export type RunningWorkspacePrebuildStarting = "queued" | "starting" | "running"; export namespace WorkspaceCreationResult { export function is(data: any): data is WorkspaceCreationResult { diff --git a/components/gitpod-protocol/src/teams-projects-protocol.ts b/components/gitpod-protocol/src/teams-projects-protocol.ts index e67b82abe34b7e..897a63c7f1934e 100644 --- a/components/gitpod-protocol/src/teams-projects-protocol.ts +++ b/components/gitpod-protocol/src/teams-projects-protocol.ts @@ -36,17 +36,28 @@ export interface ProjectSettings { * @deprecated see `Project.settings.prebuilds.branchMatchingPattern` instead. */ prebuildBranchPattern?: string; - - useIncrementalPrebuilds?: boolean; - keepOutdatedPrebuildsRunning?: boolean; - // whether new workspaces can start on older prebuilds and incrementally update - allowUsingPreviousPrebuilds?: boolean; /** * how many commits in the commit history a prebuild is good (undefined and 0 means every commit is prebuilt) * * @deprecated see `Project.settings.prebuilds.intervall` instead. */ prebuildEveryNthCommit?: number; + + /** + * @deprecated always false + */ + useIncrementalPrebuilds?: boolean; + + /** + * @deprecated always true (we should kill dangling prebuilds) + */ + keepOutdatedPrebuildsRunning?: boolean; + // whether new workspaces can start on older prebuilds and incrementally update + /** + * @deprecated always true + */ + allowUsingPreviousPrebuilds?: boolean; + // preferred workspace classes workspaceClasses?: WorkspaceClasses; } @@ -58,7 +69,7 @@ export interface PrebuildSettings { enable?: boolean; /** - * Defines an interval of commits to run new prebuilds for. Defaults to 10 + * Defines an interval of commits to run new prebuilds for. Defaults to 20 */ prebuildInterval?: number; @@ -113,7 +124,7 @@ export namespace Project { export const PREBUILD_SETTINGS_DEFAULTS: PrebuildSettingsWithDefaults = { enable: false, branchMatchingPattern: "**", - prebuildInterval: 10, + prebuildInterval: 20, branchStrategy: "all-branches", }; diff --git a/components/public-api-server/pkg/apiv1/project.go b/components/public-api-server/pkg/apiv1/project.go index 6afea2d5e684da..b1380c5e99a83b 100644 --- a/components/public-api-server/pkg/apiv1/project.go +++ b/components/public-api-server/pkg/apiv1/project.go @@ -168,14 +168,9 @@ func projectSettingsToAPIResponse(s *protocol.ProjectSettings) *v1.ProjectSettin } settings := &v1.ProjectSettings{ - Prebuild: &v1.PrebuildSettings{ - EnableIncrementalPrebuilds: s.UseIncrementalPrebuilds, - KeepOutdatedPrebuildsRunning: s.KeepOutdatedPrebuildsRunning, - UsePreviousPrebuilds: s.AllowUsingPreviousPrebuilds, - }, + Prebuild: &v1.PrebuildSettings{}, Workspace: &v1.WorkspaceSettings{ - EnablePersistentVolumeClaim: s.UsePersistentVolumeClaim, - WorkspaceClass: workspaceClassesToAPIResponse(s.WorkspaceClasses), + WorkspaceClass: workspaceClassesToAPIResponse(s.WorkspaceClasses), }, } if s.PrebuildSettings != nil { diff --git a/components/public-api-server/pkg/apiv1/project_test.go b/components/public-api-server/pkg/apiv1/project_test.go index f38eefa9790de4..4c7c760db17b8f 100644 --- a/components/public-api-server/pkg/apiv1/project_test.go +++ b/components/public-api-server/pkg/apiv1/project_test.go @@ -336,10 +336,7 @@ func newProject(p *protocol.Project) *protocol.Project { CloneURL: "https://github.com/easyCZ/foobar", AppInstallationID: "1337", Settings: &protocol.ProjectSettings{ - UseIncrementalPrebuilds: true, - UsePersistentVolumeClaim: true, - KeepOutdatedPrebuildsRunning: true, - AllowUsingPreviousPrebuilds: true, + UsePersistentVolumeClaim: true, WorkspaceClasses: &protocol.WorkspaceClassesSettings{ Regular: "default", Prebuild: "default", diff --git a/components/public-api/gitpod/experimental/v1/projects.proto b/components/public-api/gitpod/experimental/v1/projects.proto index a4e9aa635289e0..1fe6b7b0e8d8dd 100644 --- a/components/public-api/gitpod/experimental/v1/projects.proto +++ b/components/public-api/gitpod/experimental/v1/projects.proto @@ -43,9 +43,9 @@ message ProjectSettings { } message PrebuildSettings { - bool enable_incremental_prebuilds = 1; - bool keep_outdated_prebuilds_running = 2; - bool use_previous_prebuilds = 3; + reserved 1; // enable_incremental_prebuilds + reserved 2; // keep_outdated_prebuilds_running + reserved 3; // use_previous_prebuilds reserved 4; // was prebuild_every_nth optional bool enable_prebuilds = 5; reserved 6; // was prebuild_default_branch_only diff --git a/components/public-api/go/experimental/v1/projects.pb.go b/components/public-api/go/experimental/v1/projects.pb.go index b18b7a3c04eecb..fc8bb5b7214b37 100644 --- a/components/public-api/go/experimental/v1/projects.pb.go +++ b/components/public-api/go/experimental/v1/projects.pb.go @@ -183,14 +183,11 @@ type PrebuildSettings struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - EnableIncrementalPrebuilds bool `protobuf:"varint,1,opt,name=enable_incremental_prebuilds,json=enableIncrementalPrebuilds,proto3" json:"enable_incremental_prebuilds,omitempty"` - KeepOutdatedPrebuildsRunning bool `protobuf:"varint,2,opt,name=keep_outdated_prebuilds_running,json=keepOutdatedPrebuildsRunning,proto3" json:"keep_outdated_prebuilds_running,omitempty"` - UsePreviousPrebuilds bool `protobuf:"varint,3,opt,name=use_previous_prebuilds,json=usePreviousPrebuilds,proto3" json:"use_previous_prebuilds,omitempty"` - EnablePrebuilds *bool `protobuf:"varint,5,opt,name=enable_prebuilds,json=enablePrebuilds,proto3,oneof" json:"enable_prebuilds,omitempty"` - BranchMatchingPattern *string `protobuf:"bytes,7,opt,name=branch_matching_pattern,json=branchMatchingPattern,proto3,oneof" json:"branch_matching_pattern,omitempty"` - BranchStrategy *string `protobuf:"bytes,8,opt,name=branch_strategy,json=branchStrategy,proto3,oneof" json:"branch_strategy,omitempty"` - PrebuildInterval *int32 `protobuf:"varint,9,opt,name=prebuild_interval,json=prebuildInterval,proto3,oneof" json:"prebuild_interval,omitempty"` - WorkspaceClass *string `protobuf:"bytes,10,opt,name=workspace_class,json=workspaceClass,proto3,oneof" json:"workspace_class,omitempty"` + EnablePrebuilds *bool `protobuf:"varint,5,opt,name=enable_prebuilds,json=enablePrebuilds,proto3,oneof" json:"enable_prebuilds,omitempty"` + BranchMatchingPattern *string `protobuf:"bytes,7,opt,name=branch_matching_pattern,json=branchMatchingPattern,proto3,oneof" json:"branch_matching_pattern,omitempty"` + BranchStrategy *string `protobuf:"bytes,8,opt,name=branch_strategy,json=branchStrategy,proto3,oneof" json:"branch_strategy,omitempty"` + PrebuildInterval *int32 `protobuf:"varint,9,opt,name=prebuild_interval,json=prebuildInterval,proto3,oneof" json:"prebuild_interval,omitempty"` + WorkspaceClass *string `protobuf:"bytes,10,opt,name=workspace_class,json=workspaceClass,proto3,oneof" json:"workspace_class,omitempty"` } func (x *PrebuildSettings) Reset() { @@ -225,27 +222,6 @@ func (*PrebuildSettings) Descriptor() ([]byte, []int) { return file_gitpod_experimental_v1_projects_proto_rawDescGZIP(), []int{2} } -func (x *PrebuildSettings) GetEnableIncrementalPrebuilds() bool { - if x != nil { - return x.EnableIncrementalPrebuilds - } - return false -} - -func (x *PrebuildSettings) GetKeepOutdatedPrebuildsRunning() bool { - if x != nil { - return x.KeepOutdatedPrebuildsRunning - } - return false -} - -func (x *PrebuildSettings) GetUsePreviousPrebuilds() bool { - if x != nil { - return x.UsePreviousPrebuilds - } - return false -} - func (x *PrebuildSettings) GetEnablePrebuilds() bool { if x != nil && x.EnablePrebuilds != nil { return *x.EnablePrebuilds @@ -813,132 +789,121 @@ var file_gitpod_experimental_v1_projects_proto_rawDesc = []byte{ 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x09, 0x77, 0x6f, 0x72, 0x6b, 0x73, - 0x70, 0x61, 0x63, 0x65, 0x22, 0xc7, 0x04, 0x0a, 0x10, 0x50, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, - 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x40, 0x0a, 0x1c, 0x65, 0x6e, 0x61, - 0x62, 0x6c, 0x65, 0x5f, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x5f, - 0x70, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x1a, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, - 0x61, 0x6c, 0x50, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x12, 0x45, 0x0a, 0x1f, 0x6b, - 0x65, 0x65, 0x70, 0x5f, 0x6f, 0x75, 0x74, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x70, 0x72, 0x65, - 0x62, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x5f, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x6b, 0x65, 0x65, 0x70, 0x4f, 0x75, 0x74, 0x64, 0x61, 0x74, - 0x65, 0x64, 0x50, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x52, 0x75, 0x6e, 0x6e, 0x69, - 0x6e, 0x67, 0x12, 0x34, 0x0a, 0x16, 0x75, 0x73, 0x65, 0x5f, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, - 0x75, 0x73, 0x5f, 0x70, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x14, 0x75, 0x73, 0x65, 0x50, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x50, - 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x12, 0x2e, 0x0a, 0x10, 0x65, 0x6e, 0x61, 0x62, - 0x6c, 0x65, 0x5f, 0x70, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x08, 0x48, 0x00, 0x52, 0x0f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x72, 0x65, 0x62, - 0x75, 0x69, 0x6c, 0x64, 0x73, 0x88, 0x01, 0x01, 0x12, 0x3b, 0x0a, 0x17, 0x62, 0x72, 0x61, 0x6e, - 0x63, 0x68, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x5f, 0x70, 0x61, 0x74, 0x74, - 0x65, 0x72, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x15, 0x62, 0x72, 0x61, - 0x6e, 0x63, 0x68, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x50, 0x61, 0x74, 0x74, 0x65, - 0x72, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x2c, 0x0a, 0x0f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x5f, - 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02, - 0x52, 0x0e, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, - 0x88, 0x01, 0x01, 0x12, 0x30, 0x0a, 0x11, 0x70, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x48, 0x03, - 0x52, 0x10, 0x70, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, - 0x61, 0x6c, 0x88, 0x01, 0x01, 0x12, 0x2c, 0x0a, 0x0f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, - 0x63, 0x65, 0x5f, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x48, 0x04, - 0x52, 0x0e, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, - 0x88, 0x01, 0x01, 0x42, 0x13, 0x0a, 0x11, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x70, - 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x42, 0x1a, 0x0a, 0x18, 0x5f, 0x62, 0x72, 0x61, + 0x70, 0x61, 0x63, 0x65, 0x22, 0x9a, 0x03, 0x0a, 0x10, 0x50, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, + 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x2e, 0x0a, 0x10, 0x65, 0x6e, 0x61, + 0x62, 0x6c, 0x65, 0x5f, 0x70, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x72, 0x65, + 0x62, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x88, 0x01, 0x01, 0x12, 0x3b, 0x0a, 0x17, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x5f, 0x70, 0x61, 0x74, - 0x74, 0x65, 0x72, 0x6e, 0x42, 0x12, 0x0a, 0x10, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x5f, - 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x42, 0x14, 0x0a, 0x12, 0x5f, 0x70, 0x72, 0x65, - 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x42, 0x12, - 0x0a, 0x10, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x63, 0x6c, 0x61, - 0x73, 0x73, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x22, 0xb1, - 0x01, 0x0a, 0x11, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, - 0x69, 0x6e, 0x67, 0x73, 0x12, 0x43, 0x0a, 0x1e, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x70, - 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, - 0x5f, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1b, 0x65, 0x6e, - 0x61, 0x62, 0x6c, 0x65, 0x50, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x74, 0x56, 0x6f, - 0x6c, 0x75, 0x6d, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x12, 0x57, 0x0a, 0x0f, 0x77, 0x6f, 0x72, - 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, - 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, - 0x73, 0x70, 0x61, 0x63, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, - 0x67, 0x73, 0x52, 0x0e, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x43, 0x6c, 0x61, - 0x73, 0x73, 0x22, 0x4e, 0x0a, 0x16, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x43, - 0x6c, 0x61, 0x73, 0x73, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x18, 0x0a, 0x07, - 0x72, 0x65, 0x67, 0x75, 0x6c, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, - 0x65, 0x67, 0x75, 0x6c, 0x61, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x65, 0x62, 0x75, 0x69, - 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x65, 0x62, 0x75, 0x69, - 0x6c, 0x64, 0x22, 0x51, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, - 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x39, 0x0a, 0x07, 0x70, 0x72, - 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x67, 0x69, - 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, - 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x70, 0x72, - 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0x52, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, - 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x39, - 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1f, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, - 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, - 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0x32, 0x0a, 0x11, 0x47, 0x65, 0x74, - 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, - 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x22, 0x4f, 0x0a, - 0x12, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x39, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, - 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, - 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0x78, - 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x74, 0x65, 0x61, 0x6d, 0x5f, 0x69, 0x64, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x65, 0x61, 0x6d, 0x49, 0x64, 0x12, 0x42, - 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, - 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x67, 0x69, - 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x22, 0x78, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, - 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x3b, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x74, 0x65, 0x72, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x15, 0x62, 0x72, + 0x61, 0x6e, 0x63, 0x68, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x50, 0x61, 0x74, 0x74, + 0x65, 0x72, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x2c, 0x0a, 0x0f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, + 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x48, + 0x02, 0x52, 0x0e, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, + 0x79, 0x88, 0x01, 0x01, 0x12, 0x30, 0x0a, 0x11, 0x70, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, + 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x48, + 0x03, 0x52, 0x10, 0x70, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x74, 0x65, 0x72, + 0x76, 0x61, 0x6c, 0x88, 0x01, 0x01, 0x12, 0x2c, 0x0a, 0x0f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x5f, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x48, + 0x04, 0x52, 0x0e, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x43, 0x6c, 0x61, 0x73, + 0x73, 0x88, 0x01, 0x01, 0x42, 0x13, 0x0a, 0x11, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, + 0x70, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x42, 0x1a, 0x0a, 0x18, 0x5f, 0x62, 0x72, + 0x61, 0x6e, 0x63, 0x68, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x5f, 0x70, 0x61, + 0x74, 0x74, 0x65, 0x72, 0x6e, 0x42, 0x12, 0x0a, 0x10, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, + 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x42, 0x14, 0x0a, 0x12, 0x5f, 0x70, 0x72, + 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x42, + 0x12, 0x0a, 0x10, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x63, 0x6c, + 0x61, 0x73, 0x73, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x4a, + 0x04, 0x08, 0x03, 0x10, 0x04, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x06, 0x10, + 0x07, 0x22, 0xb1, 0x01, 0x0a, 0x11, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, + 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x43, 0x0a, 0x1e, 0x65, 0x6e, 0x61, 0x62, 0x6c, + 0x65, 0x5f, 0x70, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x76, 0x6f, 0x6c, + 0x75, 0x6d, 0x65, 0x5f, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x1b, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6e, + 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x12, 0x57, 0x0a, 0x0f, + 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, + 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x57, + 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x53, 0x65, 0x74, + 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x0e, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x43, 0x6c, 0x61, 0x73, 0x73, 0x22, 0x4e, 0x0a, 0x16, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, + 0x18, 0x0a, 0x07, 0x72, 0x65, 0x67, 0x75, 0x6c, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x72, 0x65, 0x67, 0x75, 0x6c, 0x61, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x65, + 0x62, 0x75, 0x69, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x65, + 0x62, 0x75, 0x69, 0x6c, 0x64, 0x22, 0x51, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, + 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x39, 0x0a, + 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, + 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, + 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, + 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0x52, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x39, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x6a, - 0x65, 0x63, 0x74, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x23, 0x0a, - 0x0d, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x75, 0x6c, - 0x74, 0x73, 0x22, 0x35, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, - 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, - 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x22, 0x17, 0x0a, 0x15, 0x44, 0x65, 0x6c, - 0x65, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x32, 0xc5, 0x03, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6e, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x2c, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, + 0x65, 0x63, 0x74, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0x32, 0x0a, 0x11, + 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, + 0x22, 0x4f, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x39, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, + 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, + 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, + 0x74, 0x22, 0x78, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x74, 0x65, 0x61, 0x6d, + 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x65, 0x61, 0x6d, 0x49, + 0x64, 0x12, 0x42, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, + 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, + 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x22, 0x78, 0x0a, 0x14, 0x4c, + 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, + 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, + 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, + 0x12, 0x23, 0x0a, 0x0d, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x65, + 0x73, 0x75, 0x6c, 0x74, 0x73, 0x22, 0x35, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, + 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, + 0x0a, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x22, 0x17, 0x0a, 0x15, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xc5, 0x03, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, + 0x74, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6e, 0x0a, 0x0d, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x2c, 0x2e, 0x67, 0x69, 0x74, + 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, + 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, + 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, + 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x65, 0x0a, 0x0a, 0x47, 0x65, 0x74, + 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x29, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, - 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, - 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x65, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, - 0x6a, 0x65, 0x63, 0x74, 0x12, 0x29, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, - 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, - 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x2a, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, - 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6a, - 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6b, 0x0a, - 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x2b, 0x2e, + 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, + 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, + 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x6b, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, + 0x12, 0x2b, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, + 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, - 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x67, 0x69, 0x74, - 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, - 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6e, 0x0a, 0x0d, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x2c, 0x2e, 0x67, 0x69, - 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, - 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, - 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x67, 0x69, 0x74, 0x70, - 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2e, - 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x46, 0x5a, 0x44, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2d, - 0x69, 0x6f, 0x2f, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, - 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x2d, 0x61, 0x70, 0x69, 0x2f, - 0x67, 0x6f, 0x2f, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x2f, - 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6e, 0x0a, + 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x2c, + 0x2e, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, + 0x6e, 0x74, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x67, + 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, + 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, + 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x46, 0x5a, + 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x69, 0x74, 0x70, + 0x6f, 0x64, 0x2d, 0x69, 0x6f, 0x2f, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2f, 0x63, 0x6f, 0x6d, + 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x2d, 0x61, + 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, + 0x61, 0x6c, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/components/public-api/typescript/src/gitpod/experimental/v1/projects_pb.ts b/components/public-api/typescript/src/gitpod/experimental/v1/projects_pb.ts index 5f442e3d23f6b9..170281b0209058 100644 --- a/components/public-api/typescript/src/gitpod/experimental/v1/projects_pb.ts +++ b/components/public-api/typescript/src/gitpod/experimental/v1/projects_pb.ts @@ -144,21 +144,6 @@ export class ProjectSettings extends Message { * @generated from message gitpod.experimental.v1.PrebuildSettings */ export class PrebuildSettings extends Message { - /** - * @generated from field: bool enable_incremental_prebuilds = 1; - */ - enableIncrementalPrebuilds = false; - - /** - * @generated from field: bool keep_outdated_prebuilds_running = 2; - */ - keepOutdatedPrebuildsRunning = false; - - /** - * @generated from field: bool use_previous_prebuilds = 3; - */ - usePreviousPrebuilds = false; - /** * @generated from field: optional bool enable_prebuilds = 5; */ @@ -192,9 +177,6 @@ export class PrebuildSettings extends Message { static readonly runtime = proto3; static readonly typeName = "gitpod.experimental.v1.PrebuildSettings"; static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "enable_incremental_prebuilds", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, - { no: 2, name: "keep_outdated_prebuilds_running", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, - { no: 3, name: "use_previous_prebuilds", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, { no: 5, name: "enable_prebuilds", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true }, { no: 7, name: "branch_matching_pattern", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, { no: 8, name: "branch_strategy", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, diff --git a/components/server/src/config.ts b/components/server/src/config.ts index 2bd962386943ef..ba5e114c6f53a3 100644 --- a/components/server/src/config.ts +++ b/components/server/src/config.ts @@ -149,11 +149,6 @@ export interface ConfigSerialized { /** maxConcurrentPrebuildsPerRef is the maximum number of prebuilds we allow per ref type at any given time */ maxConcurrentPrebuildsPerRef: number; - incrementalPrebuilds: { - repositoryPasslist: string[]; - commitHistory: number; - }; - blockNewUsers: { enabled: boolean; passlist: string[]; diff --git a/components/server/src/container-module.ts b/components/server/src/container-module.ts index 05f2f2c3183672..fde10a6926bbb1 100644 --- a/components/server/src/container-module.ts +++ b/components/server/src/container-module.ts @@ -85,7 +85,7 @@ import { GithubApp } from "./prebuilds/github-app"; import { GithubAppRules } from "./prebuilds/github-app-rules"; import { GitHubEnterpriseApp } from "./prebuilds/github-enterprise-app"; import { GitLabApp } from "./prebuilds/gitlab-app"; -import { IncrementalPrebuildsService } from "./prebuilds/incremental-prebuilds-service"; +import { IncrementalWorkspaceService } from "./prebuilds/incremental-workspace-service"; import { PrebuildManager } from "./prebuilds/prebuild-manager"; import { PrebuildStatusMaintainer } from "./prebuilds/prebuilt-status-maintainer"; import { ProjectsService } from "./projects/projects-service"; @@ -343,7 +343,7 @@ export const productionContainerModule = new ContainerModule( bind(BitbucketAppSupport).toSelf().inSingletonScope(); bind(GitHubEnterpriseApp).toSelf().inSingletonScope(); bind(BitbucketServerApp).toSelf().inSingletonScope(); - bind(IncrementalPrebuildsService).toSelf().inSingletonScope(); + bind(IncrementalWorkspaceService).toSelf().inSingletonScope(); // payment/billing bind(StripeService).toSelf().inSingletonScope(); diff --git a/components/server/src/prebuilds/incremental-prebuilds-service.ts b/components/server/src/prebuilds/incremental-workspace-service.ts similarity index 92% rename from components/server/src/prebuilds/incremental-prebuilds-service.ts rename to components/server/src/prebuilds/incremental-workspace-service.ts index cdfc37023feaea..abbbf724d0f639 100644 --- a/components/server/src/prebuilds/incremental-prebuilds-service.ts +++ b/components/server/src/prebuilds/incremental-workspace-service.ts @@ -22,8 +22,10 @@ import { ConfigProvider } from "../workspace/config-provider"; import { HostContextProvider } from "../auth/host-context-provider"; import { ImageSourceProvider } from "../workspace/image-source-provider"; +const MAX_HISTORY_DEPTH = 100; + @injectable() -export class IncrementalPrebuildsService { +export class IncrementalWorkspaceService { @inject(Config) protected readonly config: Config; @inject(ConfigProvider) protected readonly configProvider: ConfigProvider; @inject(HostContextProvider) protected readonly hostContextProvider: HostContextProvider; @@ -31,7 +33,7 @@ export class IncrementalPrebuildsService { @inject(WorkspaceDB) protected readonly workspaceDB: WorkspaceDB; public async getCommitHistoryForContext(context: CommitContext, user: User): Promise { - const maxDepth = this.config.incrementalPrebuilds.commitHistory; + const maxDepth = MAX_HISTORY_DEPTH; const hostContext = this.hostContextProvider.get(context.repository.host); const repoProvider = hostContext?.services?.repositoryProvider; if (!repoProvider) { @@ -45,6 +47,7 @@ export class IncrementalPrebuildsService { context.revision, maxDepth, ); + history.commitHistory.unshift(context.revision); if (context.additionalRepositoryCheckoutInfo && context.additionalRepositoryCheckoutInfo.length > 0) { const histories = context.additionalRepositoryCheckoutInfo.map(async (info) => { const commitHistory = await repoProvider.getCommitHistory( @@ -54,6 +57,7 @@ export class IncrementalPrebuildsService { info.revision, maxDepth, ); + commitHistory.unshift(info.revision); return { cloneUrl: info.repository.cloneUrl, commitHistory, @@ -75,14 +79,15 @@ export class IncrementalPrebuildsService { return; } - const imageSource = await this.imageSourceProvider.getImageSource({}, user, context, config); + const imageSourcePromise = this.imageSourceProvider.getImageSource({}, user, context, config); // Note: This query returns only not-garbage-collected prebuilds in order to reduce cardinality // (e.g., at the time of writing, the Gitpod repository has 16K+ prebuilds, but only ~300 not-garbage-collected) const recentPrebuilds = await this.workspaceDB.findPrebuildsWithWorkspace(projectId); + const imageSource = await imageSourcePromise; for (const recentPrebuild of recentPrebuilds) { if ( - await this.isGoodBaseforIncrementalBuild( + this.isGoodBaseforIncrementalBuild( history, config, imageSource, @@ -93,15 +98,16 @@ export class IncrementalPrebuildsService { return recentPrebuild.prebuild; } } + return undefined; } - protected async isGoodBaseforIncrementalBuild( + private isGoodBaseforIncrementalBuild( history: WithCommitHistory, config: WorkspaceConfig, imageSource: WorkspaceImageSource, candidatePrebuild: PrebuiltWorkspace, candidateWorkspace: Workspace, - ): Promise { + ): boolean { if (!history.commitHistory || history.commitHistory.length === 0) { return false; } diff --git a/components/server/src/prebuilds/prebuild-manager.spec.ts b/components/server/src/prebuilds/prebuild-manager.spec.ts index d357d53cec6309..2f196817ee3173 100644 --- a/components/server/src/prebuilds/prebuild-manager.spec.ts +++ b/components/server/src/prebuilds/prebuild-manager.spec.ts @@ -14,7 +14,7 @@ import { HostContextProvider } from "../auth/host-context-provider"; import { ConfigProvider } from "../workspace/config-provider"; import { Config } from "../config"; import { ProjectsService } from "../projects/projects-service"; -import { IncrementalPrebuildsService } from "./incremental-prebuilds-service"; +import { IncrementalWorkspaceService } from "./incremental-workspace-service"; import { EntitlementService } from "../billing/entitlement-service"; import { CommitContext, Project, ProjectSettings, Repository, WorkspaceConfig } from "@gitpod/gitpod-protocol"; @@ -30,7 +30,7 @@ const containerModule = new ContainerModule((bind) => { bind(ConfigProvider).toConstantValue({} as any); bind(Config).toConstantValue({} as any); bind(ProjectsService).toConstantValue({} as any); - bind(IncrementalPrebuildsService).toConstantValue({} as any); + bind(IncrementalWorkspaceService).toConstantValue({} as any); bind(EntitlementService).toConstantValue({} as any); // #endregion }); diff --git a/components/server/src/prebuilds/prebuild-manager.ts b/components/server/src/prebuilds/prebuild-manager.ts index e17ebe3a461b74..2627717ef03e71 100644 --- a/components/server/src/prebuilds/prebuild-manager.ts +++ b/components/server/src/prebuilds/prebuild-manager.ts @@ -28,9 +28,7 @@ import { secondsBefore } from "@gitpod/gitpod-protocol/lib/util/timeutil"; import { inject, injectable } from "inversify"; import * as opentracing from "opentracing"; -import { StopWorkspacePolicy } from "@gitpod/ws-manager/lib"; -import { error } from "console"; -import { IncrementalPrebuildsService } from "./incremental-prebuilds-service"; +import { IncrementalWorkspaceService } from "./incremental-workspace-service"; import { PrebuildRateLimiterConfig } from "../workspace/prebuild-rate-limiter"; import { ErrorCodes, ApplicationError } from "@gitpod/gitpod-protocol/lib/messaging/error"; import { EntitlementService, MayStartWorkspaceResult } from "../billing/entitlement-service"; @@ -53,48 +51,16 @@ export interface StartPrebuildParams { @injectable() export class PrebuildManager { - @inject(TracedWorkspaceDB) protected readonly workspaceDB: DBWithTracing; - @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; - @inject(HostContextProvider) protected readonly hostContextProvider: HostContextProvider; - @inject(ConfigProvider) protected readonly configProvider: ConfigProvider; - @inject(Config) protected readonly config: Config; - @inject(ProjectsService) protected readonly projectService: ProjectsService; - @inject(IncrementalPrebuildsService) protected readonly incrementalPrebuildsService: IncrementalPrebuildsService; - @inject(EntitlementService) protected readonly entitlementService: EntitlementService; - - async abortPrebuildsForBranch(ctx: TraceContext, project: Project, user: User, branch: string): Promise { - const span = TraceContext.startSpan("abortPrebuildsForBranch", ctx); - try { - const prebuilds = await this.workspaceDB - .trace({ span }) - .findActivePrebuiltWorkspacesByBranch(project.id, branch); - const results: Promise[] = []; - for (const prebuild of prebuilds) { - try { - log.info( - { userId: user.id, workspaceId: prebuild.workspace.id }, - "Cancelling Prebuild workspace because a newer commit was pushed to the same branch.", - ); - results.push( - this.workspaceService.stopWorkspace( - user.id, - prebuild.workspace.id, - "prebuild cancelled because a newer commit was pushed to the same branch", - StopWorkspacePolicy.ABORT, - ), - ); - prebuild.prebuild.state = "aborted"; - prebuild.prebuild.error = "A newer commit was pushed to the same branch."; - results.push(this.workspaceDB.trace({ span }).storePrebuiltWorkspace(prebuild.prebuild)); - } catch (err) { - error("Cannot cancel prebuild", { prebuildID: prebuild.prebuild.id }, err); - } - } - await Promise.all(results); - } finally { - span.finish(); - } - } + constructor( + @inject(TracedWorkspaceDB) private readonly workspaceDB: DBWithTracing, + @inject(WorkspaceService) private readonly workspaceService: WorkspaceService, + @inject(HostContextProvider) private readonly hostContextProvider: HostContextProvider, + @inject(ConfigProvider) private readonly configProvider: ConfigProvider, + @inject(Config) private readonly config: Config, + @inject(ProjectsService) private readonly projectService: ProjectsService, + @inject(IncrementalWorkspaceService) private readonly incrementalPrebuildsService: IncrementalWorkspaceService, + @inject(EntitlementService) private readonly entitlementService: EntitlementService, + ) {} private async findNonFailedPrebuiltWorkspace(ctx: TraceContext, projectId: string, commitSHA: string) { const existingPB = await this.workspaceDB.trace(ctx).findPrebuiltWorkspaceByCommit(projectId, commitSHA); @@ -167,13 +133,6 @@ export class PrebuildManager { } } } - if (context.ref && !project.settings?.keepOutdatedPrebuildsRunning) { - try { - await this.abortPrebuildsForBranch({ span }, project, user, context.ref); - } catch (e) { - console.error("Error aborting prebuilds", e); - } - } const prebuildContext: StartPrebuildContext = { title: `Prebuild of "${context.title}"`, @@ -206,15 +165,6 @@ export class PrebuildManager { if (prebuild) { return { prebuildId: prebuild.id, wsid: prebuild.buildWorkspaceId, done: true }; } - } else if (this.shouldPrebuildIncrementally(project)) { - // We store the commit histories in the `StartPrebuildContext` in order to pass them down to - // `WorkspaceFactoryEE.createForStartPrebuild`. - if (commitHistory) { - prebuildContext.commitHistory = commitHistory; - } - if (additionalRepositoryCommitHistories) { - prebuildContext.additionalRepositoryCommitHistories = additionalRepositoryCommitHistories; - } } const workspace = await this.workspaceService.createWorkspace( @@ -404,15 +354,6 @@ export class PrebuildManager { return { shouldRun: false, reason: "unknown-strategy" }; } - private shouldPrebuildIncrementally(project: Project): boolean { - if (project?.settings?.useIncrementalPrebuilds) { - return true; - } - const trimRepoUrl = (url: string) => url.replace(/\/$/, "").replace(/\.git$/, ""); - const repoUrl = trimRepoUrl(project.cloneUrl); - return this.config.incrementalPrebuilds.repositoryPasslist.some((url) => trimRepoUrl(url) === repoUrl); - } - async fetchConfig( ctx: TraceContext, user: User, diff --git a/components/server/src/projects/projects-service.spec.db.ts b/components/server/src/projects/projects-service.spec.db.ts index 157e0c17e4d793..32f7ca2aef95e9 100644 --- a/components/server/src/projects/projects-service.spec.db.ts +++ b/components/server/src/projects/projects-service.spec.db.ts @@ -214,6 +214,7 @@ describe("ProjectsService", async () => { ...Project.PREBUILD_SETTINGS_DEFAULTS, enable: false, }, + workspaceClasses: {}, }); }); @@ -238,10 +239,11 @@ describe("ProjectsService", async () => { ...Project.PREBUILD_SETTINGS_DEFAULTS, enable: false, }, + workspaceClasses: {}, }); }); - it.only("prebuild settings migration / new and active project / updated settings", async () => { + it("prebuild settings migration / new and active project / updated settings", async () => { const ps = container.get(ProjectsService); const cloneUrl = "https://github.com/gitpod-io/gitpod.git"; const oldProject = await createTestProject(ps, org, owner, { @@ -261,7 +263,7 @@ describe("ProjectsService", async () => { expect(project.settings).to.deep.equal({ prebuilds: { enable: true, - prebuildInterval: 13, + prebuildInterval: 20, workspaceClass: "ultra", branchStrategy: "matched-branches", branchMatchingPattern: "feature-*", diff --git a/components/server/src/projects/projects-service.ts b/components/server/src/projects/projects-service.ts index dd5082fc89937e..d632592f1314c3 100644 --- a/components/server/src/projects/projects-service.ts +++ b/components/server/src/projects/projects-service.ts @@ -411,58 +411,64 @@ export class ProjectsService { if (!!project.settings?.prebuilds) { return project; // already migrated } - - const logCtx: any = { oldSettings: { ...project.settings } }; - const newPrebuildSettings: PrebuildSettings = { enable: false }; - - // if workspaces were running in the past week - const isInactive = await this.isProjectConsideredInactive(SYSTEM_USER, project.id); - logCtx.isInactive = isInactive; - if (!isInactive) { - const sevenDaysAgo = new Date(daysBefore(new Date().toISOString(), 7)); - const count = await this.workspaceDb.trace({}).countUnabortedPrebuildsSince(project.id, sevenDaysAgo); - logCtx.count = count; - if (count > 0) { - const defaults = Project.PREBUILD_SETTINGS_DEFAULTS; - newPrebuildSettings.enable = true; - newPrebuildSettings.prebuildInterval = - project.settings?.prebuildEveryNthCommit || defaults.prebuildInterval; - newPrebuildSettings.branchStrategy = !!project.settings?.prebuildBranchPattern - ? "matched-branches" - : defaults.branchStrategy; - if (newPrebuildSettings.prebuildInterval! < defaults.prebuildInterval!) { - // limiting to default branch for short intervals, to avoid unwanted increase of costs. - newPrebuildSettings.branchStrategy = "default-branch"; + try { + const logCtx: any = { oldSettings: { ...project.settings } }; + const newPrebuildSettings: PrebuildSettings = { enable: false, ...Project.PREBUILD_SETTINGS_DEFAULTS }; + + // if workspaces were running in the past week + const isInactive = await this.isProjectConsideredInactive(SYSTEM_USER, project.id); + logCtx.isInactive = isInactive; + if (!isInactive) { + const sevenDaysAgo = new Date(daysBefore(new Date().toISOString(), 7)); + const count = await this.workspaceDb.trace({}).countUnabortedPrebuildsSince(project.id, sevenDaysAgo); + logCtx.count = count; + if (count > 0) { + const defaults = Project.PREBUILD_SETTINGS_DEFAULTS; + newPrebuildSettings.enable = true; + newPrebuildSettings.prebuildInterval = Math.max( + project.settings?.prebuildEveryNthCommit || 0, + defaults.prebuildInterval, + ); + + newPrebuildSettings.branchStrategy = !!project.settings?.prebuildBranchPattern + ? "matched-branches" + : defaults.branchStrategy; + newPrebuildSettings.branchMatchingPattern = + project.settings?.prebuildBranchPattern || defaults.branchMatchingPattern; + newPrebuildSettings.workspaceClass = project.settings?.workspaceClasses?.prebuild; } - newPrebuildSettings.branchMatchingPattern = - project.settings?.prebuildBranchPattern || defaults.branchMatchingPattern; - newPrebuildSettings.workspaceClass = project.settings?.workspaceClasses?.prebuild; } - } - // update new settings - project = (await this.projectDB.findProjectById(project.id))!; - if (!project) { - throw new ApplicationError(ErrorCodes.INTERNAL_SERVER_ERROR, "Not found"); - } - if (!!project.settings?.prebuilds) { - return project; // already migrated - } - const newSettings = { ...project.settings }; - project.settings = newSettings; - project.settings.prebuilds = newPrebuildSettings; - delete newSettings.enablePrebuilds; - delete newSettings.prebuildBranchPattern; - delete newSettings.prebuildDefaultBranchOnly; - delete newSettings.prebuildEveryNthCommit; - delete newSettings.workspaceClasses?.prebuild; - await this.projectDB.updateProject({ - id: project.id, - settings: project.settings, - }); - logCtx.newPrebuildSettings = newPrebuildSettings; - log.info("Prebuild settings migrated.", { projectId: project.id, logCtx }); + // update new settings + project = (await this.projectDB.findProjectById(project.id))!; + if (!project) { + throw new ApplicationError(ErrorCodes.INTERNAL_SERVER_ERROR, "Not found"); + } + if (!!project.settings?.prebuilds) { + return project; // already migrated + } + const newSettings = { ...project.settings }; + project.settings = newSettings; + project.settings.prebuilds = newPrebuildSettings; + delete newSettings.enablePrebuilds; + delete newSettings.prebuildBranchPattern; + delete newSettings.prebuildDefaultBranchOnly; + delete newSettings.prebuildEveryNthCommit; + delete newSettings.allowUsingPreviousPrebuilds; + delete newSettings.keepOutdatedPrebuildsRunning; + delete newSettings.useIncrementalPrebuilds; + delete newSettings.workspaceClasses?.prebuild; + await this.projectDB.updateProject({ + id: project.id, + settings: project.settings, + }); + logCtx.newPrebuildSettings = newPrebuildSettings; + log.info("Prebuild settings migrated.", { projectId: project.id, logCtx }); - return project; + return project; + } catch (error) { + log.error("Prebuild settings migration failed.", { projectId: project.id, error }); + return project; + } } } diff --git a/components/server/src/workspace/gitpod-server-impl.ts b/components/server/src/workspace/gitpod-server-impl.ts index 07c5db7a32e9a6..40583e9286d6a8 100644 --- a/components/server/src/workspace/gitpod-server-impl.ts +++ b/components/server/src/workspace/gitpod-server-impl.ts @@ -83,7 +83,6 @@ import { WorkspaceAndInstance, } from "@gitpod/gitpod-protocol/lib/admin-protocol"; import { ApplicationError, ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error"; -import { Cancelable } from "@gitpod/gitpod-protocol/lib/util/cancelable"; import { log, LogContext } from "@gitpod/gitpod-protocol/lib/util/logging"; import { InterfaceWithTraceContext, @@ -148,7 +147,7 @@ import { createCookielessId, maskIp } from "../analytics"; import { getExperimentsClientForBackend } from "@gitpod/gitpod-protocol/lib/experiments/configcat-server"; import { LinkedInService } from "../linkedin-service"; import { SnapshotService, WaitForSnapshotOptions } from "./snapshot-service"; -import { IncrementalPrebuildsService } from "../prebuilds/incremental-prebuilds-service"; +import { IncrementalWorkspaceService } from "../prebuilds/incremental-workspace-service"; import { PrebuildManager } from "../prebuilds/prebuild-manager"; import { GitHubAppSupport } from "../github/github-app-support"; import { GitLabAppSupport } from "../gitlab/gitlab-app-support"; @@ -206,7 +205,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { @inject(BitbucketAppSupport) private readonly bitbucketAppSupport: BitbucketAppSupport, @inject(PrebuildManager) private readonly prebuildManager: PrebuildManager, - @inject(IncrementalPrebuildsService) private readonly incrementalPrebuildsService: IncrementalPrebuildsService, + @inject(IncrementalWorkspaceService) private readonly incrementalPrebuildsService: IncrementalWorkspaceService, @inject(ConfigProvider) private readonly configProvider: ConfigProvider, @inject(WorkspaceService) private readonly workspaceService: WorkspaceService, @inject(SnapshotService) private readonly snapshotService: SnapshotService, @@ -341,9 +340,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { projectId: string, context: WorkspaceContext, organizationId?: string, - ignoreRunningPrebuild?: boolean, - allowUsingPreviousPrebuilds?: boolean, - ): Promise { + ): Promise { const ctx = TraceContext.childContext("findPrebuiltWorkspace", parentCtx); try { if (!(CommitContext.is(context) && context.repository.cloneUrl && context.revision)) { @@ -356,162 +353,44 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { const cloneUrl = context.repository.cloneUrl; let prebuiltWorkspace: PrebuiltWorkspace | undefined; const logPayload = { - allowUsingPreviousPrebuilds, - ignoreRunningPrebuild, cloneUrl, commit: commitSHAs, prebuiltWorkspace, }; if (OpenPrebuildContext.is(context)) { prebuiltWorkspace = await this.workspaceDb.trace(ctx).findPrebuildByID(context.openPrebuildID); - if ( - prebuiltWorkspace?.cloneURL !== cloneUrl && - (ignoreRunningPrebuild || prebuiltWorkspace?.state === "available") - ) { + if (prebuiltWorkspace?.cloneURL !== cloneUrl) { // prevent users from opening arbitrary prebuilds this way - they must match the clone URL so that the resource guards are correct. - return; + return undefined; } } else { log.debug(logCtx, "Looking for prebuilt workspace: ", logPayload); - prebuiltWorkspace = await this.workspaceDb - .trace(ctx) - .findPrebuiltWorkspaceByCommit(projectId, commitSHAs); - if (!prebuiltWorkspace && allowUsingPreviousPrebuilds) { - const { config } = await this.configProvider.fetchConfig({}, user, context, organizationId); - const history = await this.incrementalPrebuildsService.getCommitHistoryForContext(context, user); - prebuiltWorkspace = await this.incrementalPrebuildsService.findGoodBaseForIncrementalBuild( - context, - config, - history, - user, - projectId, - ); - } + const configPromise = this.configProvider.fetchConfig({}, user, context, organizationId); + const history = await this.incrementalPrebuildsService.getCommitHistoryForContext(context, user); + const { config } = await configPromise; + prebuiltWorkspace = await this.incrementalPrebuildsService.findGoodBaseForIncrementalBuild( + context, + config, + history, + user, + projectId, + ); } if (!prebuiltWorkspace?.projectId) { - return; + return undefined; } // check if the user has access to the project if (!(await this.auth.hasPermissionOnProject(user.id, "read_prebuild", prebuiltWorkspace.projectId))) { return undefined; } - if (prebuiltWorkspace.state === "available") { - log.info(logCtx, `Found prebuilt workspace for ${cloneUrl}:${commitSHAs}`, logPayload); - const result: PrebuiltWorkspaceContext = { - title: context.title, - originalContext: context, - prebuiltWorkspace, - }; - return result; - } else if (prebuiltWorkspace.state === "queued") { - // waiting for a prebuild that has not even started yet, doesn't make sense. - // starting a workspace from git will be faster anyway - return; - } else if (prebuiltWorkspace.state === "building") { - if (ignoreRunningPrebuild) { - // in force mode we ignore running prebuilds as we want to start a workspace as quickly as we can. - return; - } - - const workspaceID = prebuiltWorkspace.buildWorkspaceId; - const makeResult = (instanceID: string): WorkspaceCreationResult => { - return { - runningWorkspacePrebuild: { - prebuildID: prebuiltWorkspace!.id, - workspaceID, - instanceID, - starting: "queued", - sameCluster: false, - }, - }; - }; - - const wsi = await this.workspaceDb.trace(ctx).findCurrentInstance(workspaceID); - if (!wsi || wsi.stoppedTime !== undefined) { - return; - } - - // (AT) At this point we found a running/building prebuild, which might also include - // image build in current state. - // - // The owner's client connection is automatically registered to listen on instance updates. - // For the remaining client connections which would handle `createWorkspace` and end up here, it - // also would be reasonable to listen on the instance updates of a running prebuild, or image build. - // - // We need to be forwarded the WorkspaceInstanceUpdates in the frontend, because we do not have - // any other means to reliably learn about the status about image builds, yet. - // Once we have those, we should remove this. - // - const ws = await this.workspaceDb.trace(ctx).findById(workspaceID); - const relatedPrebuildFound = !!ws && !!wsi && ws.ownerId !== this.userID; - if (relatedPrebuildFound && !this.disposables.disposed) { - const resetListenerFromRedis = this.subscriber.listenForWorkspaceInstanceUpdates( - ws.ownerId, - (ctx, instance) => { - if (instance.id === wsi.id) { - this.forwardInstanceUpdateToClient(ctx, instance); - if (instance.status.phase === "stopped") { - resetListenerFromRedis.dispose(); - } - } - }, - ); - this.disposables.push(resetListenerFromRedis); - } - - const result = makeResult(wsi.id); - - const inSameCluster = wsi.region === this.config.installationShortname; - if (!inSameCluster) { - /* We need to wait for this prebuild to finish before we return from here. - * This creation mode is meant to be used once we have gone through default mode, have confirmation from the - * message bus that the prebuild is done, and now only have to wait for dbsync to come through. Thus, - * in this mode we'll poll the database until the prebuild is ready (or we time out). - * - * Note: This polling mechanism only makes sense if the prebuild runs in cluster different from ours. - * Otherwise there's no dbsync inbetween that we might have to wait for. - * - * DB sync interval is 2 seconds at the moment, we wait ten "ticks" for the data to be synchronized. - */ - const finishedPrebuiltWorkspace = await this.pollDatabaseUntilPrebuildIsAvailable( - ctx, - prebuiltWorkspace.id, - 20000, - ); - if (!finishedPrebuiltWorkspace) { - log.warn( - logCtx, - "did not find a finished prebuild in the database despite waiting long enough after msgbus confirmed that the prebuild had finished", - logPayload, - ); - return; - } else { - return { - title: context.title, - originalContext: context, - prebuiltWorkspace: finishedPrebuiltWorkspace, - } as PrebuiltWorkspaceContext; - } - } - - /* This is the default mode behaviour: we present the running prebuild to the user so that they can see the logs - * or choose to force the creation of a workspace. - */ - if (wsi.status.phase != "running") { - result.runningWorkspacePrebuild!.starting = "starting"; - } else { - result.runningWorkspacePrebuild!.starting = "running"; - } - log.info( - logCtx, - `Found prebuilding (starting=${ - result.runningWorkspacePrebuild!.starting - }) workspace for ${cloneUrl}:${commitSHAs}`, - logPayload, - ); - return result; - } + log.info(logCtx, `Found prebuilt workspace for ${cloneUrl}:${commitSHAs}`, logPayload); + const result: PrebuiltWorkspaceContext = { + title: context.title, + originalContext: context, + prebuiltWorkspace, + }; + return result; } catch (e) { TraceContext.setError(ctx, e); throw e; @@ -1370,22 +1249,9 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { runningInstancesPromise, ); - // TODO (se) findPrebuiltWorkspace also needs the organizationId once we limit prebuild reuse to the same org - const prebuiltWorkspace = - project && - (await this.findPrebuiltWorkspace( - ctx, - user, - project.id, - context, - options.organizationId, - options.ignoreRunningPrebuild, - options.allowUsingPreviousPrebuilds || project.settings?.allowUsingPreviousPrebuilds, - )); - if (WorkspaceCreationResult.is(prebuiltWorkspace)) { - ctx.span?.log({ prebuild: "running" }); - return prebuiltWorkspace as WorkspaceCreationResult; - } + const prebuiltWorkspace = project?.settings?.prebuilds?.enable + ? await this.findPrebuiltWorkspace(ctx, user, project.id, context, options.organizationId) + : undefined; if (WorkspaceContext.is(prebuiltWorkspace)) { ctx.span?.log({ prebuild: "available" }); context = prebuiltWorkspace; @@ -1589,28 +1455,6 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { return undefined; } - private async pollDatabaseUntilPrebuildIsAvailable( - ctx: TraceContext, - prebuildID: string, - timeoutMS: number, - ): Promise { - const pollPrebuildAvailable = new Cancelable(async (cancel) => { - const prebuild = await this.workspaceDb.trace(ctx).findPrebuildByID(prebuildID); - if (prebuild && PrebuiltWorkspace.isAvailable(prebuild)) { - return prebuild; - } - return; - }); - - const result = await Promise.race([ - pollPrebuildAvailable.run(), - new Promise((resolve, reject) => setTimeout(() => resolve(undefined), timeoutMS)), - ]); - pollPrebuildAvailable.cancel(); - - return result; - } - public async getFeaturedRepositories(ctx: TraceContext): Promise { const user = await this.checkAndBlockUser("getFeaturedRepositories"); const repositories = await this.workspaceDb.trace(ctx).getFeaturedRepositories(); diff --git a/components/server/src/workspace/workspace-factory.ts b/components/server/src/workspace/workspace-factory.ts index 7dfc5c011e70db..f867134ce0c165 100644 --- a/components/server/src/workspace/workspace-factory.ts +++ b/components/server/src/workspace/workspace-factory.ts @@ -30,8 +30,6 @@ import { inject, injectable } from "inversify"; import { RepoURL } from "../repohost"; import { ConfigProvider } from "./config-provider"; import { ImageSourceProvider } from "./image-source-provider"; -import { DeepPartial } from "@gitpod/gitpod-protocol/lib/util/deep-partial"; -import { IncrementalPrebuildsService } from "../prebuilds/incremental-prebuilds-service"; import { increasePrebuildsStartedCounter } from "../prometheus-metrics"; import { Authorizer } from "../authorization/authorizer"; @@ -42,7 +40,6 @@ export class WorkspaceFactory { @inject(TeamDB) private readonly teamDB: TeamDB, @inject(ConfigProvider) private configProvider: ConfigProvider, @inject(ImageSourceProvider) private imageSourceProvider: ImageSourceProvider, - @inject(IncrementalPrebuildsService) private readonly incrementalPrebuildsService: IncrementalPrebuildsService, @inject(Authorizer) private readonly authorizer: Authorizer, ) {} @@ -111,69 +108,14 @@ export class WorkspaceFactory { await assertNoPrebuildIsRunningForSameCommit(); - const { config } = await this.configProvider.fetchConfig({ span }, user, context.actual, organizationId); - - // If an incremental prebuild was requested, see if we can find a recent prebuild to act as a base. - let ws; - const recentPrebuild = await this.incrementalPrebuildsService.findGoodBaseForIncrementalBuild( - commitContext, - config, - context, + let ws = await this.createForCommit( + { span }, user, - projectId, + organizationId, + project, + commitContext, + normalizedContextURL, ); - if (recentPrebuild) { - const loggedContext = filterForLogging(context); - log.info({ userId: user.id }, "Using incremental prebuild base", { - basePrebuildId: recentPrebuild.id, - context: loggedContext, - }); - - const incrementalPrebuildContext: PrebuiltWorkspaceContext = { - title: `Incremental prebuild of "${commitContext.title}"`, - originalContext: commitContext, - prebuiltWorkspace: recentPrebuild, - }; - - // repeated assertion on prebuilds triggered for same commit here, in order to - // reduce likelihood of duplicates if for instance handled by two different - // server pods. - await assertNoPrebuildIsRunningForSameCommit(); - - ws = await this.createForPrebuiltWorkspace( - { span }, - user, - organizationId, - project, - incrementalPrebuildContext, - normalizedContextURL, - ); - // Overwrite the config from the parent prebuild: - // `createForPrebuiltWorkspace` 1:1 copies the config from the parent prebuild. - // Above, we've made sure that the parent's prebuild tasks (before/init/prebuild) are still the same as now. - // However, other non-prebuild config items might be outdated (e.g. any command task, VS Code extension, ...) - // To fix this, we overwrite the new prebuild's config with the most-recently fetched config. - // See also: https://github.com/gitpod-io/gitpod/issues/7475 - //TODO(sven) doing side effects on objects back and forth is complicated and error-prone. We should rather make sure we pass in the config when creating the prebuiltWorkspace. - ws.config = config; - } - - // repeated assertion on prebuilds triggered for same commit here, in order to - // reduce likelihood of duplicates if for instance handled by two different - // server pods. - await assertNoPrebuildIsRunningForSameCommit(); - - if (!ws) { - // No suitable parent prebuild was found -- create a (fresh) full prebuild. - ws = await this.createForCommit( - { span }, - user, - organizationId, - project, - commitContext, - normalizedContextURL, - ); - } ws.type = "prebuild"; ws.projectId = project?.id; ws = await this.db.trace({ span }).store(ws); @@ -436,19 +378,3 @@ export class WorkspaceFactory { return await generateWorkspaceID(); } } - -function filterForLogging(context: StartPrebuildContext) { - return >{ - actual: context.actual, - branch: context.branch, - normalizedContextURL: context.normalizedContextURL, - ref: context.ref, - title: context.title, - forceCreateNewWorkspace: context.forceCreateNewWorkspace, - forceImageBuild: context.forceImageBuild, - project: context.project, - // placeholders for the actual history - commitHistoryLength: context.commitHistory?.length || 0, - additionalRepositoryCommitHistoriesLength: context.additionalRepositoryCommitHistories?.length || 0, - }; -} diff --git a/test/pkg/integration/workspace.go b/test/pkg/integration/workspace.go index 3d72dab00ca231..979b618589dda3 100644 --- a/test/pkg/integration/workspace.go +++ b/test/pkg/integration/workspace.go @@ -382,7 +382,6 @@ func LaunchWorkspaceWithOptions(t *testing.T, ctx context.Context, opts *LaunchW resp, err = server.CreateWorkspace(cctx, &protocol.CreateWorkspaceOptions{ ContextURL: opts.ContextURL, OrganizationId: orgId, - IgnoreRunningPrebuild: true, IgnoreRunningWorkspaceOnSameCommit: true, StartWorkspaceOptions: protocol.StartWorkspaceOptions{ IdeSettings: opts.IDESettings, diff --git a/test/tests/components/server/server_test.go b/test/tests/components/server/server_test.go index 706692072f5341..407da546fefc58 100644 --- a/test/tests/components/server/server_test.go +++ b/test/tests/components/server/server_test.go @@ -68,7 +68,6 @@ func TestStartWorkspace(t *testing.T) { resp, err := server.CreateWorkspace(ctx, &protocol.CreateWorkspaceOptions{ ContextURL: "github.com/gitpod-io/gitpod", - IgnoreRunningPrebuild: true, IgnoreRunningWorkspaceOnSameCommit: true, }) if err != nil {