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

chore: Add option to hide tokens from ring statuspage #633

Merged
merged 5 commits into from
Jan 6, 2025

Conversation

alexweav
Copy link
Contributor

@alexweav alexweav commented Jan 3, 2025

What this PR does:

This PR is the inverse of #631.
There are contexts in which the instance ring is used, but tokens are ignored. Such contexts can now configure HideTokens on the ring or lifecycler in order to hide the concept of tokens completely from the ring status page.

Here is what the page looks like with the toggle left at default (no visible changes):
2025-01-03-154402_2545x814_scrot

Hiding the tokens changes the page to look like:
2025-01-03-155551_2546x721_scrot

Similarly, no "Show Tokens" button at the bottom:
2025-01-03-155604_507x180_scrot

Which issue(s) this PR fixes:

Contrib https://github.com/grafana/mimir-squad/issues/2350

Checklist

  • Tests updated
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@alexweav alexweav marked this pull request as ready for review January 3, 2025 22:28
t.Run("displays expected partition info", func(t *testing.T) {
recorder := httptest.NewRecorder()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

drive-by-fix: In a test of this form, each case needs its own isolated recorder. The recorder does not replace its contents when invoked multiple times, but rather appends the request bodies as the cases proceed.

These tests all still pass, but without this they have less coverage than they appear to.

// ShowTokens indicates whether the Show Tokens button is clicked.
ShowTokens bool `json:"-"`
// DisableTokens hides the concept of tokens entirely in the page, across all elements.
DisableTokens bool `json:"-"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here I switched the name to DisableTokens.

I still feel HideTokens is the better name for the public APIs/config options, but within this file i felt the name HideTokens conflicts with the option ShowTokens and hurts readability.

Comment on lines +52 to +54
}, `\s*`))), recorder.Body.String())

assert.Regexp(t, regexp.MustCompile(fmt.Sprintf("(?m)%s", strings.Join([]string{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I skipped asserting a couple columns here, namely the ones containing heartbeat timestamps and such.

Asserting on these full-precision times felt like a very high vector for test intermittency - plus, it's not really the focus of this PR.

Copy link
Contributor

@56quarters 56quarters left a comment

Choose a reason for hiding this comment

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

LGTM

ring/basic_lifecycler.go Outdated Show resolved Hide resolved
@alexweav alexweav merged commit 3702098 into main Jan 6, 2025
5 checks passed
@alexweav alexweav deleted the alexweav/optionally-hide-tokens-ing-statuspage branch January 6, 2025 20:57
@alexweav alexweav mentioned this pull request Jan 6, 2025
4 tasks
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.

2 participants