Skip to content

Commit

Permalink
[prebuilds] changed prebuild semantics
Browse files Browse the repository at this point in the history
- no more incremental prebuilds
- always incremental workspace
- never wait for running prebuilds
  • Loading branch information
svenefftinge committed Oct 5, 2023
1 parent 53e5225 commit b88a21f
Show file tree
Hide file tree
Showing 22 changed files with 242 additions and 659 deletions.
3 changes: 0 additions & 3 deletions components/dashboard/src/admin/ProjectDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ export default function ProjectDetail(props: { project: Project; owner: string |
</Property>
</div>
<div className="flex w-full mt-6">
<Property name="Incremental Prebuilds">
{props.project.settings?.useIncrementalPrebuilds ? "Yes" : "No"}
</Property>
<Property name="Marked Deleted">{props.project.markedDeleted ? "Yes" : "No"}</Property>
</div>
</div>
Expand Down
140 changes: 47 additions & 93 deletions components/dashboard/src/projects/ProjectSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -239,7 +238,7 @@ export default function ProjectSettingsView() {
<span>
{prebuildSettings.enable ? (
<Fragment>
Prebuilds will run for any <code>before</code> or <code>init</code> tasks.
Prebuilds execute and cache the result of the <code>init</code> tasks.
</Fragment>
) : (
"Requires permissions to configure repository webhooks."
Expand All @@ -259,17 +258,51 @@ export default function ProjectSettingsView() {
/>
{prebuildSettings.enable && (
<>
<SelectInputField
disabled={!prebuildSettings.enable}
label="Build branches"
value={prebuildSettings.branchStrategy || ""}
containerClassName="max-w-md ml-6 text-sm"
onChange={(val) => setPrebuildBranchStrategy(val as PrebuildSettings.BranchStrategy)}
>
<option value="default-branch">Default branch</option>
<option value="all-branches">All branches</option>
<option value="matched-branches">Matched by pattern</option>
</SelectInputField>
<div className="flex mt-4 max-w-2xl">
<div className="flex flex-col ml-6">
<label
htmlFor="prebuildInterval"
className={classNames(
"text-sm font-semibold cursor-pointer tracking-wide",
!prebuildSettings.enable
? "text-gray-400 dark:text-gray-400"
: "text-gray-600 dark:text-gray-100",
)}
>
Interval
</label>
<input
type="number"
id="prebuildInterval"
min="0"
max="100"
step="5"
className="mt-2"
disabled={!prebuildSettings.enable}
value={prebuildSettings.prebuildInterval}
onChange={({ target }) => setPrebuildInterval(target.value)}
/>
<div className="text-gray-500 dark:text-gray-400 text-sm mt-2">
The number of commits to be skipped between prebuild runs.
</div>
</div>
</div>
<div>
<SelectInputField
disabled={!prebuildSettings.enable}
label="Branches"
value={prebuildSettings.branchStrategy || ""}
containerClassName="max-w-md ml-6 text-sm"
onChange={(val) => setPrebuildBranchStrategy(val as PrebuildSettings.BranchStrategy)}
>
<option value="default-branch">Default branch</option>
<option value="all-branches">All branches</option>
<option value="matched-branches">Matched by pattern</option>
</SelectInputField>
<div className="ml-6 text-gray-500 dark:text-gray-400 text-sm mt-2">
Which branches are considered for prebuilds.
</div>
</div>
{prebuildSettings.branchStrategy === "matched-branches" && (
<div className="flex flex-col ml-6 mt-4">
<label
Expand Down Expand Up @@ -298,7 +331,7 @@ export default function ProjectSettingsView() {
)}
<InputField
className="max-w-md ml-6 text-sm"
label="Workspace machine type"
label="Machine type"
disabled={!prebuildSettings.enable}
>
<SelectWorkspaceClassComponent
Expand All @@ -307,85 +340,6 @@ export default function ProjectSettingsView() {
onSelectionChange={setWorkspaceClassForPrebuild}
/>
</InputField>
<CheckboxInputField
label="Enable Incremental Prebuilds"
hint={
<span>
When possible, use an earlier successful prebuild as a base to create new prebuilds.
This can make your prebuilds significantly faster, especially if they normally take
longer than 10 minutes.{" "}
<a
className="gp-link"
target="_blank"
rel="noreferrer"
href="https://www.gitpod.io/changelog/faster-incremental-prebuilds"
>
Learn more
</a>
</span>
}
disabled={!prebuildSettings.enable}
checked={project.settings?.useIncrementalPrebuilds ?? false}
onChange={(checked) => updateProjectSettings({ useIncrementalPrebuilds: checked })}
/>
<CheckboxInputField
label="Cancel Prebuilds on Outdated Commits"
hint="Cancel pending or running prebuilds on the same branch when new commits are pushed."
disabled={!prebuildSettings.enable}
checked={!project.settings?.keepOutdatedPrebuildsRunning}
onChange={(checked) => updateProjectSettings({ keepOutdatedPrebuildsRunning: !checked })}
/>
<CheckboxInputField
label={
<span>
Use Last Successful Prebuild{" "}
<PillLabel type="warn" className="font-semibold mt-2 ml-2 py-0.5 px-2 self-center">
Alpha
</PillLabel>
</span>
}
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,
})
}
/>
<div className="flex mt-4 max-w-2xl">
<div className="flex flex-col ml-6">
<label
htmlFor="prebuildInterval"
className={classNames(
"text-sm font-semibold cursor-pointer tracking-wide",
!prebuildSettings.enable
? "text-gray-400 dark:text-gray-400"
: "text-gray-600 dark:text-gray-100",
)}
>
Prebuild interval
</label>
<input
type="number"
id="prebuildInterval"
min="0"
max="100"
step="5"
className="mt-2"
disabled={!prebuildSettings.enable}
value={prebuildSettings.prebuildInterval}
onChange={({ target }) => setPrebuildInterval(target.value)}
/>
<div className="text-gray-500 dark:text-gray-400 text-sm mt-2">
The number of commits to be skipped between prebuild runs.
</div>
</div>
</div>
</>
)}
<div>
Expand Down
3 changes: 0 additions & 3 deletions components/dashboard/src/service/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 || "",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
27 changes: 6 additions & 21 deletions components/gitpod-protocol/go/gitpod-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"`
}

Expand Down Expand Up @@ -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"`
Expand Down
2 changes: 0 additions & 2 deletions components/gitpod-protocol/src/gitpod-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,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;
}

Expand Down
9 changes: 0 additions & 9 deletions components/gitpod-protocol/src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 16 additions & 5 deletions components/gitpod-protocol/src/teams-projects-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 2 additions & 7 deletions components/public-api-server/pkg/apiv1/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions components/public-api-server/pkg/apiv1/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions components/public-api/gitpod/experimental/v1/projects.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit b88a21f

Please sign in to comment.