Skip to content

[server] Don't fetch the repository config a second time when starting incremental prebuilds #13962

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 1 commit 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
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ export class IncrementalPrebuildsService {

public async findGoodBaseForIncrementalBuild(
context: CommitContext,
config: WorkspaceConfig,
history: WithCommitHistory,
user: User,
): Promise<PrebuiltWorkspace | undefined> {
if (!history.commitHistory || history.commitHistory.length < 1) {
return;
}

const { config } = await this.configProvider.fetchConfig({}, user, context);
const imageSource = await this.imageSourceProvider.getImageSource({}, user, context, config);

// Note: This query returns only not-garbage-collected prebuilds in order to reduce cardinality
Expand Down
4 changes: 4 additions & 0 deletions components/server/ee/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,13 @@ import { BillingMode } from "@gitpod/gitpod-protocol/lib/billing-mode";
import { BillingModes } from "../billing/billing-mode";
import { UsageServiceDefinition } from "@gitpod/usage-api/lib/usage/v1/usage.pb";
import { IncrementalPrebuildsService } from "../prebuilds/incremental-prebuilds-service";
import { ConfigProvider } from "../../../src/workspace/config-provider";

@injectable()
export class GitpodServerEEImpl extends GitpodServerImpl {
@inject(PrebuildManager) protected readonly prebuildManager: PrebuildManager;
@inject(IncrementalPrebuildsService) protected readonly incrementalPrebuildsService: IncrementalPrebuildsService;
@inject(ConfigProvider) protected readonly configProvider: ConfigProvider;
@inject(LicenseDB) protected readonly licenseDB: LicenseDB;
@inject(LicenseKeySource) protected readonly licenseKeySource: LicenseKeySource;

Expand Down Expand Up @@ -982,9 +984,11 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
const logPayload = { mode, cloneUrl, commit: commitSHAs, prebuiltWorkspace };
log.debug(logCtx, "Looking for prebuilt workspace: ", logPayload);
if (prebuiltWorkspace?.state !== "available" && mode === CreateWorkspaceMode.UseLastSuccessfulPrebuild) {
const { config } = await this.configProvider.fetchConfig({}, user, context);
const history = await this.incrementalPrebuildsService.getCommitHistoryForContext(context, user);
prebuiltWorkspace = await this.incrementalPrebuildsService.findGoodBaseForIncrementalBuild(
context,
config,
history,
user,
);
Expand Down
1 change: 1 addition & 0 deletions components/server/ee/src/workspace/workspace-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export class WorkspaceFactoryEE extends WorkspaceFactory {
let ws;
const recentPrebuild = await this.incrementalPrebuildsService.findGoodBaseForIncrementalBuild(
commitContext,
config,
context,
user,
);
Expand Down