fixes all_tenants query option usage for openstack service discovery (#2184)

explicit use configuration parametr instead of conditional add
https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2182
This commit is contained in:
Nikolay 2022-02-14 14:07:30 +03:00 committed by GitHub
parent d924f4b7ba
commit c90c1c4d54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View file

@ -33,7 +33,7 @@ type apiConfig struct {
// tokenLock guards creds refresh // tokenLock guards creds refresh
tokenLock sync.Mutex tokenLock sync.Mutex
creds *apiCredentials creds *apiCredentials
// authTokenReq contins request body for apiCredentials // authTokenReq contains request body for apiCredentials
authTokenReq []byte authTokenReq []byte
// keystone endpoint // keystone endpoint
endpoint *url.URL endpoint *url.URL

View file

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"path" "path"
"sort" "sort"
"strconv"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promscrape/discoveryutils" "github.com/VictoriaMetrics/VictoriaMetrics/lib/promscrape/discoveryutils"
) )
@ -110,12 +111,9 @@ func (cfg *apiConfig) getServers() ([]server, error) {
} }
computeURL := *creds.computeURL computeURL := *creds.computeURL
computeURL.Path = path.Join(computeURL.Path, "servers", "detail") computeURL.Path = path.Join(computeURL.Path, "servers", "detail")
// by default, query fetches data from all tenants q := computeURL.Query()
if !cfg.allTenants { q.Set("all_tenants", strconv.FormatBool(cfg.allTenants))
q := computeURL.Query() computeURL.RawQuery = q.Encode()
q.Set("all_tenants", "false")
computeURL.RawQuery = q.Encode()
}
nextLink := computeURL.String() nextLink := computeURL.String()
var servers []server var servers []server
for { for {