Skip to content

Commit

Permalink
feat(crux): add an env to set grpc maxReceiveMessageLength
Browse files Browse the repository at this point in the history
  • Loading branch information
m8vago committed Apr 8, 2024
1 parent b1f910f commit 157d943
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
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)
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
13 changes: 5 additions & 8 deletions web/crux/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,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 +101,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 +127,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

0 comments on commit 157d943

Please sign in to comment.