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

Fix nil pointer exception in kubeletstats receiver #404

Conversation

dmitryax
Copy link
Member

@dmitryax dmitryax commented Jul 7, 2020

Description:
Looks like some stats can be absent for the pods that are just created. And it causes crashing the otel agent with nil pointer exception.

Stacktrace:

goroutine 93 [running]:
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver/kubelet.applyLabels(...)
	/home/circleci/project/receiver/kubeletstatsreceiver/kubelet/utils.go:62
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver/kubelet.rxBytesMetric(0x2b05180, 0x8, 0xc00f0caae0, 0xc00064edb8)
	/home/circleci/project/receiver/kubeletstatsreceiver/kubelet/network.go:34 +0x1d7
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver/kubelet.networkMetrics(0x2b05180, 0x8, 0xc00f0caae0, 0xc00edcff00, 0x3, 0x3)
	/home/circleci/project/receiver/kubeletstatsreceiver/kubelet/network.go:25 +0x43
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver/kubelet.(*metricDataAccumulator).podStats(0xc00d999ac0, 0xc00f1a7d80, 0xc00eff3380, 0x27, 0xc00edd5120, 0x11, 0xc00eff33b0, 0x24, 0x0, 0xed695ea54, ...)
	/home/circleci/project/receiver/kubeletstatsreceiver/kubelet/accumulator.go:57 +0x156
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver/kubelet.MetricsData(0xc00e3493b0, 0x2b0c3e3, 0xc, 0x0, 0x2afeeb0, 0x4)
	/home/circleci/project/receiver/kubeletstatsreceiver/kubelet/metrics.go:28 +0x392
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver.(*runnable).Run(0xc00e177140, 0xc00e1f4f50, 0xc00e1f4f01)
	/home/circleci/project/receiver/kubeletstatsreceiver/runnable.go:68 +0x101
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/redisreceiver/interval.(*Runner).run(0xc00e1c5420, 0x0, 0x0)
	/home/circleci/project/receiver/redisreceiver/interval/interval_runner.go:74 +0xba
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/redisreceiver/interval.(*Runner).Start(0xc00e1c5420, 0x0, 0x0)
	/home/circleci/project/receiver/redisreceiver/interval/interval_runner.go:54 +0x4c
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver.(*receiver).Start.func1(0xc00e176d40, 0x303bd20, 0xc0001bef00)
	/home/circleci/project/receiver/kubeletstatsreceiver/receiver.go:47 +0x2f
created by github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver.(*receiver).Start
	/home/circleci/project/receiver/kubeletstatsreceiver/receiver.go:46 +0x1d7

For the pods that are just created, some stats can be absent. And it causes crashing the otel agent with nil pointer exception.
@dmitryax dmitryax requested a review from a team July 7, 2020 17:09
Copy link
Member

@pmcollins pmcollins left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov
Copy link

codecov bot commented Jul 7, 2020

Codecov Report

Merging #404 into master will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #404      +/-   ##
==========================================
- Coverage   84.04%   84.02%   -0.02%     
==========================================
  Files         178      178              
  Lines        9528     9529       +1     
==========================================
- Hits         8008     8007       -1     
- Misses       1195     1196       +1     
- Partials      325      326       +1     
Flag Coverage Δ
#integration 63.31% <ø> (ø)
#unit 83.82% <100.00%> (-0.02%) ⬇️
Impacted Files Coverage Δ
receiver/kubeletstatsreceiver/kubelet/utils.go 100.00% <100.00%> (ø)
receiver/carbonreceiver/transport/tcp_server.go 65.71% <0.00%> (-1.91%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4e6b676...74bcfac. Read the comment docs.

@bogdandrutu bogdandrutu merged commit 3d8fc69 into open-telemetry:master Jul 7, 2020
wyTrivail referenced this pull request in mxiamxia/opentelemetry-collector-contrib Jul 13, 2020
For the pods that are just created, some stats can be absent. And it causes crashing the otel agent with nil pointer exception.
mxiamxia referenced this pull request in mxiamxia/opentelemetry-collector-contrib Jul 22, 2020
…ver (#404)

* migrate code base to use "github.com/stretchr/testify/require" in receiver/opencensusreceiver

* fix go vet warning

* use require.Equal
ljmsc referenced this pull request in ljmsc/opentelemetry-collector-contrib Feb 21, 2022
* add option.File for stdout output

* Unify the naming of `Writer` field (io.Writer) in Options
codeboten pushed a commit that referenced this pull request Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants