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: remove unnecessary leadership guards in GrafanaCloudConfigRequirer #13

Merged
merged 9 commits into from
Aug 16, 2024

Conversation

ca-scribner
Copy link
Contributor

@ca-scribner ca-scribner commented Aug 14, 2024

Issue

Previously, GrafanaCloudConfigRequirer would only emit a cloud_config_* event on relation changed/broken if this unit is a leader. This caused issues with multi-unit deployments as described in #12.

Solution

Since GrafanaCloudConfigRequirer only reads the relation remote's application_data, there is no need for a leadership guard because non-leader units have permission to read this data. The current commit removes these guards.

Context

closes #12

Testing Instructions

See this grafana-agent patch for testing instructions

Release Notes

@ca-scribner ca-scribner requested a review from a team as a code owner August 14, 2024 18:53
@ca-scribner ca-scribner force-pushed the openg-2648 branch 3 times, most recently from cd94f01 to 9bb6da5 Compare August 14, 2024 19:02
Previously, GrafanaCloudConfigRequirer would only emit a cloud_config_* event on relation changed/broken if this unit is a leader.  This caused issues with multi-unit deployments as described in [#12](#12).  Since GrafanaCloudConfigRequirer only reads the relation remote's application_data, there is no need for a leadership guard because non-leader units have permission to read this data.  The current commit removes these guards.
Copy link

@PietroPasotti PietroPasotti left a comment

Choose a reason for hiding this comment

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

So I think the change is going in the right direction, as it's odd to emit custom events conditionally on leadership.
However, I was expecting to see some documentation changes? Is there nothing in the module docstring that we need to adjust to reflect the change? (if not, it was probably a bad doc and we should create an issue to improve the documentation)
Secondly, I was expecting to see some test for the new behaviour.
A couple of simple tests using Context.emitted_events to verify that the available/revoked events are emitted regardless of leadership would be great.

@ca-scribner
Copy link
Contributor Author

Yep good points.

@ca-scribner
Copy link
Contributor Author

@PietroPasotti added some tests like you mentioned to assert the correct events are emitted

Copy link

@PietroPasotti PietroPasotti left a comment

Choose a reason for hiding this comment

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

Thanks for the tests! On top of the missing assertions spotted by leon, the fixtures should be cleaned up a bit.
The rest looks good!

tests/scenario/test_grafana_cloud_integrator_lib.py Outdated Show resolved Hide resolved
tests/scenario/test_grafana_cloud_integrator_lib.py Outdated Show resolved Hide resolved
Copy link
Contributor

@Abuelodelanada Abuelodelanada left a comment

Choose a reason for hiding this comment

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

I would merge it as is and address the comments made in the created issues.

@ca-scribner ca-scribner dismissed PietroPasotti’s stale review August 16, 2024 18:36

Dismissing given Jose's review. I think everything is resolved, but if not we can update it after

@ca-scribner ca-scribner merged commit 394866d into main Aug 16, 2024
13 checks passed
@ca-scribner ca-scribner deleted the openg-2648 branch August 16, 2024 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prometheus remote-write URL is only getting pushed to the leader unit
4 participants