From 4a66f8fe4be69ef9a7de048790b3ab4dcd927b6b Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 15 Nov 2018 13:26:25 +0100 Subject: [PATCH] Fix race condition when enriching events with Kubernetes metadata (#9067) (#9075) (cherry picked from commit 936949daea57fddd9abbb13f91c61e752a9e4a77) --- CHANGELOG.asciidoc | 2 ++ metricbeat/module/kubernetes/util/kubernetes.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 74b19ff2abe..a980bbb8aa2 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -37,6 +37,8 @@ https://github.com/elastic/beats/compare/v6.4.3...6.4[Check the HEAD diff] *Metricbeat* +- Fix race condition when enriching events with kubernetes metadata. {issue}9055[9055] {issue}9067[9067] + *Packetbeat* *Winlogbeat* diff --git a/metricbeat/module/kubernetes/util/kubernetes.go b/metricbeat/module/kubernetes/util/kubernetes.go index 43cbbc25f9a..8047e08bbb0 100644 --- a/metricbeat/module/kubernetes/util/kubernetes.go +++ b/metricbeat/module/kubernetes/util/kubernetes.go @@ -294,6 +294,8 @@ func (m *enricher) Stop() { } func (m *enricher) Enrich(events []common.MapStr) { + m.RLock() + defer m.RUnlock() for _, event := range events { if meta := m.metadata[m.index(event)]; meta != nil { event.DeepUpdate(common.MapStr{