From 304b185ddf1576a4829436eafb3fd41fe5467d56 Mon Sep 17 00:00:00 2001 From: Pier-Hugues Pellerin Date: Thu, 28 Jun 2018 15:00:12 -0400 Subject: [PATCH 1/4] When we fail to build an indexer or matcher we should not add them to the execution. --- libbeat/processors/add_kubernetes_metadata/indexers.go | 3 ++- libbeat/processors/add_kubernetes_metadata/matchers.go | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libbeat/processors/add_kubernetes_metadata/indexers.go b/libbeat/processors/add_kubernetes_metadata/indexers.go index 218dea5fe2a0..a823e3a7f899 100644 --- a/libbeat/processors/add_kubernetes_metadata/indexers.go +++ b/libbeat/processors/add_kubernetes_metadata/indexers.go @@ -60,7 +60,7 @@ type Indexers struct { // IndexerConstructor builds a new indexer from its settings type IndexerConstructor func(config common.Config, metaGen kubernetes.MetaGenerator) (Indexer, error) -// NewIndexers builds indexers object +// NewIndexers builds indexers object func NewIndexers(configs PluginConfig, metaGen kubernetes.MetaGenerator) *Indexers { indexers := []Indexer{} for _, pluginConfigs := range configs { @@ -74,6 +74,7 @@ func NewIndexers(configs PluginConfig, metaGen kubernetes.MetaGenerator) *Indexe indexer, err := indexFunc(pluginConfig, metaGen) if err != nil { logp.Warn("Unable to initialize indexing plugin %s due to error %v", name, err) + continue } indexers = append(indexers, indexer) diff --git a/libbeat/processors/add_kubernetes_metadata/matchers.go b/libbeat/processors/add_kubernetes_metadata/matchers.go index 5872fec27486..5e5a403f0e0b 100644 --- a/libbeat/processors/add_kubernetes_metadata/matchers.go +++ b/libbeat/processors/add_kubernetes_metadata/matchers.go @@ -62,6 +62,7 @@ func NewMatchers(configs PluginConfig) *Matchers { matcher, err := matchFunc(pluginConfig) if err != nil { logp.Warn("Unable to initialize matcher plugin %s due to error %v", name, err) + continue } matchers = append(matchers, matcher) From 9e76bc5511bf108d37b7bbf559f206d27b4c52c0 Mon Sep 17 00:00:00 2001 From: Pier-Hugues Pellerin Date: Thu, 28 Jun 2018 15:01:39 -0400 Subject: [PATCH 2/4] Empty() predicates should be behind a mutex --- libbeat/processors/add_kubernetes_metadata/indexers.go | 2 ++ libbeat/processors/add_kubernetes_metadata/matchers.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libbeat/processors/add_kubernetes_metadata/indexers.go b/libbeat/processors/add_kubernetes_metadata/indexers.go index a823e3a7f899..49e23665b0e4 100644 --- a/libbeat/processors/add_kubernetes_metadata/indexers.go +++ b/libbeat/processors/add_kubernetes_metadata/indexers.go @@ -114,6 +114,8 @@ func (i *Indexers) GetMetadata(pod *kubernetes.Pod) []MetadataIndex { // Empty returns true if indexers list is empty func (i *Indexers) Empty() bool { + i.RLock() + defer i.RUnlock() if len(i.indexers) == 0 { return true } diff --git a/libbeat/processors/add_kubernetes_metadata/matchers.go b/libbeat/processors/add_kubernetes_metadata/matchers.go index 5e5a403f0e0b..61590821771f 100644 --- a/libbeat/processors/add_kubernetes_metadata/matchers.go +++ b/libbeat/processors/add_kubernetes_metadata/matchers.go @@ -90,6 +90,8 @@ func (m *Matchers) MetadataIndex(event common.MapStr) string { } func (m *Matchers) Empty() bool { + m.RLock() + defer m.RUnlock() if len(m.matchers) == 0 { return true } From 453a561992d4aa3f963e6f6645a60ef0cb114b3e Mon Sep 17 00:00:00 2001 From: Pier-Hugues Pellerin Date: Thu, 28 Jun 2018 15:04:05 -0400 Subject: [PATCH 3/4] changelog --- CHANGELOG.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index a8542fb3fce1..e2d681988356 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -73,6 +73,7 @@ https://github.com/elastic/beats/compare/v6.2.3...master[Check the HEAD diff] - Allow index-pattern only setup when setup.dashboards.only_index=true. {pull}7285[7285] - Fix duplicating dynamic_fields in template when overwriting the template. {pull}7352[7352] - Fix a panic on the Dissect processor when we have data remaining after the last delimiter. {pull}7449[7449] +- When we fail to build a Kubernetes' indexer or matcher we produce a warning but we don't them to the execution. {pull}7466[7466] *Auditbeat* From ec72d0b40710a52cd4a40ed33092f80fe618fcdd Mon Sep 17 00:00:00 2001 From: Pier-Hugues Pellerin Date: Thu, 28 Jun 2018 15:17:28 -0400 Subject: [PATCH 4/4] typo --- CHANGELOG.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index e2d681988356..470024053a0b 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -73,7 +73,7 @@ https://github.com/elastic/beats/compare/v6.2.3...master[Check the HEAD diff] - Allow index-pattern only setup when setup.dashboards.only_index=true. {pull}7285[7285] - Fix duplicating dynamic_fields in template when overwriting the template. {pull}7352[7352] - Fix a panic on the Dissect processor when we have data remaining after the last delimiter. {pull}7449[7449] -- When we fail to build a Kubernetes' indexer or matcher we produce a warning but we don't them to the execution. {pull}7466[7466] +- When we fail to build a Kubernetes' indexer or matcher we produce a warning but we don't add them to the execution. {pull}7466[7466] *Auditbeat*