diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index b854db26050f..c27fd06a7509 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -99,6 +99,7 @@ field. You can revert this change by configuring tags for the module and omittin - Fix panic when assigning a key to a `nil` value in an event. {pull}18143[18143] - Gives monitoring reporter hosts, if configured, total precedence over corresponding output hosts. {issue}17937[17937] {pull}17991[17991] - Change `decode_json_fields` processor, to merge parsed json objects with existing objects in the event instead of fully replacing them. {pull}17958[17958] +- [Autodiscover] Check if runner is already running before starting again. {pull}18564[18564] - Fix `keystore add` hanging under Windows. {issue}18649[18649] {pull}18654[18654] *Auditbeat* diff --git a/libbeat/cfgfile/list.go b/libbeat/cfgfile/list.go index d3b05994e9ab..975dcee1c288 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 9d28187a5034..3977efabaf08 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)