mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-21 15:45:01 +00:00
lib/promscrape/discovery/gce: do not pass filter arg when discovering zones
The filter arg isn't supported by zones API in GCE. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3202
This commit is contained in:
parent
45c2651678
commit
4df78e8814
3 changed files with 7 additions and 3 deletions
|
@ -15,6 +15,8 @@ The following tip changes can be tested by building VictoriaMetrics components f
|
||||||
|
|
||||||
## v1.79.x long-time support release (LTS)
|
## v1.79.x long-time support release (LTS)
|
||||||
|
|
||||||
|
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): properly discover GCE zones when `filter` option is set at [gce_sd_configs](https://docs.victoriametrics.com/sd_configs.html#gce_sd_configs). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3202).
|
||||||
|
|
||||||
## [v1.79.5](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.79.5)
|
## [v1.79.5](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.79.5)
|
||||||
|
|
||||||
Released at 10-11-2022
|
Released at 10-11-2022
|
||||||
|
|
|
@ -58,7 +58,9 @@ func newAPIConfig(sdc *SDConfig) (*apiConfig, error) {
|
||||||
logger.Infof("autodetected the current GCE zone: %q", zone)
|
logger.Infof("autodetected the current GCE zone: %q", zone)
|
||||||
} else if len(zones) == 1 && zones[0] == "*" {
|
} else if len(zones) == 1 && zones[0] == "*" {
|
||||||
// Autodetect zones for project.
|
// Autodetect zones for project.
|
||||||
zs, err := getZonesForProject(client, project, sdc.Filter)
|
// Do not pass sdc.Filter when discovering zones, since GCE doesn't support it.
|
||||||
|
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3202
|
||||||
|
zs, err := getZonesForProject(client, project)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot obtain zones for project %q: %w", project, err)
|
return nil, fmt.Errorf("cannot obtain zones for project %q: %w", project, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,13 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getZonesForProject(client *http.Client, project, filter string) ([]string, error) {
|
func getZonesForProject(client *http.Client, project string) ([]string, error) {
|
||||||
// See https://cloud.google.com/compute/docs/reference/rest/v1/zones
|
// See https://cloud.google.com/compute/docs/reference/rest/v1/zones
|
||||||
zonesURL := fmt.Sprintf("https://compute.googleapis.com/compute/v1/projects/%s/zones", project)
|
zonesURL := fmt.Sprintf("https://compute.googleapis.com/compute/v1/projects/%s/zones", project)
|
||||||
var zones []string
|
var zones []string
|
||||||
pageToken := ""
|
pageToken := ""
|
||||||
for {
|
for {
|
||||||
data, err := getAPIResponse(client, zonesURL, filter, pageToken)
|
data, err := getAPIResponse(client, zonesURL, "", pageToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot obtain zones: %w", err)
|
return nil, fmt.Errorf("cannot obtain zones: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue