Skip to content

[server] Bump dependencies avoid pulling 'agent-base' < 6.0.0 #2388

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
Jan 15, 2021
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
7 changes: 6 additions & 1 deletion components/server/ee/src/container-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { WorkspaceFactoryEE } from "./workspace/workspace-factory";
import { MonitoringEndpointsAppEE } from "./monitoring-endpoint-ee";
import { MonitoringEndpointsApp } from "../../src/monitoring-endpoints";
import { WorkspaceHealthMonitoring } from "./workspace/workspace-health-monitoring";
import { Env } from "../../src/env";

export const productionEEContainerModule = new ContainerModule((bind, unbind, isBound, rebind) => {
rebind(Server).to(ServerEE).inSingletonScope();
Expand All @@ -52,7 +53,11 @@ export const productionEEContainerModule = new ContainerModule((bind, unbind, is
bind(PrebuildRateLimiter).toSelf().inSingletonScope();
bind(PrebuildQueueMaintainer).toSelf().inSingletonScope();
bind(IPrefixContextParser).to(StartPrebuildContextParser).inSingletonScope();
bind(GithubApp).toSelf().inSingletonScope();
bind(GithubApp).toDynamicValue(ctx => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This might be irrelevant

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't it same as the ctor injection?
or did you try to solve an issue with eager dep resolution?

const env = ctx.container.get<Env>(Env);
const prebuildStatusMaintainer = ctx.container.get<PrebuildStatusMaintainer>(PrebuildStatusMaintainer);
return new GithubApp(env, prebuildStatusMaintainer);
}).inSingletonScope();
bind(GithubAppRules).toSelf().inSingletonScope();
bind(PrebuildStatusMaintainer).toSelf().inSingletonScope();
bind(GitLabApp).toSelf().inSingletonScope();
Expand Down
26 changes: 15 additions & 11 deletions components/server/ee/src/prebuilds/github-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* See License.enterprise.txt in the project root folder.
*/

import { Probot, Application, Context } from 'probot';
import { findPrivateKey } from 'probot/lib/private-key';
import { Probot, Context } from 'probot';
import { getPrivateKey } from '@probot/get-private-key';
import * as fs from 'fs-extra';
import { injectable, inject, decorate } from 'inversify';
import { Env } from '../../../src/env';
Expand All @@ -24,6 +24,7 @@ import { TraceContext } from '@gitpod/gitpod-protocol/lib/util/tracing';
import { TracedWorkspaceDB, DBWithTracing } from '@gitpod/gitpod-db/lib/traced-db';
import { PrebuildManager } from './prebuild-manager';
import { PrebuildStatusMaintainer } from './prebuilt-status-maintainer';
import { ApplicationFunctionOptions } from 'probot/lib/types';

/**
* GitHub app urls:
Expand Down Expand Up @@ -53,7 +54,7 @@ export class GithubApp extends Probot {
) {
super({
id: env.githubAppAppID,
cert: GithubApp.loadPrivateKey(env.githubAppCertPath),
privateKey: GithubApp.loadPrivateKey(env.githubAppCertPath),
secret: env.githubAppWebhookSecret
});
log.debug("Starting GitHub app integration", {
Expand All @@ -65,7 +66,8 @@ export class GithubApp extends Probot {
this.load(this.buildApp.bind(this));
}

protected async buildApp(app: Application) {
protected async buildApp(options: ApplicationFunctionOptions) {
const app = options.app;
this.statusMaintainer.start(async id => (await app.auth(parseInt(id))) as any as Octokit);
// this.queueMaintainer.start();

Expand Down Expand Up @@ -105,14 +107,17 @@ export class GithubApp extends Probot {
});

app.on('installation.created', async ctx => {
const authId: string = ctx.payload.installation.account.id;
const user = await this.userDB.findUserByIdentity({ authProviderId: this.env.githubAppAuthProviderId, authId });
const accountId: string = `${ctx.payload.installation.account.id}`;
const installationId = `${ctx.payload.installation.id}`;
const senderId = `${ctx.payload.sender.id}`;
const user = await this.userDB.findUserByIdentity({ authProviderId: this.env.githubAppAuthProviderId, authId: accountId });
const userId = user ? user.id : undefined;
await this.appInstallationDB.recordNewInstallation("github", 'platform', ctx.payload.installation.id, userId, ctx.payload.sender.id);
await this.appInstallationDB.recordNewInstallation("github", 'platform', installationId, userId, senderId);
log.debug({ userId }, "New installation recorded", { userId, platformUserId: ctx.payload.sender.id })
});
app.on('installation.deleted', async ctx => {
await this.appInstallationDB.recordUninstallation("github", 'platform', ctx.payload.installation.id);
const installationId = `${ctx.payload.installation.id}`;
await this.appInstallationDB.recordUninstallation("github", 'platform', installationId);
});

app.on('push', async ctx => {
Expand Down Expand Up @@ -412,14 +417,13 @@ export namespace GithubApp {
}

// loadPrivateKey is used in super call - must not be async
if (filename && fs.existsSync(filename)) {
const key = findPrivateKey(filename);
if (fs.existsSync(filename)) {
const key = getPrivateKey({ filepath: filename });
if (key) {
return key.toString();
}
}
}

}

class PrebuildListener {
Expand Down
16 changes: 8 additions & 8 deletions components/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@
"/dist"
],
"dependencies": {
"@gitbeaker/node": "^25.6.0",
"@gitpod/content-service": "0.1.5",
"@gitpod/gitpod-db": "0.1.5",
"@gitpod/gitpod-messagebus": "0.1.5",
"@gitpod/gitpod-protocol": "0.1.5",
"@gitpod/image-builder": "0.1.5",
"@gitpod/licensor": "0.1.5",
"@gitpod/ws-manager": "0.1.5",
"@google-cloud/storage": "^2.5.0",
"@google-cloud/storage": "^5.6.0",
"@octokit/rest": "16.35.0",
"agent-base": "4.2.1",
"@probot/get-private-key": "^1.1.0",
"amqplib": "^0.5.2",
"base-64": "^0.1.0",
"bitbucket": "^2.4.2",
Expand All @@ -50,7 +51,6 @@
"express-mysql-session": "^2.1.0",
"express-session": "^1.15.6",
"fs-extra": "^6.0.1",
"@gitbeaker/node": "^25.6.0",
"google-protobuf": "^3.8.0-rc.1",
"graphql": "^14.6.0",
"graphql-tools": "^4.0.7",
Expand All @@ -69,7 +69,7 @@
"passport-dummy": "^0.0.1",
"passport-gitlab2": "5.0.0",
"passport-http": "^0.3.0",
"probot": "^7.4.0",
"probot": "^10.17.2",
"prom-client": "^10.2.0",
"rasha": "^1.2.5",
"reflect-metadata": "^0.1.10",
Expand All @@ -81,10 +81,10 @@
"ws": "^5.2.2"
},
"devDependencies": {
"@graphql-codegen/cli": "^1.13.1",
"@graphql-codegen/introspection": "^1.13.1",
"@graphql-codegen/typescript": "^1.13.1",
"@graphql-codegen/typescript-resolvers": "^1.13.1",
"@graphql-codegen/cli": "^1.19.4",
"@graphql-codegen/introspection": "^1.18.1",
"@graphql-codegen/typescript": "^1.19.0",
"@graphql-codegen/typescript-resolvers": "^1.18.0",
"@types/amqplib": "^0.5.7",
"@types/assert": "^0.0.31",
"@types/base-64": "^0.1.2",
Expand Down
2 changes: 0 additions & 2 deletions components/server/src/gitlab/gitlab-context-parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import { HostContextProvider } from "../auth/host-context-provider";
import { skipIfEnvVarNotSet } from "@gitpod/gitpod-protocol/lib/util/skip-if";


import "../patch-agent-base";

@suite(timeout(10000), retries(2), skipIfEnvVarNotSet("GITPOD_TEST_TOKEN_GITLAB"))
class TestGitlabContextParser {

Expand Down
4 changes: 0 additions & 4 deletions components/server/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,3 @@ export async function start(container: Container) {
await server.stop();
});
}

// The module `[email protected]` contains a bad patch for nodejs, this should fix it.
// cf. https://github.com/gitpod-io/gitpod/pull/2375
import "./patch-agent-base";
22 changes: 0 additions & 22 deletions components/server/src/patch-agent-base.ts

This file was deleted.

2 changes: 1 addition & 1 deletion components/server/src/storage/gcloud-storage-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { injectable } from "inversify";
import { Storage, GetSignedUrlConfig } from "@google-cloud/storage";
import { Response } from 'request';
import { Response } from 'teeny-request';
import { log } from '@gitpod/gitpod-protocol/lib/util/logging';
import { StorageClient, CreateSignedUrlOptions } from "./storage-client";
import { getBucketNamePrefix } from "./commons";
Expand Down
2 changes: 1 addition & 1 deletion components/server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"downlevelIteration": true,
"module": "commonjs",
"moduleResolution": "node",
"target": "es5",
"target": "es6",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

"jsx": "react",
"sourceMap": true,
"declaration": true,
Expand Down
Loading