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 (#18564)
  • Loading branch information
ChrsMark authored May 21, 2020
1 parent 34af60d commit b0f7ae7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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*
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 b0f7ae7

Please sign in to comment.