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

Add partitions ring support to Distributor.UserStats() #7402

Merged
merged 5 commits into from
Feb 16, 2024

Conversation

pracucci
Copy link
Collaborator

What this PR does

In this PR I'm adding partitions ring support to Distributor.UserStats(). Contrary to #7393 (which was straightforward) the main difference here is that with the ingest storage we have to account for replication in a slightly different way (see comments in the code).

Note to reviewers:

  • I suggest to review with "hide whitespace changes" enabled

Which issue(s) this PR fixes or relates to

N/A

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

@@ -2996,28 +3332,25 @@ func TestDistributor_LabelValuesCardinality(t *testing.T) {
}

tests := map[string]struct {
labelNames []model.LabelName
matchers []*labels.Matcher
ingestersSeriesCountTotal uint64
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note to reviewers: I've modified this test to not mock the result of mockIngester.UserStats() anymore, but having it computing the actual number of pushed series.

pkg/distributor/distributor.go Outdated Show resolved Hide resolved
pkg/distributor/distributor.go Outdated Show resolved Hide resolved
pkg/distributor/distributor.go Show resolved Hide resolved
Comment on lines +423 to +425
"partitions RF=2 (2 zones), 4 ingesters, all ingesters in the preferred zone (zone-a) are UNHEALTHY": {
ingesterStateByZone: map[string]ingesterZoneState{
"zone-a": {numIngesters: 2, happyIngesters: 0},
Copy link
Contributor

Choose a reason for hiding this comment

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

Is UNHEALTHY a ring term? In this case they're just returning 5xx, but are ACTIVE in the ring

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is UNHEALTHY a ring term?

It's not a ring state, but it's what we display in the ring UI.

pkg/distributor/distributor_ingest_storage_test.go Outdated Show resolved Hide resolved
Comment on lines 524 to 527
numPartitions := 0
for _, state := range testData.ingesterStateByZone {
numPartitions = max(numPartitions, max(state.numIngesters, len(state.states)))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

you can maybe use prepConfig.totalIngesters() and prepConfig.totalZones() to figure this one out. It should work in this this test. If you still want to preserve the behaviour you implemented which supports different number of ingesters per zone, then, then can you add this as a method on prepConfig?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggestion is to add a function on prepConfig to set a field on prepConfig itself. Don't think will make code better.

Copy link
Contributor

Choose a reason for hiding this comment

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

the suggestion was to add maxIngestersPerZone() int function and use that here. Mainly because prepConfig already counts ingesters and zones and know what are the different ways of setting the number of ingesters (states vs happy/unhappy)

it's a minor change, i'll leave it up to you

Copy link
Collaborator Author

@pracucci pracucci Feb 16, 2024

Choose a reason for hiding this comment

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

Instead of explicitly setting ingestStoragePartitions we can auto-detect it in most cases. I've done it here: 7916307

pkg/distributor/distributor_test.go Show resolved Hide resolved
pkg/distributor/distributor_test.go Show resolved Hide resolved
Base automatically changed from query-partitions-for-labels to main February 16, 2024 13:51
Signed-off-by: Marco Pracucci <marco@pracucci.com>
@pracucci pracucci force-pushed the query-partitions-for-userstats branch from 237dd98 to c217503 Compare February 16, 2024 14:01
Signed-off-by: Marco Pracucci <marco@pracucci.com>
…ats_ShouldSupportIngestStorage() because not necessary

Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
@pracucci pracucci marked this pull request as ready for review February 16, 2024 14:29
@pracucci pracucci requested a review from a team as a code owner February 16, 2024 14:29
Copy link
Contributor

@dimitarvdimitrov dimitarvdimitrov left a comment

Choose a reason for hiding this comment

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

I replied to one already open comment, but LGTM, happy to merge as-is

@pracucci pracucci force-pushed the query-partitions-for-userstats branch from 57232cf to 1b44a0e Compare February 16, 2024 15:32
Signed-off-by: Marco Pracucci <marco@pracucci.com>
@pracucci pracucci force-pushed the query-partitions-for-userstats branch from 1b44a0e to 7916307 Compare February 16, 2024 15:35
@pracucci
Copy link
Collaborator Author

I replied to one already open comment, but LGTM, happy to merge as-is

Addressed (see comment).

@pracucci pracucci merged commit dcb0dfa into main Feb 16, 2024
28 checks passed
@pracucci pracucci deleted the query-partitions-for-userstats branch February 16, 2024 16:02
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