Cherry-pick #14329 to 7.4: [Metricbeat]Kubernetes: add nil check for kubernetes parent object check #14469
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cherry-pick of PR #14329 to 7.4 branch. Original message:
Any object using libbeat's
common/kubernetes.metagenerator.ResourceMetadata
method will try to grab its parent(s) object(s).If an object has no parent,
ref.Controller
(pointer to bool) will be nil which is making metricbeat panic in such cases.beats/libbeat/common/kubernetes/metadata.go
Lines 112 to 122 in 2a526ac
This PR adds a single liner to make sure the reference is not nil.
Fixes #14320
Related https://discuss.elastic.co/t/metricbeat-7-4-kubernetes-crash-on-startup/205479