From 936949daea57fddd9abbb13f91c61e752a9e4a77 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Wed, 14 Nov 2018 17:09:56 +0100 Subject: [PATCH] Fix race condition when enriching events with Kubernetes metadata (#9067) --- CHANGELOG.asciidoc | 1 + metricbeat/module/kubernetes/util/kubernetes.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 21f9abdbab0..16da217dbfb 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -70,6 +70,7 @@ https://github.com/elastic/beats/compare/v6.4.0...master[Check the HEAD diff] - Fix golang.heap.gc.cpu_fraction type from long to float in Golang module. {pull}7789[7789] - Add missing namespace field in http server metricset {pull}7890[7890] +- Fix race condition when enriching events with kubernetes metadata. {issue}9055[9055] {issue}9067[9067] *Packetbeat* 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{