Skip to content

Commit

Permalink
feat(crux): add env to set grpc maxReceiveMessageLength (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
m8vago authored Apr 9, 2024
1 parent b1f910f commit 82b6889
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 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
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

0 comments on commit 82b6889

Please sign in to comment.