Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidecar: Fix process external label on promethues v2.28+ use units.Bytes config type #4657

Merged
merged 2 commits into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/promclient/promclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
16 changes: 10 additions & 6 deletions pkg/promclient/promclient_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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())

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/e2ethanos/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down