From fc85dd4b2687f72eb0c6458ce8ee4b04c544b73c Mon Sep 17 00:00:00 2001 From: "Lee E. Hinman" Date: Thu, 28 Sep 2023 14:30:27 -0500 Subject: [PATCH] add check for underAgent and DiskQueue --- libbeat/cmd/instance/beat.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/libbeat/cmd/instance/beat.go b/libbeat/cmd/instance/beat.go index 27af71050207..925246b8038b 100644 --- a/libbeat/cmd/instance/beat.go +++ b/libbeat/cmd/instance/beat.go @@ -64,8 +64,10 @@ import ( "github.com/elastic/beats/v7/libbeat/outputs/elasticsearch" "github.com/elastic/beats/v7/libbeat/plugin" "github.com/elastic/beats/v7/libbeat/pprof" + "github.com/elastic/beats/v7/libbeat/publisher" "github.com/elastic/beats/v7/libbeat/publisher/pipeline" "github.com/elastic/beats/v7/libbeat/publisher/processing" + "github.com/elastic/beats/v7/libbeat/publisher/queue/diskqueue" "github.com/elastic/beats/v7/libbeat/version" "github.com/elastic/elastic-agent-libs/config" "github.com/elastic/elastic-agent-libs/file" @@ -838,6 +840,10 @@ func (b *Beat) configure(settings Settings) error { if err != nil { return err } + err = checkAgentDiskQueue(&b.Config) + if err != nil { + return err + } if err := b.Manager.CheckRawConfig(b.RawConfig); err != nil { return err @@ -1513,3 +1519,20 @@ func (bc *beatConfig) Validate() error { } return nil } + +// checkAgentDiskQueue should be run after management.NewManager() so +// that publisher.UnderAgent will be set with correct value +func checkAgentDiskQueue(bc *beatConfig) error { + //restriction is only if under agent + if !publisher.UnderAgent() { + return nil + } + //default queue settings are always allowed + if !bc.Pipeline.Queue.IsSet() { + return nil + } + if bc.Pipeline.Queue.Config().Enabled() && bc.Pipeline.Queue.Name() == diskqueue.QueueType { + return fmt.Errorf("disk queue is not supported under elastic-agent") + } + return nil +}