Skip to content

Commit

Permalink
Clone any cached data from docker and k8s (elastic#8240) (elastic#8246)
Browse files Browse the repository at this point in the history
Using cached data can lead to race condition if we have some reference
in place, this commit force a clone on the retrieved data so each event
has his own copy.

(cherry picked from commit b4a69c1)
  • Loading branch information
ph authored Sep 6, 2018
1 parent 58b06d3 commit 0d235f9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ https://github.com/elastic/beats/compare/v6.4.0...6.4[Check the HEAD diff]
- Add backoff support to x-pack monitoring outputs. {issue}7966[7966]
- Removed execute permissions systemd unit file. {pull}7873[7873]
- Fix a race condition with the `add_host_metadata` and the event serialization. {pull}8223[8223]
- Enforce that data used by k8s or docker doesn't use any reference. {pull}8240[8240]

*Auditbeat*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (d *addDockerMetadata) Run(event *beat.Event) (*beat.Event, error) {
meta.Put("container.id", container.ID)
meta.Put("container.image", container.Image)
meta.Put("container.name", container.Name)
event.Fields["docker"] = meta
event.Fields["docker"] = meta.Clone()
} else {
d.log.Debugf("Container not found: cid=%s", cid)
}
Expand Down
2 changes: 1 addition & 1 deletion libbeat/processors/add_kubernetes_metadata/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (k *kubernetesAnnotator) Run(event *beat.Event) (*beat.Event, error) {
}

event.Fields.DeepUpdate(common.MapStr{
"kubernetes": metadata,
"kubernetes": metadata.Clone(),
})

return event, nil
Expand Down

0 comments on commit 0d235f9

Please sign in to comment.