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

Common storage backend config #2330

Merged
merged 16 commits into from
Jul 8, 2022
Merged

Common storage backend config #2330

merged 16 commits into from
Jul 8, 2022

Conversation

colega
Copy link
Contributor

@colega colega commented Jul 6, 2022

What this PR does

Adds a common configuration block to yaml, as well as common.-prefixed flags that will allow configuring common values for all services.

In this first iteration, we'll allow configuring a common storage backend.

The logic this follows is: flags override yaml, specific configs override common.

In particular, this means that a specific yaml configuration will be overridden by a common flag value (there's a test case for that). This is not exacty what I desired (I'd prefer to have "specific over common, flags over yaml" instead), but given the complexity of implementing the other option, I think we can accept the tradeoff.

Why is it complex to do the other option?

We would need to know how flags relate to specific struct fields (reflection-based) in order to know whether a common flag name doesn't have to be applied because it was set by yaml.

This is already hard since there's no [decent] way of sniffing what fields are being registered in the flagset with which names (actually, there might be no strict 1-1 relation between flags and fields, since flag.Value is just an interface that does stuff).

If we were able to achieve that, we'd still need to be able to distinguish whether a specific config value is there just because it was a default value or otherwise it's because yaml stated the same value as the default one.

Which issue(s) this PR fixes or relates to

Relates to #2319

Checklist

  • Tests updated
  • Documentation added: Common storage backend docs #2347
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@pracucci pracucci self-requested a review July 7, 2022 08:04
@pracucci
Copy link
Collaborator

pracucci commented Jul 7, 2022

In particular, this means that a specific yaml configuration will be overridden by a common flag value (there's a test case for that). This is not exacty what I desired (I'd prefer to have "specific over common, flags over yaml" instead), but given the complexity of implementing the other option, I think we can accept the tradeoff.

I would preferred that as well, but if it's too complex the current behaviour looks acceptable to me (as far as will be properly documented).

Copy link
Collaborator

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

Solid work! LGTM.

We need documentation for that, but it can be done in a follow up PR, so that we don't block it on doc reviews.

pkg/mimir/mimir.go Show resolved Hide resolved
@colega colega force-pushed the common-storage-backend-config branch from f5c0916 to fc1f8a4 Compare July 7, 2022 14:21
@colega colega marked this pull request as ready for review July 7, 2022 14:22
@colega
Copy link
Contributor Author

colega commented Jul 7, 2022

I've updated some tests and the tutorial to use common flags (I've left couple of tests using specific configurations, to have both of them).

I also extracted root blocks for common and providers configs as you suggested, @pracucci.

Re-requesting review since there have been a bunch of changes here, meanwhile I'll start working on adding some better docs for this (I'll include docs squad as reviewer in those).

@colega colega requested a review from pracucci July 7, 2022 14:23
Copy link
Collaborator

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

LGTM! (modulo few minor comments)

Have you manually tried the tutorial? If yes, LGTM, otherwise please test it 😉

CHANGELOG.md Outdated Show resolved Hide resolved
# The s3_backend block configures the connection to Amazon S3 object storage
# backend.
# The CLI flags prefix for this block configuration is: common.storage
[s3: <s3_storage_backend>]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I remember docs squad want to call it as the YAML config field name, so I would rename s3_storage_backend to s3. However, naming is very generic here (e.g. filesystem) and I personally like your naming.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I followed the same reasoning, wanted to go with just s3, gcs, etc, but they just looked too generic here, especially filesystem, which is not an object-storage per se.

@colega colega mentioned this pull request Jul 8, 2022
3 tasks
@colega
Copy link
Contributor Author

colega commented Jul 8, 2022

Going to merge this as the docs will come in later, and I don't want to spend my days rebasing all the e2e tests.

@pracucci
Copy link
Collaborator

pracucci commented Jul 8, 2022

LGTM merging it.

@colega colega force-pushed the common-storage-backend-config branch from f185a6b to df7d532 Compare July 8, 2022 14:12
@colega
Copy link
Contributor Author

colega commented Jul 8, 2022

Rebased.

colega and others added 16 commits July 8, 2022 16:49
We don't want to make the entire Bucket config common, because:
- We need them to have different prefixes
- They don't necessarily will reuse middlewares (actually, middlewares
are not used at all right now).

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
These use three components: ruler, alertmanager and blocks storage, so
they're a good candidate for the common config.

The config renaming is partial and will be completed in the next change,
to make the scope of this change smaller.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Co-authored-by: Marco Pracucci <marco.pracucci@grafana.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
@colega colega force-pushed the common-storage-backend-config branch from df7d532 to d652246 Compare July 8, 2022 14:50
@colega colega enabled auto-merge (squash) July 8, 2022 14:50
@colega colega merged commit 616649a into main Jul 8, 2022
@colega colega deleted the common-storage-backend-config branch July 8, 2022 15:03
@dbrennand
Copy link

Hi @colega @pracucci

Is there a container image available to use these changes?

The most recently updated image tag available on DockerHub is r193-df12d7b which I don't think includes these changes yet:

error loading config from /etc/mimir/mimir.yml: Error parsing config file: yaml: unmarshal errors:
  line 10: field common not found in type mimir.Config

masonmei pushed a commit to udmire/mimir that referenced this pull request Jul 11, 2022
* Extract storage backend config to a struct

We don't want to make the entire Bucket config common, because:
- We need them to have different prefixes
- They don't necessarily will reuse middlewares (actually, middlewares
are not used at all right now).

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Add common flags that can be overriden by specific

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Unmarshal common config yaml

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Fix typo

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* make license

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* make doc

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Use common config for ruler/alertmaneger e2e tests

These use three components: ruler, alertmanager and blocks storage, so
they're a good candidate for the common config.

The config renaming is partial and will be completed in the next change,
to make the scope of this change smaller.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Simplify configs

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Use common.storage in the tutorial

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Add TestQueryFrontendWithBlocksStorageViaCommonFlags

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Extract root blocks for common and storage backends

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Update CHANGELOG.md

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Remove sse root block

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Apply suggested CHANGELOG format

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Co-authored-by: Marco Pracucci <marco.pracucci@grafana.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Clarify comment

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Fix anchor after removing sse block

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

Co-authored-by: Marco Pracucci <marco.pracucci@grafana.com>
@pstibrany
Copy link
Member

pstibrany commented Jul 11, 2022

Hi @colega @pracucci

Is there a container image available to use these changes?

The most recently updated image tag available on DockerHub is r193-df12d7b which I don't think includes these changes yet:

error loading config from /etc/mimir/mimir.yml: Error parsing config file: yaml: unmarshal errors:
  line 10: field common not found in type mimir.Config

There is now grafana/mimir:r194-61b589d which has this PR. In general, our weekly releases builds are created on monday morning (EU time).

@replay
Copy link
Contributor

replay commented Aug 1, 2022

This is a great feature, thanks a lot for implementing it!
Do we need to update backend-enterprise so that the GEM specific block storage config also uses the config from common?

@pracucci
Copy link
Collaborator

pracucci commented Aug 2, 2022

This is a great feature, thanks a lot for implementing it! Do we need to update backend-enterprise so that the GEM specific block storage config also uses the config from common?

Already done.

@colega
Copy link
Contributor Author

colega commented Aug 2, 2022

Now we should start using it 💪

@colega colega mentioned this pull request Oct 19, 2022
3 tasks
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.

5 participants