David-VTUK / prometheus-rancher-exporter

MIT License
7 stars 7 forks source link

Rancher projects improved #19

Closed ulikl closed 1 year ago

ulikl commented 1 year ago

This improves the implementation for Issue "Add metrics on rancher project and related namespaces (Issue #12)" in the following two aspects:

quota Unit clash

The units returned for the same resources can differ in Rancher. Especially hard and used value are using different units in my test project:

Instead of just stripping the unit part, it should first be converted to the standard units e.g. like is a the func ExampleMustParse from

https://github.com/kubernetes/apimachinery/blob/adc6f4cd9e7d28fc1c1e5efc658d940d55c0f356/pkg/api/resource/quantity_example_test.go

air gapped setup not working

The container is crashlooping, when it has no internet connection and the DNS lookup return to github.com returns "BAD ADDRESS" When I add a proxy it works fine.

time="2023-04-07T08:12:23Z" level=info msg="Building Rancher Client"
time="2023-04-07T08:12:23Z" level=info msg="Beginning to serve on port :8080"
time="2023-04-07T08:12:26Z" level=info msg="updating rancher metrics" source="collector.go:201"
time="2023-04-07T08:12:38Z" level=info msg="updating rancher metrics" source="collector.go:201"
time="2023-04-07T08:12:51Z" level=info msg="updating rancher metrics" source="collector.go:201"
time="2023-04-07T08:13:04Z" level=info msg="updating rancher metrics" source="collector.go:201"
time="2023-04-07T08:13:17Z" level=info msg="updating rancher metrics" source="collector.go:201"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x9834e5]

goroutine 54 [running]:
github.com/david-vtuk/prometheus-rancher-exporter/query/rancher.Client.GetLatestRancherVersion({{0xc00029c0f0?, 0xc0002ac780?}, 0xc000076f88?})
        /prometheus-rancher-exporter/query/rancher/rancher.go:103 +0x65
github.com/david-vtuk/prometheus-rancher-exporter/collector.Collect.func1()
        /prometheus-rancher-exporter/collector/collector.go:188 +0xf0
created by github.com/david-vtuk/prometheus-rancher-exporter/collector.Collect
        /prometheus-rancher-exporter/collector/collector.go:181 +0x16d
David-VTUK commented 1 year ago

Thanks a lot for this - merged and image created.