From e77c4670d6c6aaab84f43b69fb5e2f3bbb3be910 Mon Sep 17 00:00:00 2001 From: Daniel Moran Date: Wed, 20 Jan 2021 12:44:43 -0800 Subject: [PATCH] feat(cmd/influxd): add `nats-max-payload-bytes` config option to influxd (#20564) --- CHANGELOG.md | 1 + cmd/influxd/launcher/cmd.go | 13 +++++++++++-- cmd/influxd/launcher/launcher.go | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da0e2811fcb..3500f8a54c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Replacement `tsi1` indexes will be automatically generated on startup for shards 1. [20473](https://github.com/influxdata/influxdb/pull/20473): Add `--overwrite-existing-v2` flag to `influxd upgrade` to overwrite existing files at output paths (instead of aborting). 1. [20524](https://github.com/influxdata/influxdb/pull/20524): Add `influxd print-config` command to support automated config inspection. 1. [20561](https://github.com/influxdata/influxdb/pull/20561): Add `nats-port` config option for `influxd` server. +1. [20564](https://github.com/influxdata/influxdb/pull/20564): Add `nats-max-payload-bytes` config option for `influxd` server. ### Bug Fixes diff --git a/cmd/influxd/launcher/cmd.go b/cmd/influxd/launcher/cmd.go index 517b59b39fb..3e567de4336 100644 --- a/cmd/influxd/launcher/cmd.go +++ b/cmd/influxd/launcher/cmd.go @@ -18,6 +18,7 @@ import ( "github.com/influxdata/influxdb/v2/storage" "github.com/influxdata/influxdb/v2/v1/coordinator" "github.com/influxdata/influxdb/v2/vault" + natsserver "github.com/nats-io/gnatsd/server" "github.com/spf13/cobra" "github.com/spf13/viper" "go.uber.org/zap/zapcore" @@ -128,7 +129,8 @@ type InfluxdOpts struct { SessionLength int // in minutes SessionRenewDisabled bool - NatsPort int + NatsPort int + NatsMaxPayloadBytes int NoTasks bool FeatureFlags map[string]string @@ -174,7 +176,8 @@ func newOpts(viper *viper.Viper) *InfluxdOpts { StoreType: BoltStore, SecretStore: BoltStore, - NatsPort: nats.RandomPort, + NatsPort: nats.RandomPort, + NatsMaxPayloadBytes: natsserver.MAX_PAYLOAD_SIZE, NoTasks: false, @@ -485,5 +488,11 @@ func (o *InfluxdOpts) bindCliOpts() []cli.Opt { Desc: fmt.Sprintf("Port that should be bound by the NATS streaming server. A value of %d will cause a random port to be selected.", nats.RandomPort), Default: o.NatsPort, }, + { + DestP: &o.NatsMaxPayloadBytes, + Flag: "nats-max-payload-bytes", + Desc: "The maximum number of bytes allowed in a NATS message payload.", + Default: o.NatsMaxPayloadBytes, + }, } } diff --git a/cmd/influxd/launcher/launcher.go b/cmd/influxd/launcher/launcher.go index 41e21c7372d..94498d97b49 100644 --- a/cmd/influxd/launcher/launcher.go +++ b/cmd/influxd/launcher/launcher.go @@ -573,6 +573,7 @@ func (m *Launcher) run(ctx context.Context, opts *InfluxdOpts) (err error) { // NATS streaming server natsOpts := nats.NewDefaultServerOptions() natsOpts.Port = opts.NatsPort + natsOpts.MaxPayload = opts.NatsMaxPayloadBytes m.natsServer = nats.NewServer(&natsOpts) if err := m.natsServer.Open(); err != nil { m.log.Error("Failed to start nats streaming server", zap.Error(err))