From 894246176f8dbe414e3ce6789ec7258e20f2175c Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sun, 14 Mar 2021 21:55:00 +0200 Subject: [PATCH] lib/promscrape/discovery/kubernetes: do not start object watcher until initial objects are loaded --- lib/promscrape/discovery/kubernetes/api_watcher.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/promscrape/discovery/kubernetes/api_watcher.go b/lib/promscrape/discovery/kubernetes/api_watcher.go index 1e09e8955e..d0cc9bb6ca 100644 --- a/lib/promscrape/discovery/kubernetes/api_watcher.go +++ b/lib/promscrape/discovery/kubernetes/api_watcher.go @@ -490,10 +490,11 @@ func (uw *urlWatcher) watchForUpdates() { apiURL += delimiter + "watch=1&allowWatchBookmarks=true&timeoutSeconds=" + strconv.Itoa(int(timeoutSeconds)) for { resourceVersion := uw.reloadObjects() - requestURL := apiURL - if resourceVersion != "" { - requestURL += "&resourceVersion=" + url.QueryEscape(resourceVersion) + if resourceVersion == "" { + backoffSleep() + continue } + requestURL := apiURL + "&resourceVersion=" + url.QueryEscape(resourceVersion) resp, err := uw.gw.doRequest(requestURL) if err != nil { logger.Errorf("cannot perform request to %q: %s", requestURL, err)