From b3a069fa2cf803624c82b8dc04cfaf0f08217878 Mon Sep 17 00:00:00 2001 From: hanjm <hanjinming@outlook.com> Date: Sun, 12 Sep 2021 17:27:44 +0800 Subject: [PATCH 1/2] Sidecar: Fix process external label when promethues v2.28+ use units.Bytes config type (#4656) Signed-off-by: hanjm <hanjinming@outlook.com> --- pkg/promclient/promclient.go | 4 +++- pkg/promclient/promclient_e2e_test.go | 16 ++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pkg/promclient/promclient.go b/pkg/promclient/promclient.go index cf5ca3ee3e..45a3c49638 100644 --- a/pkg/promclient/promclient.go +++ b/pkg/promclient/promclient.go @@ -176,7 +176,9 @@ func (c *Client) ExternalLabels(ctx context.Context, base *url.URL) (labels.Labe if err := json.Unmarshal(body, &d); err != nil { return nil, errors.Wrapf(err, "unmarshal response: %v", string(body)) } - var cfg config.Config + var cfg struct { + GlobalConfig config.GlobalConfig `yaml:"global"` + } if err := yaml.Unmarshal([]byte(d.Data.YAML), &cfg); err != nil { return nil, errors.Wrapf(err, "parse Prometheus config: %v", d.Data.YAML) } diff --git a/pkg/promclient/promclient_e2e_test.go b/pkg/promclient/promclient_e2e_test.go index e0d3c23766..c9845f4f5d 100644 --- a/pkg/promclient/promclient_e2e_test.go +++ b/pkg/promclient/promclient_e2e_test.go @@ -15,12 +15,14 @@ import ( "github.com/oklog/ulid" "github.com/prometheus/common/model" + "github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/timestamp" "github.com/thanos-io/thanos/pkg/block/metadata" "github.com/thanos-io/thanos/pkg/runutil" "github.com/thanos-io/thanos/pkg/testutil" "github.com/thanos-io/thanos/pkg/testutil/e2eutil" + "gopkg.in/yaml.v3" ) func TestIsWALFileAccessible_e2e(t *testing.T) { @@ -38,12 +40,14 @@ func TestIsWALFileAccessible_e2e(t *testing.T) { func TestExternalLabels_e2e(t *testing.T) { e2eutil.ForeachPrometheus(t, func(t testing.TB, p *e2eutil.Prometheus) { - p.SetConfig(` -global: - external_labels: - region: eu-west - az: 1 -`) + // Keep consistent with the config processing in function (*Client).ExternalLabels. + cfg := config.Config{GlobalConfig: config.GlobalConfig{ExternalLabels: []labels.Label{ + {Name: "region", Value: "eu-west"}, + {Name: "az", Value: "1"}, + }}} + cfgData, err := yaml.Marshal(cfg) + testutil.Ok(t, err) + p.SetConfig(string(cfgData)) testutil.Ok(t, p.Start()) From 2e021bc59ce3822e0e4496dec0a8d941411f361a Mon Sep 17 00:00:00 2001 From: hanjm <hanjinming@outlook.com> Date: Wed, 15 Sep 2021 12:48:42 +0800 Subject: [PATCH 2/2] E2E: Upgrade prometheus image version Signed-off-by: hanjm <hanjinming@outlook.com> --- test/e2e/e2ethanos/services.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/e2ethanos/services.go b/test/e2e/e2ethanos/services.go index e71a39b213..c15c150cbb 100644 --- a/test/e2e/e2ethanos/services.go +++ b/test/e2e/e2ethanos/services.go @@ -43,7 +43,7 @@ const ( // TODO(bwplotka): Run against multiple? func DefaultPrometheusImage() string { - return "quay.io/prometheus/prometheus:v2.26.0" + return "quay.io/prometheus/prometheus:v2.29.2" } func DefaultAlertmanagerImage() string {