Skip to content
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

feat(crux): add an env to set grpc maxReceiveMessageLength #950

Merged
merged 2 commits into from
Apr 9, 2024
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: 4 additions & 0 deletions web/crux/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ MAX_CONTAINER_LOG_TAKE=1000
# Determines how much time an agent callback has to execute
AGENT_CALLBACK_TIMEOUT=5000

# Maximum accepted message size sent by the agent in bytes
# defaults to 4 Megabytes
# MAX_GRPC_RECEIVE_MESSAGE_LENGTH=4194304

# For overriding the node DNS result order
# regardless of the NODE_ENV value
# It may be necessary for running the e2e tests,
Expand Down
1 change: 1 addition & 0 deletions web/crux/src/app/node/node.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,6 @@ export class ContainerInspectionDto {
export class NodeContainerLogQuery {
@IsPositive()
@IsOptional()
@Type(() => Number)
m8vago marked this conversation as resolved.
Show resolved Hide resolved
take?: number
}
1 change: 1 addition & 0 deletions web/crux/src/config/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const configSchema = yup.object({

MAX_CONTAINER_LOG_TAKE: yup.number().optional(),
AGENT_CALLBACK_TIMEOUT: yup.number().optional(),
MAX_GRPC_RECEIVE_MESSAGE_LENGTH: yup.number().optional(),
})

class InvalidEnvironmentError extends Error {
Expand Down
18 changes: 5 additions & 13 deletions web/crux/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ import DyoWsAdapter from './websockets/dyo.ws.adapter'

const HOUR_IN_MS: number = 60 * 60 * 1000

type GrpcOptions = {
url: string
credentials: ServerCredentials
}

const CRUX_COMMANDS = ['serve', 'encrypt'] as const
type CruxCommand = (typeof CRUX_COMMANDS)[number]

Expand All @@ -48,12 +43,6 @@ const parseCruxCommand = (args: string[]): CruxCommand | null => {
return command as CruxCommand
}

const loadGrpcOptions = (port: number): GrpcOptions => ({
// tls termination occurs at the reverse proxy
credentials: ServerCredentials.createInsecure(),
url: `0.0.0.0:${port}`,
})

const createLogger = (): Logger | LogLevel[] => {
if (process.env.NODE_ENV === 'production') {
return new Logger()
Expand Down Expand Up @@ -107,7 +96,7 @@ const serve = async () => {
const document = SwaggerModule.createDocument(app, config)
SwaggerModule.setup('/api/swagger', app, document)

const agentOptions = loadGrpcOptions(configService.get<number>('GRPC_AGENT_PORT'))
const agentPort = configService.get<number>('GRPC_AGENT_PORT')
const httpOptions = configService.get<number>('HTTP_API_PORT')
const metricsApiPort = configService.get<number>('METRICS_API_PORT')

Expand All @@ -133,7 +122,10 @@ const serve = async () => {
package: ['agent'],
protoPath: [join(__dirname, '../proto/agent.proto'), join(__dirname, '../proto/common.proto')],
keepalive: { keepaliveTimeoutMs: HOUR_IN_MS },
...agentOptions,
// tls termination occurs at the reverse proxy
credentials: ServerCredentials.createInsecure(),
url: `0.0.0.0:${agentPort}`,
maxReceiveMessageLength: configService.get('MAX_GRPC_RECEIVE_MESSAGE_LENGTH'),
},
})

Expand Down
Loading