ribbybibby / s3_exporter

Exports Prometheus metrics about S3 buckets and objects
Apache License 2.0
104 stars 42 forks source link

Crash on invalid resp object #18

Closed nerzhul closed 3 years ago

nerzhul commented 3 years ago

Hello, thanks for this very nice project, it's exactly what we needed at work for our use-case.

Just to report you a bug, we have a cephs3 and we use path style model. On initial setup i forgot the option and this triggers this crash (on today master)

INFO[0000] Starting s3_exporter (version=, branch=, revision=)  source="s3_exporter.go:190"
INFO[0000] Build context (go=go1.15.3, user=, date=)     source="s3_exporter.go:191"
INFO[0000] Listening on :9340                            source="s3_exporter.go:208"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xb4b798]

goroutine 43 [running]:
main.(*Exporter).Collect(0xc0001f2f00, 0xc00012f320)
    /home/lblot/Devel/VP/s3_exporter/s3_exporter.go:110 +0x218
github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func1()
    /home/lblot/Devel/VP/s3_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:444 +0x1a2
created by github.com/prometheus/client_golang/prometheus.(*Registry).Gather
    /home/lblot/Devel/VP/s3_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:455 +0x5ce

You should handle it :)

After that option fixed, i'm just burning my PC on a 700GB gitlab artifact bucket :trollface:

ribbybibby commented 3 years ago

Hi @nerzhul, thanks for pointing this out! I've raised a PR with a fix for the nil pointer dereference: https://github.com/ribbybibby/s3_exporter/pull/19.

Could you try and reproduce with this branch? I spent some time trying to set ceph up locally but I couldn't reproduce it.

It's quite interesting that you managed to reach this part of the code. I would have expected an error to be returned if the path style was wrong. Perhaps ceph returns an empty list response or something.

ribbybibby commented 3 years ago

Should be fixed in v0.4.1.