Skip to content

Configure grpc client ChannelOptions #5449

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
Sep 2, 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
4 changes: 2 additions & 2 deletions components/ee/db-sync/leeway.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# Licensed under the Gitpod Enterprise Source Code License,
# See License.enterprise.txt in the project root folder.

FROM node:12.18.3-slim as builder
FROM node:12.22.1-slim as builder
COPY components-ee-db-sync--app /installer/

WORKDIR /app
RUN /installer/install.sh

FROM node:12.18.3-slim
FROM node:12.22.1-slim
# '--no-log-init': see https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
RUN useradd --no-log-init --create-home --uid 31002 --home-dir /app/ unode
COPY --from=builder /app /app/
Expand Down
15 changes: 15 additions & 0 deletions components/gitpod-protocol/src/util/grpc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/

export const defaultGRPCOptions = {
"grpc.keepalive_timeout_ms": 1000,
"grpc.keepalive_time_ms": 5000,
"grpc.http2.min_time_between_pings_ms": 1000,
"grpc.keepalive_permit_without_calls": 1,
"grpc-node.max_session_memory": 50,
"grpc.max_reconnect_backoff_ms": 5000,
"grpc.max_receive_message_length": 1024 * 1024 * 16,
};
4 changes: 2 additions & 2 deletions components/server/leeway.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the GNU Affero General Public License (AGPL).
# See License-AGPL.txt in the project root for license information.

FROM node:12.18.3-slim as builder
FROM node:12.22.1-slim as builder

RUN apt-get update && apt-get install -y build-essential python

Expand All @@ -12,7 +12,7 @@ WORKDIR /app
RUN /installer/install.sh


FROM node:12.18.3-slim
FROM node:12.22.1-slim

# Using ssh-keygen for RSA keypair generation
RUN apt-get update && apt-get install -yq \
Expand Down
15 changes: 10 additions & 5 deletions components/server/src/container-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import { ProjectsService } from './projects/projects-service';
import { NewsletterSubscriptionController } from './user/newsletter-subscription-controller';
import { Config, ConfigFile } from './config';
import { Env } from './env';
import { defaultGRPCOptions } from '@gitpod/gitpod-protocol/lib/util/grpc';

export const productionContainerModule = new ContainerModule((bind, unbind, isBound, rebind) => {
bind(Env).toSelf().inSingletonScope();
Expand Down Expand Up @@ -183,25 +184,29 @@ export const productionContainerModule = new ContainerModule((bind, unbind, isBo

bind(TermsProvider).toSelf().inSingletonScope();

const grpcOptions: grpc.ClientOptions = {
...defaultGRPCOptions,
};

bind(ContentServiceClient).toDynamicValue(ctx => {
const config = ctx.container.get<Config>(Config);
return new ContentServiceClient(config.contentServiceAddr, grpc.credentials.createInsecure());
return new ContentServiceClient(config.contentServiceAddr, grpc.credentials.createInsecure(), grpcOptions);
});
bind(BlobServiceClient).toDynamicValue(ctx => {
const config = ctx.container.get<Config>(Config);
return new BlobServiceClient(config.contentServiceAddr, grpc.credentials.createInsecure());
return new BlobServiceClient(config.contentServiceAddr, grpc.credentials.createInsecure(), grpcOptions);
});
bind(WorkspaceServiceClient).toDynamicValue(ctx => {
const config = ctx.container.get<Config>(Config);
return new WorkspaceServiceClient(config.contentServiceAddr, grpc.credentials.createInsecure());
return new WorkspaceServiceClient(config.contentServiceAddr, grpc.credentials.createInsecure(), grpcOptions);
});
bind(IDEPluginServiceClient).toDynamicValue(ctx => {
const config = ctx.container.get<Config>(Config);
return new IDEPluginServiceClient(config.contentServiceAddr, grpc.credentials.createInsecure());
return new IDEPluginServiceClient(config.contentServiceAddr, grpc.credentials.createInsecure(), grpcOptions);
});
bind(HeadlessLogServiceClient).toDynamicValue(ctx => {
const config = ctx.container.get<Config>(Config);
return new HeadlessLogServiceClient(config.contentServiceAddr, grpc.credentials.createInsecure());
return new HeadlessLogServiceClient(config.contentServiceAddr, grpc.credentials.createInsecure(), grpcOptions);
});

bind(StorageClient).to(ContentServiceStorageClient).inSingletonScope();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Disposable, User, Workspace, WorkspaceInstance } from "@gitpod/gitpod-p
import { WorkspaceClusterWoTLS, WorkspaceManagerConnectionInfo } from '@gitpod/gitpod-protocol/lib/workspace-cluster';
import { WorkspaceManagerClientProviderCompositeSource, WorkspaceManagerClientProviderSource } from "./client-provider-source";
import { log } from '@gitpod/gitpod-protocol/lib/util/logging';
import { defaultGRPCOptions } from '@gitpod/gitpod-protocol/lib/util/grpc';

@injectable()
export class WorkspaceManagerClientProvider implements Disposable {
Expand All @@ -31,7 +32,10 @@ export class WorkspaceManagerClientProvider implements Disposable {
public async getStartManager(user: User, workspace: Workspace, instance: WorkspaceInstance): Promise<{ manager: PromisifiedWorkspaceManagerClient, installation: string}> {
const availableCluster = await this.getAvailableStartCluster(user, workspace, instance);
const chosenCluster = chooseCluster(availableCluster);
const client = await this.get(chosenCluster.name);
const grpcOptions: grpc.ClientOptions = {
...defaultGRPCOptions,
};
const client = await this.get(chosenCluster.name, grpcOptions);
return {
manager: client,
installation: chosenCluster.name,
Expand Down
14 changes: 5 additions & 9 deletions components/ws-manager-bridge/src/bridge-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { log } from '@gitpod/gitpod-protocol/lib/util/logging';
import { TLSConfig, WorkspaceClusterDB, WorkspaceClusterWoTLS } from "@gitpod/gitpod-protocol/lib/workspace-cluster";
import { WorkspaceCluster } from "@gitpod/gitpod-protocol/lib/workspace-cluster";
import { Queue } from "@gitpod/gitpod-protocol";
import { defaultGRPCOptions } from '@gitpod/gitpod-protocol/lib/util/grpc';
import * as grpc from '@grpc/grpc-js';

@injectable()
export class BridgeController {
Expand Down Expand Up @@ -84,16 +86,10 @@ export class BridgeController {

protected async createAndStartBridge(cluster: WorkspaceClusterInfo): Promise<WorkspaceManagerBridge> {
const bridge = this.bridgeFactory() as WorkspaceManagerBridge;
const grpcOptions: grpc.ClientOptions = {
...defaultGRPCOptions,
};
const clientProvider = async () => {
const grpcOptions = {
"grpc.keepalive_timeout_ms": 1000,
"grpc.keepalive_time_ms": 5000,
"grpc.http2.min_time_between_pings_ms": 1000,
"grpc.keepalive_permit_without_calls": 1,
"grpc-node.max_session_memory": 50,
"grpc.max_reconnect_backoff_ms": 5000,
};

return this.clientProvider.get(cluster.name, grpcOptions);
}
bridge.start(cluster, clientProvider);
Expand Down