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

Lifecycler: return the number of instances in lifecycler's zone #266

Merged
merged 4 commits into from
Feb 15, 2023

Conversation

duricanikolic
Copy link
Contributor

What this PR does:
This PR enriches Lifecycler with the InstancesInZoneCount() method, that returns the number of instances in ring belonging to the lifecycler's zone, updated during the last heartbeat period.
A test (TestLifecycler_InstancesInZoneCount) showing the expected behaviour of InstancesInZoneCount() has been added.

Which issue(s) this PR fixes:
This PR is a pre-requisite for fixing the issue 4208.

Checklist

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

@CLAassistant
Copy link

CLAassistant commented Feb 11, 2023

CLA assistant check
All committers have signed the CLA.

ring/lifecycler.go Outdated Show resolved Hide resolved
Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

LGTM (modulo a couple of nits). Thanks!

CHANGELOG.md Outdated Show resolved Hide resolved
ring/lifecycler_test.go Outdated Show resolved Hide resolved
ring/lifecycler_test.go Outdated Show resolved Hide resolved
ring/lifecycler_test.go Outdated Show resolved Hide resolved
Comment on lines +814 to +816
if _, ok := zones[ingester.Zone]; !ok {
zones[ingester.Zone] = 0
}
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Setting default value 0 to zones[ingester.Zone] is unnecessary. zones[ingester.Zone]++ below will work just fine without this.

Copy link
Contributor Author

@duricanikolic duricanikolic Feb 21, 2023

Choose a reason for hiding this comment

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

Hi @pstibrany,
This assignment is needed in order to count the total number of zones. If we remove the block setting 0 to zones[ingester.Zone], we will count only the number of zones with healthy ingesters.

Copy link
Member

Choose a reason for hiding this comment

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

Good point that I missed! That's worth adding a comment in my opinion.

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.

4 participants