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 sync.Mutex
creds *apiCredentials
// authTokenReq contins request body for apiCredentials
// authTokenReq contains request body for apiCredentials
authTokenReq []byte
// keystone endpoint
endpoint *url.URL

View file

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