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

Expose IngestersWithTokensCount and IngestersWithTokensInZone count from ring.ReadRing #516

Merged
merged 5 commits into from
Apr 11, 2024

Conversation

pr00se
Copy link
Contributor

@pr00se pr00se commented Apr 10, 2024

What this PR does:

This PR adds InstancesWithTokensCount and InstancesWithTokensInZoneCount methods to the ring.ReadRing interface and *ring.Ring implementation. These methods provide global and per-zone counts of registered instances that have some tokens in the ring, regardless of instance state. In Mimir we need these to exclude instances with no tokens when calculating limits (since these instances won't actually handle a portion of the global limit).

This PR also moves the InstancesCount implementation to ring.go, with the other instance counting functions.

Which issue(s) this PR fixes:

Relates to grafana/mimir#7847

Checklist

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

@@ -518,6 +518,18 @@ func (d *Desc) getOldestRegisteredTimestamp() int64 {
return result
}

func (d *Desc) instancesWithTokensCount() int {
count := 0
if d != nil {
Copy link
Member

Choose a reason for hiding this comment

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

super-nit: if d == nil we can return 0, and then reduce indentation in the following code.

@pr00se pr00se merged commit 40cf812 into main Apr 11, 2024
3 checks passed
@pr00se pr00se deleted the instances-with-tokens branch April 11, 2024 15:33
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.

3 participants