Skip to content

Conversation

tomwilkie
Copy link
Contributor

@tomwilkie tomwilkie commented Jan 18, 2017

Fixes #194, fixes #151

  • Push flag definitions onto the respective config objects
  • Separate binaries for each component
  • Add a new component: cortex_querier (currently a dressed up distributor)
  • New server package for common server logic
  • Makefile magic to decide what services to build
  • Nest the consul client in the ring, and the ring in the ingester registerer, as they share config.
  • Make the chunk cache initialise itself, and noop if isn't provided a hostname
  • Move prometheus.MustRegister into each component to reduce repetition

@tomwilkie tomwilkie self-assigned this Jan 18, 2017
@tomwilkie tomwilkie force-pushed the 151-split-it-up branch 4 times, most recently from c22f249 to 327cd5a Compare January 19, 2017 18:56
@tomwilkie tomwilkie changed the title [WIP] Spit up the single Cortex binary into cortex_{distributor, ingester, querier, ruler, table_manager} [WIP] Spit up the single Cortex binary into cortex-{distributor, ingester, querier, ruler, table-manager} Jan 19, 2017
@tomwilkie tomwilkie force-pushed the 151-split-it-up branch 5 times, most recently from bfc04dd to 176bc38 Compare January 20, 2017 17:54
@tomwilkie tomwilkie changed the title [WIP] Spit up the single Cortex binary into cortex-{distributor, ingester, querier, ruler, table-manager} Split up the single Cortex binary into cortex-{distributor, ingester, querier, ruler, table-manager} Jan 20, 2017
var (
serverConfig = server.Config{}
ingesterRegistrationConfig = ring.IngesterRegistrationConfig{
ListenPort: &serverConfig.GRPCListenPort, // IngesterRegistrator need to know our gRPC listen port
Copy link
Contributor

Choose a reason for hiding this comment

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

need -> needs


func main() {
var (
serverConfig = server.Config{}
Copy link
Contributor

Choose a reason for hiding this comment

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

The var serverConfig = server.Config{} style here and below is just a bit unusual. More usual would be either var serverConfig server.Config or serverConfig := server.Config{} (not a mix of var and explicit assignment of zero value).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point, I'll make it this:

var (
  serverConfig server.Config
  ...
)

"github.com/prometheus/common/model"
)

// Registerer is a think that can RegisterFlags
Copy link
Contributor

Choose a reason for hiding this comment

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

think -> thing

@juliusv
Copy link
Contributor

juliusv commented Jan 22, 2017

👍

@juliusv
Copy link
Contributor

juliusv commented Jan 22, 2017

Btw., do we need the cortex- prefix in the binary dirs? Since it's all part of Cortex, it seems a bit redundant.

@tomwilkie
Copy link
Contributor Author

Btw., do we need the cortex- prefix in the binary dirs? Since it's all part of Cortex, it seems a bit redundant.

I'm using it to generate the binary and image name, and image name definitely needs it. I can include that as a constant in the Makefile though. Let me give that a go.

@juliusv
Copy link
Contributor

juliusv commented Jan 23, 2017

👍

- Push flag definitions onto the respective config objects
- Separate binaries for each component
- Add a new component: cortex_querier (currently a dressed up distributor)
- New server package for common server logic
- Makefile magic to decide what services to build
- Nest the consul client in the ring, and the ring in the ingester registerer, as they share config.
- Move prometheus.MustRegister into each component to reduce repetition
- Remove ingester http interface
- Move ring prometheus metrics to package-level, so we can instantiate the IngesterRegistration more than once.
@tomwilkie
Copy link
Contributor Author

@juliusv @jml I think this is ready to merge now; will do so tomorrow morning unless I hear otherwise?

@jml
Copy link
Contributor

jml commented Jan 24, 2017

Great stuff.

In person yesterday, you mentioned a pattern for constructors for components. Could you please jot that down in text somewhere in the repo?

@tomwilkie tomwilkie merged commit 2be2a2e into master Jan 24, 2017
@tomwilkie tomwilkie deleted the 151-split-it-up branch January 24, 2017 09:55
@jml
Copy link
Contributor

jml commented Jan 24, 2017

I'll take that as a no.

@@ -165,6 +174,7 @@ func New(cfg Config, chunkStore cortex_chunk.Store) (*Ingester, error) {
Help: "The total number of samples returned from queries.",
}),
}
prometheus.MustRegister(i)
Copy link
Contributor

Choose a reason for hiding this comment

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

@tomwilkie Registering Prometheus metrics from a constructor is problematic because it makes it impossible to instantiate multiple objects of the same type (the Prometheus client library will panic). I'm hitting this with ingester tests right now. While there's a non-panicking Register method, neither returning its error nor letting it silently fail seem like the right choice.

I would propose either moving this out of the constructor again or making the metrics global. Which one do you prefer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm hitting this with ingester tests right now

Have you written some new tests? Wondering why I didn't hit it.

I would propose either moving this out of the constructor again or making the metrics global. Which one do you prefer?

Global please. For consistency sake, I'd like everything to be global - I'm not concerned about the namespace pollution, and going global results in less code, which is one of the things I care most about.

Copy link
Contributor

Choose a reason for hiding this comment

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

Have you written some new tests? Wondering why I didn't hit it.

Yeah, I hit this when writing a second ingester test for the series limiting.

Global please.

Ok, will get to it next week.

FWIW, with having metrics globally, the concern is less about global variable namespace pollution, but about anyone wanting to reuse a package getting globally registered metrics forced on them. As long as we don't care about reuse, that's fine.

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.

Separate out query service Split up cortex into different binaries / images
3 participants