Skip to content

Commit

Permalink
[server] Don't fetch the repository config a second time when startin…
Browse files Browse the repository at this point in the history
…g incremental prebuilds
  • Loading branch information
jankeromnes authored and roboquat committed Oct 19, 2022
1 parent e2cfceb commit 53ad761
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
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

0 comments on commit 53ad761

Please sign in to comment.