frebib / nzbget-exporter

NZBGet Prometheus metrics exporter
20 stars 5 forks source link

Build error #2

Closed jonny-ervine closed 2 years ago

jonny-ervine commented 2 years ago

The nzbget-exporter is generating an error when queried: curl http://nzbget-exporter:9452/metrics An error has occurred while serving metrics:

GOOD does not belong to DeleteStatus values

Trying to rebuild the exporter with Good being added to DeleteStatus brings a build error: ./collect.go:421:42: hi.ParStatus.String undefined (type ParStatus has no field or method String) ./collect.go:422:48: hi.UnpackStatus.String undefined (type UnpackStatus has no field or method String)

This hasn't changed though, and I get the same build error when trying to build the container image from the source here.

frebib commented 2 years ago

According to the documentation, GOOD is not a valid value for DeleteStatus, see https://nzbget.net/api/history. This sounds like an NzbGet bug to me. Is the issue reproducible?

To build you need to run go generate first: https://github.com/frebib/nzbget-exporter/blob/master/.drone.yml#L14

I'll push a change to update the documentation to make it more obvious how to build this

jonny-ervine commented 2 years ago

Thanks for the quick reply. The issue is reproducible insofar as that my history is returning this value. When I curl against the history API endpoint, then some history DeleteStatus values do have Good as a value. It sounds like NZBget have put this in without updating the API docs. If it helps, I'm running NZBget in a container on Alpine, and it is running 21.1

For the build, that makes sense to have to run go gneerate beforehand - is this not run as part of the container build in the Dockerfile? I'm trying to rebuild the container using the Dockerfile, so I thought that go generate would be run as part of the container build. [I'm using kaniko to build the container image, but have also tested with buildah]

frebib commented 2 years ago

I think we need to open an issue in the NzbGet repo about this to either get clarification about whether GOOD is a valid value here, or whether that's a bug. It would be useful with some more detail from yourself (JSON snippets etc, redacted if you like) to give the issue some context. In the short term I suppose we could add DeleteStatusGood to the enum with a comment noting that this is a known issue. Fwiw I've never had that happen.

The Dockerfile issue is my fault; I'll fix that. I guess I never caught it because CI doesn't build it for me.

jonny-ervine commented 2 years ago

The record with DeleteStatus = GOOD has now been pushed out of my history, so the exporter is working as expected now. Which is good from a functional point of view for me, but does mean I can't easily reproduce the issue. Sorry. I will keep checking to find out if I can reproduce this later.

Thanks for looking at the Dockerfile - I have tested a manual build with running go generate beforehand, and can confirm that this does indeed work as expected (after installing enumer)

frebib commented 2 years ago

https://github.com/nzbget/nzbget/blob/6bbfb6b7b7c2e6da77968784005793ccce5c7286/daemon/queue/DownloadInfo.h#L418-L428 So this seems like a documentation issue more than anything. I'll push a fix https://github.com/nzbget/nzbget/commit/659ed48652d5c8532c8710079f0e8ed0070c10f0