Skip to content

Commit 67ed90a

Browse files
committed
test/kubernetes: use zero-value TextParser until prometheus/common is bumped
expfmt.NewTextParser was introduced in a later prometheus/common release than the one pinned here (v0.59.1), so every CoreDNS PR that runs the Kubernetes test step fails with: ./metrics_test.go:87:15: undefined: expfmt.NewTextParser Revert that call site to the zero-value `var tp expfmt.TextParser` pattern (which defaults to legacy validation) so the job compiles on the currently pinned dependency. Once go.mod's prometheus/ common is bumped to a version that exports NewTextParser (see coredns/coredns#7731), this can be re-applied without the compat note. Also drop the now-unused prometheus/common/model import. Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>
1 parent 326aa94 commit 67ed90a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

test/kubernetes/metrics_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010

1111
dto "github.com/prometheus/client_model/go"
1212
"github.com/prometheus/common/expfmt"
13-
"github.com/prometheus/common/model"
1413
api "k8s.io/api/core/v1"
1514
discovery "k8s.io/api/discovery/v1"
1615
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -85,7 +84,11 @@ func testEndpoints(t *testing.T, client *kubernetes.Clientset, slices bool) {
8584

8685
// scrape and parse metrics to get base state
8786
m := ScrapeMetrics(t)
88-
tp := expfmt.NewTextParser(model.LegacyValidation)
87+
// prometheus/common v0.59.1 (pinned in go.mod) does not yet expose
88+
// NewTextParser; stick with the zero-value TextParser, which
89+
// defaults to legacy validation, until coredns/coredns#7731 bumps
90+
// the common dep.
91+
var tp expfmt.TextParser
8992
base, err := tp.TextToMetricFamilies(strings.NewReader(string(m)))
9093
if err != nil {
9194
t.Fatalf("Could not parse scraped metrics: %v", err)

0 commit comments

Comments
 (0)