lib/promscrape/discovery/kubernetes: do not start object watcher until initial objects are loaded

This commit is contained in:
Aliaksandr Valialkin 2021-03-14 21:55:00 +02:00
parent 83edbb7cab
commit b88806ecbf

View file

@ -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)