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 panics when API calls fail #41

Merged
merged 1 commit into from
Feb 24, 2024
Merged

Conversation

BeryJu
Copy link
Contributor

@BeryJu BeryJu commented Feb 22, 2024

every so often my instance will panic due to some network hiccup:

2024/02/22 21:22:42.704302 ERROR RESTY Get "https://api.linode.com/v4/account": read tcp 10.244.0.202:42616->88.221.221.99:443: read: connection reset by peer, Attempt 1
{"level":"info","msg":"[002] Get \"https://api.linode.com/v4/account\": read tcp 10.244.0.202:42616-\u003e88.221.221.99:443: read: connection reset by peer","time":"2024-02-22T21:22:42Z"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x7e5b3e]

goroutine 142 [running]:
github.com/DazWilkin/linode-exporter/collector.(*AccountCollector).Collect(0xc000234300, 0xc0001e7f60?)
	/linode-exporter/collector/account.go:57 +0xde
github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func1()
	/go/pkg/mod/github.com/prometheus/client_golang@v1.2.1/prometheus/registry.go:443 +0x10d
created by github.com/prometheus/client_golang/prometheus.(*Registry).Gather
	/go/pkg/mod/github.com/prometheus/client_golang@v1.2.1/prometheus/registry.go:535 +0xb0c

This PR should prevent this by returning early when an API Client returns an error

@BeryJu BeryJu mentioned this pull request Feb 22, 2024
@DazWilkin
Copy link
Owner

Ugh, thanks for catching all these.

That's poor form on my part.

@DazWilkin DazWilkin merged commit 8a9d5c9 into DazWilkin:master Feb 24, 2024
@BeryJu BeryJu deleted the fix-panic branch February 24, 2024 18:52
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.

None yet

2 participants