Skip to content

Commit

Permalink
libbeat: Stop autodiscover runners in a goroutine (elastic#7170) (ela…
Browse files Browse the repository at this point in the history
…stic#7186)

Stopping runners can be a blocking operation, what can block the
autodiscover event loop. Run it in a goroutine so events can continue
being handled.

(cherry picked from commit eb58c3a)
  • Loading branch information
jsoriano authored and exekias committed May 29, 2018
1 parent 78e9fe7 commit 5822d55
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ https://github.com/elastic/beats/compare/v6.2.3...v6.3.0[View commits]
- Ensure Kubernetes labels/annotations don't break mapping {pull}6490[6490]
- Ensure that the dashboard zip files can't contain files outside of the kibana directory. {pull}6921[6921]
- Fix map overwrite panics by cloning shared structs before doing the update. {pull}6947[6947]
- Fix delays on autodiscovery events handling caused by blocking runner stops. {pull}7170[7170]
*Auditbeat*
Expand Down
6 changes: 5 additions & 1 deletion libbeat/autodiscover/autodiscover.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,12 @@ func (a *Autodiscover) handleStop(event bus.Event) {
}

if runner := a.runners.Get(hash); runner != nil {
// Stop can block, we run it asyncrhonously to avoid blocking
// the whole events loop. The runner hash is removed in any case
// so an equivalent configuration can be added again while this
// one stops, and a duplicated event don't try to stop it twice.
logp.Info("Autodiscover stopping runner: %s", runner)
runner.Stop()
go runner.Stop()
a.runners.Remove(hash)
} else {
logp.Debug(debugK, "Runner not found for stopping: %s", hash)
Expand Down

0 comments on commit 5822d55

Please sign in to comment.