diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 3996d4299c9..5e646f05d79 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -112,6 +112,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Fix panic when assigning a key to a `nil` value in an event. {pull}18143[18143] - Change `decode_json_fields` processor, to merge parsed json objects with existing objects in the event instead of fully replacing them. {pull}17958[17958] - Gives monitoring reporter hosts, if configured, total precedence over corresponding output hosts. {issue}17937[17937] {pull}17991[17991] +- [Autodiscover] Check if runner is already running before starting again. {pull}18564[18564] *Auditbeat* diff --git a/libbeat/cfgfile/list.go b/libbeat/cfgfile/list.go index db02c56bbdd..1f3b2a7269b 100644 --- a/libbeat/cfgfile/list.go +++ b/libbeat/cfgfile/list.go @@ -70,7 +70,7 @@ func (r *RunnerList) Reload(configs []*reload.ConfigWithMeta) error { continue } - if _, ok := stopList[hash]; ok { + if _, ok := r.runners[hash]; ok { delete(stopList, hash) } else { startList[hash] = config diff --git a/libbeat/cfgfile/list_test.go b/libbeat/cfgfile/list_test.go index 9d28187a503..3977efabaf0 100644 --- a/libbeat/cfgfile/list_test.go +++ b/libbeat/cfgfile/list_test.go @@ -103,6 +103,28 @@ func TestReloadSameConfigs(t *testing.T) { assert.Equal(t, state, list.copyRunnerList()) } +func TestReloadDuplicateConfig(t *testing.T) { + factory := &runnerFactory{} + list := NewRunnerList("", factory, nil) + + list.Reload([]*reload.ConfigWithMeta{ + createConfig(1), + }) + + state := list.copyRunnerList() + assert.Equal(t, len(state), 1) + + // This can happen in Autodiscover when a container if getting restarted + // but the previous one is not cleaned yet. + list.Reload([]*reload.ConfigWithMeta{ + createConfig(1), + createConfig(1), + }) + + // nothing changed + assert.Equal(t, state, list.copyRunnerList()) +} + func TestReloadStopConfigs(t *testing.T) { factory := &runnerFactory{} list := NewRunnerList("", factory, nil)