Skip to content

Add support for large NGINX config file sizes #1053

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

Open
wants to merge 2 commits into
base: v3
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,19 @@ func registerClientFlags(fs *flag.FlagSet) {
fs.Int(
ClientGRPCMaxMessageReceiveSizeKey,
DefMaxMessageRecieveSize,
"Updates the client grpc setting MaxRecvMsgSize with the specific value in MB.",
"Updates the client grpc setting MaxRecvMsgSize with the specific value in bytes.",
)

fs.Int(
ClientGRPCMaxMessageSendSizeKey,
DefMaxMessageSendSize,
"Updates the client grpc setting MaxSendMsgSize with the specific value in MB.",
"Updates the client grpc setting MaxSendMsgSize with the specific value in bytes.",
)

fs.Uint32(
ClientGRPCFileChunkSizeKey,
DefFileChunkSize,
"File chunk size in bytes.",
)
}

Expand Down Expand Up @@ -611,6 +617,7 @@ func resolveClient() *Client {
MaxMessageSize: viperInstance.GetInt(ClientGRPCMaxMessageSizeKey),
MaxMessageReceiveSize: viperInstance.GetInt(ClientGRPCMaxMessageReceiveSizeKey),
MaxMessageSendSize: viperInstance.GetInt(ClientGRPCMaxMessageSendSizeKey),
FileChunkSize: viperInstance.GetUint32(ClientGRPCFileChunkSizeKey),
},
Backoff: &BackOff{
InitialInterval: viperInstance.GetDuration(ClientBackoffInitialIntervalKey),
Expand Down
2 changes: 2 additions & 0 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func checkDefaultsClientValues(t *testing.T, viperInstance *viper.Viper) {
assert.Equal(t, DefMaxMessageSize, viperInstance.GetInt(ClientGRPCMaxMessageSizeKey))
assert.Equal(t, DefMaxMessageRecieveSize, viperInstance.GetInt(ClientGRPCMaxMessageReceiveSizeKey))
assert.Equal(t, DefMaxMessageSendSize, viperInstance.GetInt(ClientGRPCMaxMessageSendSizeKey))
assert.Equal(t, DefFileChunkSize, viperInstance.GetUint32(ClientGRPCFileChunkSizeKey))
assert.Equal(t, make(map[string]string), viperInstance.GetStringMapString(LabelsRootKey))
}

Expand Down Expand Up @@ -746,6 +747,7 @@ func createConfig() *Config {
MaxMessageSize: 1048575,
MaxMessageReceiveSize: 1048575,
MaxMessageSendSize: 1048575,
FileChunkSize: 48575,
},
Backoff: &BackOff{
InitialInterval: 200 * time.Millisecond,
Expand Down
8 changes: 4 additions & 4 deletions internal/config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package config

import (
"math"
"time"

pkg "github.com/nginx/agent/v3/pkg/config"
Expand All @@ -28,9 +27,10 @@ const (
DefCommandTLServerNameKey = ""

// Client GRPC Settings
DefMaxMessageSize = 0 // 0 = unset
DefMaxMessageRecieveSize = 4194304 // default 4 MB
DefMaxMessageSendSize = math.MaxInt32
DefMaxMessageSize = 0 // 0 = unset
DefMaxMessageRecieveSize = 4194304 // default 4 MB
DefMaxMessageSendSize = 4194304 // default 4 MB
DefFileChunkSize uint32 = 2097152 // 2MB

// Client HTTP Settings
DefHTTPTimeout = 10 * time.Second
Expand Down
1 change: 1 addition & 0 deletions internal/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var (
ClientGRPCMaxMessageSendSizeKey = pre(ClientRootKey) + "grpc_max_message_send_size"
ClientGRPCMaxMessageReceiveSizeKey = pre(ClientRootKey) + "grpc_max_message_receive_size"
ClientGRPCMaxMessageSizeKey = pre(ClientRootKey) + "grpc_max_message_size"
ClientGRPCFileChunkSizeKey = pre(ClientRootKey) + "grpc_file_chunk_size"

ClientBackoffInitialIntervalKey = pre(ClientRootKey) + "backoff_initial_interval"
ClientBackoffMaxIntervalKey = pre(ClientRootKey) + "backoff_max_interval"
Expand Down
1 change: 1 addition & 0 deletions internal/config/testdata/nginx-agent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ client:
max_message_size: 1048575
max_message_receive_size: 1048575
max_message_send_size: 1048575
file_chunk_size: 48575
backoff:
initial_interval: 200ms
max_interval: 10s
Expand Down
11 changes: 5 additions & 6 deletions internal/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,11 @@ type (
}

GRPC struct {
KeepAlive *KeepAlive `yaml:"-" mapstructure:"target"`
// if MaxMessageSize is size set then we use that value,
// otherwise MaxMessageRecieveSize and MaxMessageSendSize for individual settings
MaxMessageSize int `yaml:"-" mapstructure:"max_message_size"`
MaxMessageReceiveSize int `yaml:"-" mapstructure:"max_message_receive_size"`
MaxMessageSendSize int `yaml:"-" mapstructure:"max_message_send_size"`
KeepAlive *KeepAlive `yaml:"-" mapstructure:"target"`
MaxMessageSize int `yaml:"-" mapstructure:"max_message_size"`
MaxMessageReceiveSize int `yaml:"-" mapstructure:"max_message_receive_size"`
MaxMessageSendSize int `yaml:"-" mapstructure:"max_message_send_size"`
FileChunkSize uint32 `yaml:"file_chunk_size" mapstructure:"file_chunk_size"`
}

KeepAlive struct {
Expand Down
Loading