Skip to content

e2e: Fix expfmt.TextParser in metrics test#1043

Merged
zeeke merged 1 commit intok8snetworkplumbingwg:masterfrom
zeeke:e2e/fix-metrics-test
Feb 26, 2026
Merged

e2e: Fix expfmt.TextParser in metrics test#1043
zeeke merged 1 commit intok8snetworkplumbingwg:masterfrom
zeeke:e2e/fix-metrics-test

Conversation

@zeeke
Copy link
Member

@zeeke zeeke commented Feb 24, 2026

TextParser objects must be initialized since github.com/prometheus/common v0.67.0

Links:

This PR fixes the failure:

> Enter [BeforeAll] [sriov] Metrics Exporter - /go/src/github.com/openshift/sriov-network-operator/test/conformance/tests/test_exporter_metrics.go:34 @ 02/23/26 16:24:05.991
STEP: Enabling `metricsExporter` feature flag - /go/src/github.com/openshift/sriov-network-operator/test/conformance/tests/test_exporter_metrics.go:51 @ 02/23/26 16:24:06.237
STEP: Adding monitoring label to openshift-sriov-network-operator - /go/src/github.com/openshift/sriov-network-operator/test/conformance/tests/test_exporter_metrics.go:54 @ 02/23/26 16:24:06.304
STEP: Using device ens1f0 on node cnfdr13.telco5g.eng.rdu2.redhat.com - /go/src/github.com/openshift/sriov-network-operator/test/conformance/tests/test_exporter_metrics.go:65 @ 02/23/26 16:24:21.179
< Exit [BeforeAll] [sriov] Metrics Exporter - /go/src/github.com/openshift/sriov-network-operator/test/conformance/tests/test_exporter_metrics.go:34 @ 02/23/26 16:24:31.747 (25.756s)
> Enter [It] collects metrics regarding receiving traffic via VF - /go/src/github.com/openshift/sriov-network-operator/test/conformance/tests/test_exporter_metrics.go:79 @ 02/23/26 16:24:31.747
[PANICKED] Test Panicked
In [It] at: /go/src/github.com/openshift/sriov-network-operator/vendor/github.com/prometheus/common/model/metric.go:179 @ 02/23/26 16:24:34.123

Invalid name validation scheme requested: unset

Full Stack Trace
  github.com/prometheus/common/model.ValidationScheme.IsValidMetricName(0x51d3c5?, {0xc000e32060?, 0x16?})
  	/go/src/github.com/openshift/sriov-network-operator/vendor/github.com/prometheus/common/model/metric.go:179 +0xb9
  github.com/prometheus/common/expfmt.(*TextParser).setOrCreateCurrentMF(0xc0000fe000)
  	/go/src/github.com/openshift/sriov-network-operator/vendor/github.com/prometheus/common/expfmt/text_parse.go:899 +0x85
  github.com/prometheus/common/expfmt.(*TextParser).startComment(0xc0000fe000)
  	/go/src/github.com/openshift/sriov-network-operator/vendor/github.com/prometheus/common/expfmt/text_parse.go:264 +0x15c
  github.com/prometheus/common/expfmt.(*TextParser).TextToMetricFamilies(0xc0000fe000, {0x1c111c0?, 0xc0004da9c0?})
  	/go/src/github.com/openshift/sriov-network-operator/vendor/github.com/prometheus/common/expfmt/text_parse.go:118 +0x5f
  github.com/k8snetworkplumbingwg/sriov-network-operator/test/conformance/tests.getMetricsForNode({0xc000a52450, 0x23})
  	/go/src/github.com/openshift/sriov-network-operator/test/conformance/tests/test_exporter_metrics.go:202 +0x545
  github.com/k8snetworkplumbingwg/sriov-network-operator/test/conformance/tests.init.func4.2()
  	/go/src/github.com/openshift/sriov-network-operator/test/conformance/tests/test_exporter_metrics.go:92 +0x2bc
< Exit [It] collects metrics regarding receiving traffic via VF - /go/src/github.com/openshift/sriov-network-operator/test/conformance/tests/test_exporter_metrics.go:79 @ 02/23/26 16:24:34.123 (2.376s)
> Enter [DeferCleanup (Each)] [sriov] Metrics Exporter - /go/src/github.com/openshift/sriov-network-operator/test/conformance/tests/test_exporter_metrics.go:85 @ 02/23/26 16:24:34.123
< Exit [DeferCleanup (Each)] [sriov] Metrics Exporter - /go/src/github.com/openshift/sriov-network-operator/test/conformance/tests/test_exporter_metrics.go:85 @ 02/23/26 16:24:34.187 (64ms)

`TextParser` objects must be initialized since `github.com/prometheus/common` `v0.67.0`

Links:
- https://github.com/prometheus/common/blob/main/CHANGELOG.md#whats-changed-3

Signed-off-by: Andrea Panattoni <apanatto@redhat.com>
@github-actions
Copy link

Thanks for your PR,
To run vendors CIs, Maintainers can use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs, Maintainers can use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

@gemini-code-assist
Copy link

Summary of Changes

Hello @zeeke, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical test failure within the end-to-end metrics conformance suite. The issue stemmed from an outdated method of initializing a Prometheus text parser, which no longer conformed to recent API changes in the prometheus/common library. By updating the parser's instantiation, the tests can now correctly process metrics without encountering runtime panics, ensuring the continued reliability of the metrics exporter validation.

Highlights

  • Fix expfmt.TextParser initialization: The expfmt.TextParser object is now correctly initialized using expfmt.NewTextParser(model.UTF8Validation) as required by github.com/prometheus/common v0.67.0 and later versions.
  • Resolved test failure: This change addresses a panicking test failure in the metrics exporter conformance tests, specifically related to an 'Invalid name validation scheme requested: unset' error during metric parsing.
Changelog
  • test/conformance/tests/test_exporter_metrics.go
    • Updated expfmt.TextParser initialization to use expfmt.NewTextParser(model.UTF8Validation).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request correctly addresses the panic caused by the uninitialized expfmt.TextParser object by using expfmt.NewTextParser(model.UTF8Validation). This resolves a critical issue in the metrics test, ensuring proper initialization of the parser as required by recent prometheus/common versions.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 22342596177

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 8 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.04%) to 62.982%

Files with Coverage Reduction New Missed Lines %
controllers/drain_controller.go 3 77.17%
controllers/generic_network_controller.go 5 77.49%
Totals Coverage Status
Change from base Build 22316823048: -0.04%
Covered Lines: 9322
Relevant Lines: 14801

💛 - Coveralls

Copy link
Collaborator

@SchSeba SchSeba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zeeke zeeke merged commit 6d87134 into k8snetworkplumbingwg:master Feb 26, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants