From ab318660cd6ca394082238754df8ccc63d66571c Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 10 Jan 2023 13:48:23 -0800 Subject: [PATCH] lib/promscrape/discovery/gce: follow-up for b2ccdaaa2f76350d9c8cbd318980955fb164bee4 - Use promutils.Labels.GetLabels() instead of comparing promutils.Labels.Labels to nil. This make the code more consistent with other places. - Mention the release where the issue has been introduced at docs/CHANGELOG.md. Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3624 --- docs/CHANGELOG.md | 3 ++- lib/promscrape/discovery/gce/instance.go | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 0c67ef791f..74bd50eb1e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -44,9 +44,10 @@ The following tip changes can be tested by building VictoriaMetrics components f * BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): fix a panic during target discovery when `vmagent` runs with `-promscrape.dropOriginalLabels` command-line flag. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3580). The bug has been introduced in [v1.85.0](https://docs.victoriametrics.com/CHANGELOG.html#v1850). * BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): [dockerswarm_sd_configs](https://docs.victoriametrics.com/sd_configs.html#dockerswarm_sd_configs): properly encode `filters` field. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3579). * BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): fix possible resource leak after hot reload of the updated [consul_sd_configs](https://docs.victoriametrics.com/sd_configs.html#consul_sd_configs). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3468). +* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): fix a panic in [gce_sd_configs](https://docs.victoriametrics.com/sd_configs.html#gce_sd_configs) when the discovered instance has zero labels. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3624). The issue has been introduced in [v1.85.0](https://docs.victoriametrics.com/CHANGELOG.html#v1850). * BUGFIX: properly return label names starting from uppercase such as `CamelCaseLabel` from [/api/v1/labels](https://docs.victoriametrics.com/url-examples.html#apiv1labels). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3566). * BUGFIX: consistently select the sample with the biggest value out of samples with identical timestamps during querying when the [deduplication](https://docs.victoriametrics.com/#deduplication) is enabled according to [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3333). Previously random samples could be selected during querying. -* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): fix a panic during GCE service discovery for instance without any labels set. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3624). + ## [v1.85.3](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.85.3) diff --git a/lib/promscrape/discovery/gce/instance.go b/lib/promscrape/discovery/gce/instance.go index a9c37f4c5f..49bee6232a 100644 --- a/lib/promscrape/discovery/gce/instance.go +++ b/lib/promscrape/discovery/gce/instance.go @@ -160,10 +160,8 @@ func (inst *Instance) appendTargetLabels(ms []*promutils.Labels, project, tagSep for _, item := range inst.Metadata.Items { m.Add(discoveryutils.SanitizeLabelName("__meta_gce_metadata_"+item.Key), item.Value) } - if inst.Labels != nil { - for _, label := range inst.Labels.Labels { - m.Add(discoveryutils.SanitizeLabelName("__meta_gce_label_"+label.Name), label.Value) - } + for _, label := range inst.Labels.GetLabels() { + m.Add(discoveryutils.SanitizeLabelName("__meta_gce_label_"+label.Name), label.Value) } if len(iface.AccessConfigs) > 0 { ac := iface.AccessConfigs[0]