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

Ruler: validation and logging with disabled tenant federation #4555

Merged
merged 10 commits into from
Mar 27, 2023

Conversation

dimitarvdimitrov
Copy link
Contributor

What this PR does

This PR bundles two changes because they are related and small

  • reject creating federated rule groups when ruler tenant federation is
    disabled. Currently, the rule groups would be silently ignored during
    bucket syncs. This made the UX around creating federated rules confusing
    because there was no feedback as to why the groups aren't evaluating
  • log an info line on each sync when a federated rule group is skipped
    because the feature is disabled

Technically the first is a breaking change, but I think no one would
depend on this behaviour.

Signed-off-by: Dimitar Dimitrov dimitar.dimitrov@grafana.com

Which issue(s) this PR fixes or relates to

Fixes #

Checklist

  • Tests updated
  • [n/a] Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@@ -55,11 +57,12 @@ func TenantFederationQueryFunc(regularQueryable, federatedQueryable rules.QueryF
}
}

func RemoveFederatedRuleGroups(groups map[string]rulespb.RuleGroupList) {
func removeFederatedRuleGroups(groups map[string]rulespb.RuleGroupList, logger log.Logger) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This wasn't used outside the package. I also checked github code search and couldn't find any usages of it in upstream projects (including GEM)

pkg/ruler/api_test.go Outdated Show resolved Hide resolved
pkg/ruler/tenant_federation.go Outdated Show resolved Hide resolved
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! I just left a nit. Also good question from @charleskorn.

pkg/ruler/manager.go Outdated Show resolved Hide resolved
@dimitarvdimitrov dimitarvdimitrov added the type/docs Improvements or additions to documentation label Mar 22, 2023
This PR bundles two changes because they are related and small

* reject creating federated rule groups when ruler tenant federation is
disabled. Currently, the rule groups would be silently ignored during
bucket syncs. This made the UX around creating federated rules confusing
because there was no feedback as to why the groups aren't evaluating
* log an info line on each sync when a federated rule group is skipped
because the feature is disabled

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Copy link
Contributor

@gotjosh gotjosh left a comment

Choose a reason for hiding this comment

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

LGTM, all of my comments are tiny nits. I'll let you choose which ones you'd like to implement, and I certainly don't need to see this again.

Looks 👌

pkg/ruler/manager.go Outdated Show resolved Hide resolved
pkg/ruler/tenant_federation.go Outdated Show resolved Hide resolved
for userID, groupList := range groups {
amended := make(rulespb.RuleGroupList, 0, len(groupList))
for _, group := range groupList {
if len(group.GetSourceTenants()) > 0 {
level.Warn(logger).Log("msg", "skipping federated rule group because rule federation is disabled", "namespace", group.Namespace, "group_name", group.Name, "user", userID)
Copy link
Contributor

Choose a reason for hiding this comment

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

👌

This has the potential to be very very noisy, perhaps we should consider using rate limited logger? Also if it feels more natural to me to indicate back to the operator here that we should include To enable the feature, configure the Mimir or GEM ruler instance with the following parameter.... you had earlier on.

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 agree that having the config options in the log line is more appropriate.

I'm not sure about the rate limiter. It will also mute the warning for some groups. Let's see how this works in grafana cloud, maybe we can add it afterwards.

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
@dimitarvdimitrov dimitarvdimitrov requested a review from a team as a code owner March 27, 2023 08:21
labels:
test: test
`,
err: errors.New("invalid rules config: rule group 'test' is a federated rule group, but rules federation is disabled; please contact your service administrator to have it enabled"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
err: errors.New("invalid rules config: rule group 'test' is a federated rule group, but rules federation is disabled; please contact your service administrator to have it enabled"),
err: errors.New("invalid rules configuration: rule group 'test' is a federated rule group, but rules federation is disabled; contact your service administrator to have it enabled."),

Are you talking about a configuration or a config file. (I assume the former.)

Copy link
Contributor

Choose a reason for hiding this comment

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

(Not sure if the operator or end user will see this text.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you talking about a configuration or a config file. (I assume the former.)

It's more a configuration - you're right. I'll also change the validations that include this string.

(Not sure if the operator or end user will see this text.)

this will be seen by end users (although this string in particular is part of our tests, but it matches the string that the user will see)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also - it's a go convention to not put punctuation at the end of errors, so I'll only replace config with configuration

Copy link
Contributor

@osg-grafana osg-grafana left a comment

Choose a reason for hiding this comment

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

Unblocking with feedback

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
@dimitarvdimitrov dimitarvdimitrov enabled auto-merge (squash) March 27, 2023 11:01
@dimitarvdimitrov dimitarvdimitrov merged commit d901233 into main Mar 27, 2023
@dimitarvdimitrov dimitarvdimitrov deleted the dimiatr/ruler-federated-groups branch March 27, 2023 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/ruler type/docs Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants