mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-26 08:39:06 +02:00
Connections to the daemon were left on gRPC's own defaults, which cap a received message at 4 MB. A detailed status carries an entry per peer, so on a large deployment the response outgrows that cap and the command fails outright: netbird status -d Error: status failed: grpc: received message larger than max (4287609 vs. 4194304) The limit is raised where the daemon dial options are built, so every caller inherits it: the CLI, the desktop UI, the JSON gateway, and the SSH client and proxy. It is overridable through NB_DAEMON_GRPC_MAX_MSG_SIZE for a deployment that outgrows the new default too, mirroring what the management client already does with NB_MANAGEMENT_GRPC_MAX_MSG_SIZE, and reusing its 16 MB default. Only the receive direction needs raising. Requests to the daemon are small, and gRPC does not cap the send side by default, so the daemon could already send a response the caller then refused to read.
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package daemonaddr
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
const (
|
|
// EnvMaxRecvMsgSize overrides the default gRPC max receive message size for
|
|
// connections to the daemon. Value is in bytes.
|
|
EnvMaxRecvMsgSize = "NB_DAEMON_GRPC_MAX_MSG_SIZE"
|
|
|
|
// defaultMaxRecvMsgSize is the max gRPC receive message size used for daemon
|
|
// connections when EnvMaxRecvMsgSize is unset or invalid. It overrides the
|
|
// gRPC library default of 4 MB, which a detailed status already exceeds on a
|
|
// network of a few thousand peers.
|
|
defaultMaxRecvMsgSize = 1024 * 1024 * 16
|
|
)
|
|
|
|
// MaxRecvMsgSize returns the max gRPC receive message size for daemon connections
|
|
// from the environment, or defaultMaxRecvMsgSize (16 MB) if unset or invalid.
|
|
func MaxRecvMsgSize() int {
|
|
val := os.Getenv(EnvMaxRecvMsgSize)
|
|
if val == "" {
|
|
return defaultMaxRecvMsgSize
|
|
}
|
|
|
|
size, err := strconv.Atoi(val)
|
|
if err != nil {
|
|
log.Warnf("invalid %s value %q, using default: %v", EnvMaxRecvMsgSize, val, err)
|
|
return defaultMaxRecvMsgSize
|
|
}
|
|
|
|
if size <= 0 {
|
|
log.Warnf("invalid %s value %d, must be positive, using default", EnvMaxRecvMsgSize, size)
|
|
return defaultMaxRecvMsgSize
|
|
}
|
|
|
|
return size
|
|
}
|