Skip to content

Easy to use Cortex: Single binary, single process #1262

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

Merged
merged 17 commits into from
May 16, 2019

Conversation

tomwilkie
Copy link
Contributor

@tomwilkie tomwilkie commented Mar 6, 2019

Fixes #1136

Build a single binary Cortex which can be told to start as an ingester, distributor, querier etc. Declare the various dependancies between modules and use code to start and stop them in the right order. Support the loading of config from a YAML file, and ship a config that allows you to start as a single process.

This replaces all the previous binaries and lite, and avoids the problem of having two (or more) copies of the init code that can get out of sync.

The follow flags have been removed:

  • -ingester.max-concurrent-streams: use -server.grpc-max-concurrent-streams
  • -query-frontend.max-recv-message-size-bytes: use -server.grpc-max-recv-msg-size-bytes
  • -memcached.* on the the frontend: use -frontend.memcached.*

And you need to add the following flag when running as a set of microservices:

  • -target={distributor,ingester,querier,query-frontend,table-manager}

TODO:

  • Single binary
  • Figure out what to do about ruler and alertmanager.
  • Test.
  • Config for single process mode.
  • Add getting started guide.
  • Test it all still works as a bunch of microservices.
@tomwilkie tomwilkie force-pushed the single-binary branch 4 times, most recently from 3d1daa6 to fd10a6b Compare March 25, 2019 14:02
)

// Client is what the ruler and altermanger needs from a config store to process rules.
type Client interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

This interface looks to be missing a GetTemplates method for alert template files, which were added in PR #1237.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @khaines - I don't understand - I don't see a GetTemplates method in that PR (or anywhere in the codebase). What am I missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think we're good - GetAlerts returns a ConfigsResponse which contains the templates, like before.

@tomwilkie tomwilkie force-pushed the single-binary branch 5 times, most recently from b1c43ae to b5bb25a Compare April 10, 2019 19:40
@tomwilkie tomwilkie marked this pull request as ready for review May 9, 2019 11:02
@tomwilkie tomwilkie force-pushed the single-binary branch 5 times, most recently from 52be491 to 3c0c054 Compare May 9, 2019 14:25
Copy link
Contributor

@gouthamve gouthamve left a comment

Choose a reason for hiding this comment

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

LGTM, but tbh, this is a biiig refactoring and it's easy to miss things.

It should only be accepted after thorough testing.

tomwilkie added 5 commits May 13, 2019 11:02
Add a new module-loading system that declaritvely states which module depends on which, and then initialises them in the correct order.

This also allows for a single-process mode where all the different modules run in the same process.

Also:
- Remove the migrations copying, and we just have a single docker image now.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
… type.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
tomwilkie added 7 commits May 13, 2019 11:02
…ddes consistently.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
…process.

This is built into the docer image to make the getting started guide a bit simplier.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
- Don't forget to register chunk encoding flags.
- Table manager still needs server.
- Don't require auth on gRPC query frontend Process method.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
@tomwilkie tomwilkie force-pushed the single-binary branch 2 times, most recently from 85b0ce8 to 415e456 Compare May 13, 2019 10:43
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
@tomwilkie
Copy link
Contributor Author

Questions form the slack channel:

Is the yaml config optional ?

Yes, command line flags will continue to work and take precedence.

-target doesn't seem a good way to express "take on this function"

Target was chosen for its similarity to make - is run this module and all its dependancies. I'm not particularly wedded to it though

can it have more than one target ?

As the code stands "no", although there is nothing to stop us doing that in the future.

should I be able to switch over service by service from my current running system ? I.e. are all inter-process APIs the same?

Yes & yes

Copy link
Contributor

@bboreham bboreham left a comment

Choose a reason for hiding this comment

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

Some initial points

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
@bboreham
Copy link
Contributor

bboreham commented May 13, 2019

This flag has also disappeared: -alertmanager.configs.url
and -alertmanager.configs.fallback

tomwilkie added 2 commits May 14, 2019 11:49
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
Also, alertmanager depends on server.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
@tomwilkie
Copy link
Contributor Author

grafana/cortex:single-binary-4ac3bf5bb is upload for testing, should fix issues with the alertmanager flags.

subrouter.PathPrefix("/api/v1").Handler(middleware.AuthenticateUser.Wrap(promRouter))
subrouter.Path("/read").Handler(middleware.AuthenticateUser.Wrap(querier.RemoteReadHandler(queryable)))
subrouter.Path("/validate_expr").Handler(middleware.AuthenticateUser.Wrap(http.HandlerFunc(dist.ValidateExprHandler)))
subrouter.Path("/user_stats").Handler(middleware.AuthenticateUser.Wrap(http.HandlerFunc(dist.UserStatsHandler)))
Copy link
Contributor

Choose a reason for hiding this comment

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

This path seems to have been dropped

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

Copy link
Contributor

@bboreham bboreham Jun 7, 2019

Choose a reason for hiding this comment

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

Unfortunately you added it back on distributor not querier, and on a different path.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
@tomwilkie tomwilkie merged commit 4bf1dcf into cortexproject:master May 16, 2019
@tomwilkie tomwilkie deleted the single-binary branch May 16, 2019 10:47
bboreham added a commit that referenced this pull request Jun 7, 2019
It moved accidentally to distributor in the single-binary change
#1262

Signed-off-by: Bryan Boreham <bryan@weave.works>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants