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

test: First pass at unregistering metrics so that we can run multiple tests #12927

Merged
merged 5 commits into from
May 9, 2024

Conversation

paul1r
Copy link
Collaborator

@paul1r paul1r commented May 9, 2024

What this PR does / why we need it:
When running tests with a -count= value greater than 1, there are multiple places in the code that yield the following error:

panic: duplicate metrics collector registration attempted [recovered]
	panic: duplicate metrics collector registration attempted

goroutine 205 [running]:
testing.tRunner.func1.2({0x1058e1b00, 0xc00090e800})
	/opt/homebrew/Cellar/go/1.22.2/libexec/src/testing/testing.go:1631 +0x2c8
testing.tRunner.func1()
	/opt/homebrew/Cellar/go/1.22.2/libexec/src/testing/testing.go:1634 +0x47c
panic({0x1058e1b00?, 0xc00090e800?})
	/opt/homebrew/Cellar/go/1.22.2/libexec/src/runtime/panic.go:770 +0x124
github.com/prometheus/client_golang/prometheus.(*Registry).MustRegister(0x106d22380, {0xc000a02fc0, 0x1, 0x0?})
	/Users/progers/dev/src/github.com/grafana/loki/vendor/github.com/prometheus/client_golang/prometheus/registry.go:405 +0xa8
github.com/prometheus/client_golang/prometheus.MustRegister(...)
	/Users/progers/dev/src/github.com/grafana/loki/vendor/github.com/prometheus/client_golang/prometheus/registry.go:177
github.com/grafana/loki/v3/pkg/storage/chunk/client/azure.NewBlobStorageMetrics()

This PR is to ensure the metrics are unregistered so that subsequent tests can be run

Which issue(s) this PR fixes:
Relates to #8586

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • For Helm chart changes bump the Helm chart version in production/helm/loki/Chart.yaml and update production/helm/loki/CHANGELOG.md and production/helm/loki/README.md. Example PR
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

@paul1r paul1r requested a review from a team as a code owner May 9, 2024 15:06
@paul1r paul1r merged commit d16a3bf into main May 9, 2024
58 checks passed
@paul1r paul1r deleted the paul1r/start_allowing_tests_with_count_gt_1 branch May 9, 2024 16:15
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.

2 participants