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

[Metricbeat AWS] check if cpuOptions is nil in DescribeInstances output #17418

Merged
merged 3 commits into from
Apr 3, 2020
Merged

[Metricbeat AWS] check if cpuOptions is nil in DescribeInstances output #17418

merged 3 commits into from
Apr 3, 2020

Conversation

kaiyan-sheng
Copy link
Contributor

@kaiyan-sheng kaiyan-sheng commented Apr 1, 2020

I cannot reproduce this error with my AWS account. But based on the error message in the bug report #17392, I believe it is caused by response body of DescribeInstances API has empty cpuOptions:

2020-04-01T12:57:03.827+0200	ERROR	runtime/panic.go:199	recovered from panic while
fetching 'aws/ec2' for host ''. Recovering, but please report this.	{"panic": "runtime error: 
invalid memory address or nil pointer dereference", "stack": 
"github.com/elastic/beats/libbeat/logp.Recover\n\t/go/src/github.com/elastic/beats/libbeat/logp/
global.go:105\nruntime.gopanic\n\t/usr/local/go/src/runtime/panic.go:679\nruntime.panicmem\n
\t/usr/local/go/src/runtime/panic.go:199\nruntime.sigpanic\n\t/usr/local/go/src/runtime/signal_un
ix.go:394\ngithub.com/elastic/beats/x-pack/metricbeat/module/aws/ec2.
(*MetricSet).createCloudWatchEvents\n\t/go/src/github.com/elastic/beats/x-
pack/metricbeat/module/aws/ec2/ec2.go:238\ngithub.com/elastic/beats/x-
pack/metricbeat/module/aws/ec2.(*MetricSet).Fetch\n\t/go/src/github.com/elastic/beats/x-
pack/metricbeat/module/aws/ec2/ec2.go:133\ngithub.com/elastic/beats/metricbeat/mb/module.
(*metricSetWrapper).fetch\n\t/go/src/github.com/elastic/beats/metricbeat/mb/module/wrapper.
go:249\ngithub.com/elastic/beats/metricbeat/mb/module.
(*metricSetWrapper).startPeriodicFetching\n\t/go/src/github.com/elastic/beats/metricbeat/mb/
module/wrapper.go:217\ngithub.com/elastic/beats/metricbeat/mb/module.
(*metricSetWrapper).run\n\t/go/src/github.com/elastic/beats/metricbeat/mb/module/wrapper.go
:201\ngithub.com/elastic/beats/metricbeat/mb/module.
(*Wrapper).Start.func1\n\t/go/src/github.com/elastic/beats/metricbeat/mb/module/wrapper.go:1
40"}

This PR is to fix the error by checking if cpuOptions is nil first before evaluating cpuOptions. Similarly, I also added the check for Placement field.

@kaiyan-sheng kaiyan-sheng self-assigned this Apr 1, 2020
@kaiyan-sheng kaiyan-sheng added bug Metricbeat Metricbeat needs_backport PR is waiting to be backported to other branches. Team:Platforms Label for the Integrations - Platforms team labels Apr 1, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-platforms (Team:Platforms)

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Changelog?

@kaiyan-sheng
Copy link
Contributor Author

@blakerouse Just added the changelog, good catch! Thanks!

@kaiyan-sheng kaiyan-sheng merged commit 8d43169 into elastic:master Apr 3, 2020
@kaiyan-sheng kaiyan-sheng deleted the ec2_nil_pointer branch April 3, 2020 01:34
@kaiyan-sheng kaiyan-sheng added v7.8.0 and removed needs_backport PR is waiting to be backported to other branches. labels Apr 3, 2020
kaiyan-sheng added a commit that referenced this pull request Apr 3, 2020
…ut (#17418) (#17459)

* check if cpuOptions is nil

(cherry picked from commit 8d43169)
kaiyan-sheng added a commit that referenced this pull request Apr 3, 2020
…ut (#17418) (#17458)

* check if cpuOptions is nil

(cherry picked from commit 8d43169)
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
…ut (elastic#17418) (elastic#17459)

* check if cpuOptions is nil

(cherry picked from commit 1c48809)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Metricbeat Metricbeat Team:Platforms Label for the Integrations - Platforms team v7.7.0 v7.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants