Skip to content

Revert "Use Last Successful Prebuild" for now #13997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions components/dashboard/src/contexts/FeatureFlagContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ interface FeatureFlagConfig {
const FeatureFlagContext = createContext<{
showPersistentVolumeClaimUI: boolean;
showUsageView: boolean;
showUseLastSuccessfulPrebuild: boolean;
}>({
showPersistentVolumeClaimUI: false,
showUsageView: false,
showUseLastSuccessfulPrebuild: false,
});

const FeatureFlagContextProvider: React.FC = ({ children }) => {
Expand All @@ -33,15 +31,13 @@ const FeatureFlagContextProvider: React.FC = ({ children }) => {
const team = getCurrentTeam(location, teams);
const [showPersistentVolumeClaimUI, setShowPersistentVolumeClaimUI] = useState<boolean>(false);
const [showUsageView, setShowUsageView] = useState<boolean>(false);
const [showUseLastSuccessfulPrebuild, setShowUseLastSuccessfulPrebuild] = useState<boolean>(false);

useEffect(() => {
if (!user) return;
(async () => {
const featureFlags: FeatureFlagConfig = {
persistent_volume_claim: { defaultValue: true, setter: setShowPersistentVolumeClaimUI },
usage_view: { defaultValue: false, setter: setShowUsageView },
showUseLastSuccessfulPrebuild: { defaultValue: false, setter: setShowUseLastSuccessfulPrebuild },
};
for (const [flagName, config] of Object.entries(featureFlags)) {
if (teams) {
Expand Down Expand Up @@ -73,9 +69,7 @@ const FeatureFlagContextProvider: React.FC = ({ children }) => {
}, [user, teams, team, project]);

return (
<FeatureFlagContext.Provider
value={{ showPersistentVolumeClaimUI, showUsageView, showUseLastSuccessfulPrebuild }}
>
<FeatureFlagContext.Provider value={{ showPersistentVolumeClaimUI, showUsageView }}>
{children}
</FeatureFlagContext.Provider>
);
Expand Down
14 changes: 0 additions & 14 deletions components/dashboard/src/start/CreateWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { BillingAccountSelector } from "../components/BillingAccountSelector";
import { AttributionId } from "@gitpod/gitpod-protocol/lib/attribution";
import { TeamsContext } from "../teams/teams-context";
import Alert from "../components/Alert";
import { FeatureFlagContext } from "../contexts/FeatureFlagContext";

export interface CreateWorkspaceProps {
contextUrl: string;
Expand Down Expand Up @@ -270,9 +269,6 @@ export default class CreateWorkspace extends React.Component<CreateWorkspaceProp
return (
<RunningPrebuildView
runningPrebuild={result.runningWorkspacePrebuild}
onUseLastSuccessfulPrebuild={() =>
this.createWorkspace(CreateWorkspaceMode.UseLastSuccessfulPrebuild)
}
onIgnorePrebuild={() => this.createWorkspace(CreateWorkspaceMode.ForceNew)}
onPrebuildSucceeded={() => this.createWorkspace(CreateWorkspaceMode.UsePrebuild)}
/>
Expand Down Expand Up @@ -535,14 +531,12 @@ interface RunningPrebuildViewProps {
starting: RunningWorkspacePrebuildStarting;
sameCluster: boolean;
};
onUseLastSuccessfulPrebuild: () => void;
onIgnorePrebuild: () => void;
onPrebuildSucceeded: () => void;
}

function RunningPrebuildView(props: RunningPrebuildViewProps) {
const workspaceId = props.runningPrebuild.workspaceID;
const { showUseLastSuccessfulPrebuild } = useContext(FeatureFlagContext);

useEffect(() => {
const disposables = new DisposableCollection();
Expand Down Expand Up @@ -571,14 +565,6 @@ function RunningPrebuildView(props: RunningPrebuildViewProps) {
{/* TODO(gpl) Copied around in Start-/CreateWorkspace. This should properly go somewhere central. */}
<div className="h-full mt-6 w-11/12 lg:w-3/5">
<PrebuildLogs workspaceId={workspaceId} onIgnorePrebuild={props.onIgnorePrebuild}>
{showUseLastSuccessfulPrebuild && (
<button
className="secondary"
onClick={() => props.onUseLastSuccessfulPrebuild && props.onUseLastSuccessfulPrebuild()}
>
Use Last Successful Prebuild
</button>
)}
<button className="secondary" onClick={() => props.onIgnorePrebuild && props.onIgnorePrebuild()}>
Skip Prebuild
</button>
Expand Down
9 changes: 2 additions & 7 deletions components/gitpod-protocol/src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1111,16 +1111,13 @@ export namespace SnapshotContext {
}
}

export interface WithCommitHistory {
export interface StartPrebuildContext extends WorkspaceContext {
actual: WorkspaceContext;
commitHistory?: string[];
additionalRepositoryCommitHistories?: {
cloneUrl: string;
commitHistory: string[];
}[];
}

export interface StartPrebuildContext extends WorkspaceContext, WithCommitHistory {
actual: WorkspaceContext;
project?: Project;
branch?: string;
}
Expand Down Expand Up @@ -1385,8 +1382,6 @@ export enum CreateWorkspaceMode {
UsePrebuild = "use-prebuild",
// SelectIfRunning returns a list of currently running workspaces for the context URL if there are any, otherwise falls back to Default mode
SelectIfRunning = "select-if-running",
// UseLastSuccessfulPrebuild returns ...
UseLastSuccessfulPrebuild = "use-last-successful-prebuild",
}

export namespace WorkspaceCreationResult {
Expand Down
2 changes: 0 additions & 2 deletions components/server/ee/src/container-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { PrebuildStatusMaintainer } from "./prebuilds/prebuilt-status-maintainer
import { GitLabApp } from "./prebuilds/gitlab-app";
import { BitbucketApp } from "./prebuilds/bitbucket-app";
import { GitHubEnterpriseApp } from "./prebuilds/github-enterprise-app";
import { IncrementalPrebuildsService } from "./prebuilds/incremental-prebuilds-service";
import { IPrefixContextParser } from "../../src/workspace/context-parser";
import { StartPrebuildContextParser } from "./prebuilds/start-prebuild-context-parser";
import { WorkspaceFactory } from "../../src/workspace/workspace-factory";
Expand Down Expand Up @@ -84,7 +83,6 @@ export const productionEEContainerModule = new ContainerModule((bind, unbind, is
bind(BitbucketAppSupport).toSelf().inSingletonScope();
bind(GitHubEnterpriseApp).toSelf().inSingletonScope();
bind(BitbucketServerApp).toSelf().inSingletonScope();
bind(IncrementalPrebuildsService).toSelf().inSingletonScope();

bind(UserCounter).toSelf().inSingletonScope();

Expand Down
175 changes: 0 additions & 175 deletions components/server/ee/src/prebuilds/incremental-prebuilds-service.ts

This file was deleted.

41 changes: 30 additions & 11 deletions components/server/ee/src/prebuilds/prebuild-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ 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";

export class WorkspaceRunningError extends Error {
constructor(msg: string, public instance: WorkspaceInstance) {
Expand All @@ -60,7 +59,6 @@ export class PrebuildManager {
@inject(ConfigProvider) protected readonly configProvider: ConfigProvider;
@inject(Config) protected readonly config: Config;
@inject(ProjectsService) protected readonly projectService: ProjectsService;
@inject(IncrementalPrebuildsService) protected readonly incrementalPrebuildsService: IncrementalPrebuildsService;

async abortPrebuildsForBranch(ctx: TraceContext, project: Project, user: User, branch: string): Promise<void> {
const span = TraceContext.startSpan("abortPrebuildsForBranch", ctx);
Expand Down Expand Up @@ -174,15 +172,36 @@ export class PrebuildManager {
};

if (this.shouldPrebuildIncrementally(context.repository.cloneUrl, project)) {
// We store the commit histories in the `StartPrebuildContext` in order to pass them down to
// `WorkspaceFactoryEE.createForStartPrebuild`.
const { commitHistory, additionalRepositoryCommitHistories } =
await this.incrementalPrebuildsService.getCommitHistoryForContext(context, user);
if (commitHistory) {
prebuildContext.commitHistory = commitHistory;
}
if (additionalRepositoryCommitHistories) {
prebuildContext.additionalRepositoryCommitHistories = additionalRepositoryCommitHistories;
const maxDepth = this.config.incrementalPrebuilds.commitHistory;
const hostContext = this.hostContextProvider.get(context.repository.host);
const repoProvider = hostContext?.services?.repositoryProvider;
if (repoProvider) {
prebuildContext.commitHistory = await repoProvider.getCommitHistory(
user,
context.repository.owner,
context.repository.name,
context.revision,
maxDepth,
);
if (
context.additionalRepositoryCheckoutInfo &&
context.additionalRepositoryCheckoutInfo.length > 0
) {
const histories = context.additionalRepositoryCheckoutInfo.map(async (info) => {
const commitHistory = await repoProvider.getCommitHistory(
user,
info.repository.owner,
info.repository.name,
info.revision,
maxDepth,
);
return {
cloneUrl: info.repository.cloneUrl,
commitHistory,
};
});
prebuildContext.additionalRepositoryCommitHistories = await Promise.all(histories);
}
}
}

Expand Down
Loading