kashalls / kromgo

Easily expose preconfigured prometheus metrics to the outside using badges.
67 stars 3 forks source link

Hard fail when config file not right. #23

Closed reefland closed 7 months ago

reefland commented 7 months ago

Initial configuration attempt left me with:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6eeedf]
goroutine 1 [running]:
main.main()
/go/src/github.com/kashalls/kromgo/main.go:64 +0x27f

I tracked it down to having this defined:

    globalMounts:
      - path: /kromgo/config.yaml
        subPath: config.yaml
        readOnly: true

Yet, mistakenly the configmap.data had a mismatched extension:

configMaps:
  configmap:
    enabled: true
    data:
      config.yml: |
      ...

I assume that left the pod with either a missing config file or a zero-byte, etc.

The ask is for some additional checks on the config file to log something more friendly and not a panic message.

kashalls commented 7 months ago

What version are you running?

Assuming you were running v0.2.4, this issue was fixed in #16 and v0.3.0 as I realized we were trying to read if debug logging was enabled before handling the config failure.

reefland commented 7 months ago

Yeah, it was v0.2.4 and I fixed the config prior to v0.3.0. I checked the upgrade notes, didn't notice anything obvious saying it was addressed. Must the "and more" part. Thanks for the prompt reply. Closing issue.