From 81fb34665a26ece016c0c675484a9ebb2087a2e8 Mon Sep 17 00:00:00 2001 From: SAY-5 Date: Tue, 21 Apr 2026 02:27:14 -0700 Subject: [PATCH] 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 --- test/kubernetes/metrics_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/kubernetes/metrics_test.go b/test/kubernetes/metrics_test.go index e1461dd..2d8c8f3 100644 --- a/test/kubernetes/metrics_test.go +++ b/test/kubernetes/metrics_test.go @@ -10,7 +10,6 @@ import ( dto "github.com/prometheus/client_model/go" "github.com/prometheus/common/expfmt" - "github.com/prometheus/common/model" api "k8s.io/api/core/v1" discovery "k8s.io/api/discovery/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -85,7 +84,11 @@ func testEndpoints(t *testing.T, client *kubernetes.Clientset, slices bool) { // scrape and parse metrics to get base state m := ScrapeMetrics(t) - tp := expfmt.NewTextParser(model.LegacyValidation) + // prometheus/common v0.59.1 (pinned in go.mod) does not yet expose + // NewTextParser; stick with the zero-value TextParser, which + // defaults to legacy validation, until coredns/coredns#7731 bumps + // the common dep. + var tp expfmt.TextParser base, err := tp.TextToMetricFamilies(strings.NewReader(string(m))) if err != nil { t.Fatalf("Could not parse scraped metrics: %v", err)