Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick #14329 to 7.5: [Metricbeat]Kubernetes: add nil check for kubernetes parent object check #14431

Merged
merged 2 commits into from
Nov 12, 2019

Conversation

odacremolbap
Copy link
Contributor

@odacremolbap odacremolbap commented Nov 11, 2019

Cherry-pick of PR #14329 to 7.5 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.

for _, ref := range accessor.GetOwnerReferences() {
if *ref.Controller {
switch ref.Kind {
// TODO grow this list as we keep adding more `state_*` metricsets
case "Deployment",
"ReplicaSet",
"StatefulSet":
safemapstr.Put(meta, strings.ToLower(ref.Kind)+".name", ref.Name)
}
}
}

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

…eck (elastic#14329)

add nil check for kubernetes parent object

(cherry picked from commit d7d2c17)
@odacremolbap odacremolbap added the Team:Integrations Label for the Integrations team label Nov 12, 2019
@odacremolbap
Copy link
Contributor Author

CI issues are unrelated

@odacremolbap odacremolbap merged commit 6ef3fdc into elastic:7.5 Nov 12, 2019
@odacremolbap odacremolbap deleted the backport_14329_7.5 branch November 12, 2019 09:43
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
…ck for kubernetes parent object check (elastic#14431)

* [Metricbeat]Kubernetes: add nil check for kubernetes parent object check (elastic#14329)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport review Team:Integrations Label for the Integrations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants