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

Feature: allow querier and query frontend targets to run on same process #4301

Merged
merged 7 commits into from
Sep 15, 2021

Conversation

trevorwhitney
Copy link
Collaborator

What this PR does / why we need it:
This PR allows both the Query and QueryFrontend targets to be enabled in the same loki process, as well as adding QueryFrontend to the "all" target. It follows a similar pattern as was done in cortex, where a query worker service is enabled with an internal router to handle query endpoints. Those endpoints are either a) exposed externally if the querier is running standalone, b) used internally by the query worker if the querier is running alongside the query frontend (since the query fronted will register those same routes externally).

Which issue(s) this PR fixes:
Fixes #4218

Special notes for your reviewer:

Checklist

  • Documentation added
  • Tests updated

@trevorwhitney trevorwhitney requested a review from a team as a code owner September 9, 2021 17:58
@trevorwhitney trevorwhitney changed the title 4218 internal querier Feature: allow querier and query frontend targets to run on same process Sep 9, 2021
pkg/loki/modules.go Outdated Show resolved Hide resolved
assert.Equal(t, "test handler", recorder.Body.String())
})

t.Run("wrap external handler with auth middleware", func(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This took me a few minutes to understand, the test name implied something was being done but after looking around I was able to see that every test actually has the auth middleware.

The other part of this I'm a little worried about is the use of a global variable, this feels a little brittle to me over time.

What if instead the testContext function took a config and a middleware.Interface which you could then provide a specific version of for this test which does what the current noop middleware does but it would be scoped within this test.

All the other tests could then just call testContext(config, nil) or you could make a separate testContextWithMiddleware(config, middleware.Interface) and have testContext call that with a nil middleware to save refactoring all your tests

WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I like it! IMO a test should always be easier to understand than the code it's testing, so I love simplifications and clarifications.

@slim-bean
Copy link
Collaborator

Looks good @trevorwhitney! A couple suggestions, and the linter doesn't like a typo and I think we should be good to go!

trevorwhitney and others added 7 commits September 15, 2021 11:24
Signed-off-by: Trevor Whitney <trevorjwhitney@gmail.com>
Signed-off-by: Trevor Whitney <trevorjwhitney@gmail.com>
Signed-off-by: Trevor Whitney <trevorjwhitney@gmail.com>
Co-authored-by: Ed Welch <edward.welch@grafana.com>
Signed-off-by: Trevor Whitney <trevorjwhitney@gmail.com>
Signed-off-by: Trevor Whitney <trevorjwhitney@gmail.com>
Copy link
Collaborator

@slim-bean slim-bean left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow Querier and Query Frontend to run in the same process
2 participants