VictoriaMetrics/lib/promscrape/discovery/kubernetes
Zakhar Bessarab 55d25fb844
lib/promscrape/discovery/kubernetes: fix leaking api watcher (#4861)
* lib/promscrape/discovery/kubernetes: fix leaking api watcher

goroutine which was polling k8s API had no execution control. This leaded to leaking goroutines during config reload.

See: https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4850
Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>

* lib/promscrape/discovery/kubernetes: use reference counting for urlWatcher cleanup

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>

* lib/promscrape/discovery/kubernetes: remove waitgroup sync for goroutines polling API server

This is unnecessary since context will is cancelled and new requests will not be sent. Also, using waitgroup will increase time required to perform reload which might result in missed scrapes.

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>

* lib/promscrape/discovery/kubernetes: clarify comment

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>

* Apply suggestions from code review

* lib/promscrape/discovery/kubernetes: address review feedback

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>

---------

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>
Co-authored-by: Nikolay <nik@victoriametrics.com>
2023-09-18 17:13:55 +02:00
..
testdata lib/promscrape/discovery/kubernetes: follow-up after 0b5c874911 (#2672) 2022-06-04 01:11:23 +03:00
api.go lib/promauth: refactor NewConfig in order to improve maintainability 2022-07-04 14:31:43 +03:00
api_watcher.go lib/promscrape/discovery/kubernetes: fix leaking api watcher (#4861) 2023-09-18 17:13:55 +02:00
api_watcher_test.go lib/promscrape: optimize service discovery speed 2022-11-29 21:26:23 -08:00
common_types.go lib/promscrape: optimize service discovery speed 2022-11-29 21:26:23 -08:00
endpoints.go Add endpoint labels for pod targets discovered form endpoint but has different ports (#4253) 2023-05-09 21:25:56 -07:00
endpoints_test.go lib/promscrape/discovery/kubernetes: follow-up for d5e94721db (#4255) 2023-05-09 21:29:27 -07:00
endpointslice.go Add endpoint labels for pod targets discovered form endpoint but has different ports (#4253) 2023-05-09 21:25:56 -07:00
endpointslice_test.go lib/promscrape/discovery/kubernetes: follow-up for d5e94721db (#4255) 2023-05-09 21:29:27 -07:00
ingress.go Makefile: update golangci-lint from v1.51.2 to v1.54.2 2023-09-01 10:25:49 +02:00
ingress_test.go lib/promscrape: optimize service discovery speed 2022-11-29 21:26:23 -08:00
kubeconfig.go lib/promscrape/discovery/kubernetes: use unsupportedFieldError() function instead of errContext string 2022-06-07 01:24:14 +03:00
kubeconfig_test.go lib/promscrape/discovery/kubernetes: follow-up after 006b8c7534 2022-06-06 14:41:28 +03:00
kubernetes.go lib/promscrape: optimize service discovery speed 2022-11-29 21:26:23 -08:00
node.go Makefile: update golangci-lint from v1.51.2 to v1.54.2 2023-09-01 10:25:49 +02:00
node_test.go lib/promscrape: optimize service discovery speed 2022-11-29 21:26:23 -08:00
pod.go lib/promscrape/discovery/kubernetes: follow-up for d5e94721db (#4255) 2023-05-09 21:29:27 -07:00
pod_test.go lib/promscrape/discovery/kubernetes: add support for __meta_kubernetes_pod_container_id 2023-01-27 16:33:57 -08:00
pod_timing_test.go lib/promscrape: optimize service discovery speed 2022-11-29 21:26:23 -08:00
service.go Makefile: update golangci-lint from v1.51.2 to v1.54.2 2023-09-01 10:25:49 +02:00
service_test.go lib/promscrape: optimize service discovery speed 2022-11-29 21:26:23 -08:00