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 more Distributor querying functions #7393

Merged
merged 4 commits into from
Feb 16, 2024

Conversation

pracucci
Copy link
Collaborator

@pracucci pracucci commented Feb 15, 2024

What this PR does

This PR, which builds on #7388, add partitions ring support to the following Distributor functions:

  • LabelNames()
  • LabelNamesAndValues()
  • LabelValuesForLabelName()
  • Distributor.MetricsForLabelMatchers()
  • Distributor.MetricsMetadata()
  • Distributor.QueryExemplars()

Note to reviewers:

  • I suggest to review tests 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.

@@ -1505,6 +1507,29 @@ func forReplicationSet[T any](ctx context.Context, d *Distributor, replicationSe
return ring.DoUntilQuorum(ctx, replicationSet, d.queryQuorumConfig(ctx, replicationSet), wrappedF, cleanup)
}

// forReplicationSets runs f, in parallel, for all ingesters in the input replication sets.
func forReplicationSets[R any](ctx context.Context, d *Distributor, replicationSets []ring.ReplicationSet, f func(context.Context, ingester_client.IngesterClient) (R, error)) ([]R, error) {
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: this function contains some duplicate code from forReplicationSet(), but forReplicationSet() will disappear in few PRs.

@@ -1553,10 +1554,6 @@ func TestDistributor_Push_HistogramValidation(t *testing.T) {
assert.Nil(t, resp)
checkGRPCError(t, tc.expectedErr, expectedDetails, err)
}

t.Cleanup(func() {
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: this is already done by prepare(). I removed it both here and in few other tests.

@@ -2698,58 +2749,78 @@ func TestDistributor_LabelNamesAndValues(t *testing.T) {
Values: []string{"200", "500"},
},
}
tests := map[string]struct {
zones []string
zonesResponseDelay map[string]time.Duration
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: the test case on zone awareness only makes sense when partitions are not used (quorum works differently with partitions). So I've extracted this test case in a dedicated t.Run().

@pracucci pracucci changed the title Add partitions ring support to Distributor's labels querying functions Add partitions ring support to more Distributor querying functions Feb 15, 2024
Base automatically changed from query-partitions to main February 15, 2024 15:46
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.

LGTM

pkg/distributor/distributor_test.go Show resolved Hide resolved
pkg/distributor/distributor_test.go Show resolved Hide resolved
pkg/distributor/distributor_test.go Outdated Show resolved Hide resolved
Added partitions support to Distributor.LabelNamesAndValues()
Added partitions support to Distributor.LabelValuesForLabelName()
Added partitions support to Distributor.MetricsForLabelMatchers()
Added partitions support to Distributor.MetricsMetadata()
Added partitions support to Distributor.QueryExemplars()

Signed-off-by: Marco Pracucci <marco@pracucci.com>
Co-authored-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
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 06:01
@pracucci pracucci requested a review from a team as a code owner February 16, 2024 06:01
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.

still LGTM although i noticed something else about the tests, maybe there's some repetition

Comment on lines +2595 to +2596
testConfig.limits = prepareDefaultLimits()
testConfig.limits.IngestionPartitionsTenantShardSize = testData.shuffleShardSize
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here I'm setting IngestionPartitionsTenantShardSize, and not IngestionTenantShardSize. When I test the ingest storage I (intentionally) don't want to set IngestionTenantShardSize, and viceversa when testing with the ingest storage disabled, in order to make sure the right config option is used for shuffle sharding. For this reason, I would need the if condition even if I will move IngestionPartitionsTenantShardSize as a prepConfig (due to the lack of a ternary operator in go).

I'm going to keep it as is for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah makes sense. I didn't read the full config option

Signed-off-by: Marco Pracucci <marco@pracucci.com>
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