Skip to content

Commit

Permalink
add check for underAgent and DiskQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
leehinman committed Oct 9, 2023
1 parent 094df3d commit fc85dd4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions libbeat/cmd/instance/beat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit fc85dd4

Please sign in to comment.