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

fix(static/metrics/instance): fix duplicate metrics registration panic when recreating the instance #6608

Conversation

hainenber
Copy link
Contributor

PR Description

Props to @rfratto for troubleshooting and guidance, I'm just implementing the idea here :D

Which issue(s) this PR fixes

Fixes #6548

Notes to the Reviewer

PR Checklist

  • CHANGELOG.md updated
  • Tests updated

…c when recreating the instance

Signed-off-by: hainenber <dotronghai96@gmail.com>
@@ -278,7 +278,6 @@ func TestInstance_Recreate(t *testing.T) {

// Recreate the instance, no panic should happen.
require.NotPanics(t, func() {
inst, err := New(prometheus.NewRegistry(), cfg, walDir, logger)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This actually recreates a blank new Prom registry and the children write handler won't have any duplicate registration, thus no panic.

Removing it allows for reproduction of the panic

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should remove this line (the comment doesn't recreate the instance anymore), but rather pass in the same registry on both line 261 and here. Can we add it back and make that change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re-added :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And I can confirm that without the change in instance.go, that also reproduces the panic.

Copy link
Member

@rfratto rfratto left a comment

Choose a reason for hiding this comment

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

Thanks! Once the comment about the test is resolved I'll merge and get a patch release out for this.

@@ -278,7 +278,6 @@ func TestInstance_Recreate(t *testing.T) {

// Recreate the instance, no panic should happen.
require.NotPanics(t, func() {
inst, err := New(prometheus.NewRegistry(), cfg, walDir, logger)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should remove this line (the comment doesn't recreate the instance anymore), but rather pass in the same registry on both line 261 and here. Can we add it back and make that change?

@hainenber hainenber changed the title fix(static/metrics/instance): fix duplicate metrics registration panic hen recreating the instance fix(static/metrics/instance): fix duplicate metrics registration panic when recreating the instance Mar 5, 2024
…with past Prom registry

Signed-off-by: hainenber <dotronghai96@gmail.com>
Copy link
Member

@rfratto rfratto left a comment

Choose a reason for hiding this comment

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

Thanks again!

@rfratto rfratto enabled auto-merge (squash) March 5, 2024 15:54
@rfratto rfratto merged commit 7a61067 into grafana:main Mar 5, 2024
10 checks passed
@hainenber hainenber deleted the fix-write-handler-duplicate-metrics-collector-registration-panic branch March 5, 2024 17:26
rfratto pushed a commit to rfratto/agent that referenced this pull request Mar 5, 2024
…c when recreating the instance (grafana#6608)

Signed-off-by: hainenber <dotronghai96@gmail.com>
(cherry picked from commit 7a61067)
rfratto added a commit that referenced this pull request Mar 5, 2024
* Set permissions on the Grafana Agent [Flow] folder... (#6540)

* Set permissions on the  folder when installing via the windows installer rather than relying on the parent folder permissions.

Signed-off-by: erikbaranowski <39704712+erikbaranowski@users.noreply.github.com>

---------

Signed-off-by: erikbaranowski <39704712+erikbaranowski@users.noreply.github.com>
(cherry picked from commit 9e4d3b5)

* Loader reuse existing nodes on reload (#6288)

* Move UpdateBlock from componentNode interface to blockNode interface.

This change means that all blockNodes have now the possibility to update their managed block with the update River block content.

* Update the loader to update the managed block of a config node  on reload if it already existed in the graph.
With this optimization, we re-use existing nodes and update them instead of creating a new node.
This is especially useful for modules.

* add two new tests to check that on reload the config nodes behave as expected

* add updateblock to declare node

* update loader logic to detect duplicated blocks and reuse already defined blocks

* add updateblock to import config node

* update changelog

* move function and remove unnecessary check

(cherry picked from commit 2e9d5a2)

* fix(static/metrics/instance): fix duplicate metrics registration panic when recreating the instance (#6608)

Signed-off-by: hainenber <dotronghai96@gmail.com>
(cherry picked from commit 7a61067)

* chore(build): upgrade base image to frequently updated ECR-hosted Ubuntu (#6612)

Signed-off-by: hainenber <dotronghai96@gmail.com>
(cherry picked from commit fe513a4)

* prepare for 0.40.2 release (#6619)

(cherry picked from commit ed54148)

* Port promtail changes part 1 (#6559)

* Port promtail changes part 1

* changelog

(cherry picked from commit 1a642cf)

* remove accidentally committed web/ui/build folder

* fix issue with cherry-picking CHANGELOG.md

* fix bad conflict resolution

* fix test which failed due to bad merge conflict resolution

* On new windows installs, remove default read permissions from agent c… (#6622)

* On new windows installs, remove default read permissions from agent config

Signed-off-by: erikbaranowski <39704712+erikbaranowski@users.noreply.github.com>

* only apply permissions for a new install

Signed-off-by: erikbaranowski <39704712+erikbaranowski@users.noreply.github.com>

* Update CHANGELOG.md

Co-authored-by: Robert Fratto <robertfratto@gmail.com>

---------

Signed-off-by: erikbaranowski <39704712+erikbaranowski@users.noreply.github.com>
Co-authored-by: Robert Fratto <robertfratto@gmail.com>
(cherry picked from commit e8a3d29)

---------

Co-authored-by: Erik Baranowski <39704712+erikbaranowski@users.noreply.github.com>
Co-authored-by: William Dumont <william.dumont@grafana.com>
Co-authored-by: Đỗ Trọng Hải <41283691+hainenber@users.noreply.github.com>
Co-authored-by: Piotr <17101802+thampiotr@users.noreply.github.com>
@github-actions github-actions bot added the frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed. label Apr 5, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0.40.0: panic: duplicate metrics collector registration attempted
2 participants