Skip to content

Commit

Permalink
Move Manager.Start() and Manager.Stop() in the beat execution.
Browse files Browse the repository at this point in the history
This move the Manager.Start and Stop into the Beats' run method, this
move ensure that the system is configured and ready to receive events.

Having the Manager started and stopped at the Libbeat level was causing
inconsistency when configuring the Beats by the Elastic Agent.
The problem would lead to the following behavior:

- Zombie Beats with only outputs configured
- Beats without any inputs configured
- Beats with some of the input configured.

The problem was often cause by restarting the agent and having the
machine under a significant load.

See: elastic/beats#30694 for details
  • Loading branch information
ph authored and axw committed Mar 17, 2022
1 parent 2060c98 commit f6422a1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions beater/beater.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@ func (bt *beater) run(ctx context.Context, cancelContext context.CancelFunc, b *
ctx, reload.ReloadableFunc(reloader.reloadOutput),
)
})

// Start the manager after all the hooks are initialized
// and defined this ensure reloading consistency..
if err := b.Manager.Start(); err != nil {
return err
}
defer b.Manager.Stop()

} else {
// Management disabled, use statically defined config.
reloader.namespace = "default"
Expand Down

0 comments on commit f6422a1

Please sign in to comment.