Skip to content

Commit

Permalink
[Autodiscover] Check if runner is already running before starting aga…
Browse files Browse the repository at this point in the history
…in (elastic#18564)

(cherry picked from commit b0f7ae7)
  • Loading branch information
ChrsMark committed May 21, 2020
1 parent 095947e commit c06cf5f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ 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]
- Fix `keystore add` hanging under Windows. {issue}18649[18649] {pull}18654[18654]

*Auditbeat*

Expand Down
2 changes: 1 addition & 1 deletion libbeat/cfgfile/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions libbeat/cfgfile/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c06cf5f

Please sign in to comment.