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

Move cortex' querier split_queries_by_interval to limits config #5184

Closed

Conversation

ssncferreira
Copy link
Contributor

@ssncferreira ssncferreira commented Jan 19, 2022

What this PR does / why we need it:

Move split_queries_by_interval config from cortex' queryrange package to limits config.

Special notes for your reviewer:

Checklist

  • Documentation updated
  • Tests updated
  • Add an entry in the CHANGELOG.md about the changes.

@ssncferreira ssncferreira force-pushed the deprecate_querier_split_queries_by_interval branch from 2a5cf06 to 305e520 Compare January 20, 2022 14:34
@ssncferreira ssncferreira changed the title Deprecate querier split_queries_by_interval Deprecate cortex' querier split_queries_by_interval Jan 20, 2022
@ssncferreira ssncferreira self-assigned this Jan 20, 2022
@ssncferreira ssncferreira marked this pull request as ready for review January 20, 2022 14:42
@ssncferreira ssncferreira requested review from KMiller-Grafana and a team as code owners January 20, 2022 14:42
@@ -52,6 +52,7 @@ var (

// Config for query_range middleware chain.
type Config struct {
// Deprecated: SplitQueriesByInterval will be removed in the next major release
Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do we keep track of the flags that will be deprecated on follow-up releases? Should one issue be created to remind us of this flag? 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we do any logging around use of deprecated fields?

Copy link
Contributor

@cyriltovena cyriltovena Jan 24, 2022

Choose a reason for hiding this comment

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

I think we have flagext.DeprecatedFlag( from dskit log a warning. So worth looking into that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cyriltovena set the flag with flagext.DeprecatedFlag on commit c99dd51

Copy link
Member

Choose a reason for hiding this comment

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

If we move the same flag to the limits struct, we don't need to deprecate it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in commit: d35fcf3

@ssncferreira ssncferreira force-pushed the deprecate_querier_split_queries_by_interval branch 3 times, most recently from 195a515 to 161f8b3 Compare January 26, 2022 12:07
@pull-request-size pull-request-size bot added size/L and removed size/M labels Jan 26, 2022
Copy link
Collaborator

@trevorwhitney trevorwhitney left a comment

Choose a reason for hiding this comment

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

Looks great! My only question is why deprecate the old flag and introduce a new one vs changing where the flag is registered into limits.go? Seems less disruptive to me to do the latter since it achieves the same outcome.

pkg/querier/queryrange/queryrangebase/roundtrip.go Outdated Show resolved Hide resolved
pkg/validation/limits.go Outdated Show resolved Hide resolved
Copy link
Member

@owen-d owen-d left a comment

Choose a reason for hiding this comment

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

Looking good, but left some suggestions.

res.splitDuration = conf.SplitQueriesByInterval
}
// Set as the default split by interval value
res.splitDuration = l.QuerySplitDurationDefault()
Copy link
Member

Choose a reason for hiding this comment

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

We should be able to remove res.splitDuration now, since it'll be automatically covered in the underlying Limits impl. Previously we needed to support tenant override > tenant default > global default, but we've removed global default and we already handle the first two in the underlying implementation: https://github.com/grafana/loki/blob/main/pkg/validation/limits.go#L530-L538

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh yeah, +1 to this as well.

Copy link
Contributor Author

@ssncferreira ssncferreira Jan 26, 2022

Choose a reason for hiding this comment

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

@owen-d I don't think we can remove res.splitDuration because of function WithSplitByLimits:

func WithSplitByLimits(l Limits, splitBy time.Duration) Limits {
return limits{
Limits: l,
splitDuration: splitBy,
}
}

used to force a 24-hour split in the query range middleware of the NewSeriesTripperware and NewLabelsTripperware

pkg/validation/limits.go Outdated Show resolved Hide resolved
pkg/querier/queryrange/queryrangebase/roundtrip.go Outdated Show resolved Hide resolved
if conf.SplitQueriesByInterval != 0 {
res.splitDuration = conf.SplitQueriesByInterval
level.Warn(util_log.Logger).Log("deprecated", "yaml flag 'query_range.split_queries_by_interval' is deprecated, use yaml flag 'limits_config.split_queries_by_interval' or CLI flag -querier.split-queries-by-interval instead.",
"default split_queries_by_interval", l.QuerySplitDurationDefault())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For users currently using the config file, setting res.splitDuration = conf.SplitQueriesByInterval has no effect here. Since limits now contain a default value (30 minutes), this will always be returned, meaning clause:

if dur == 0 {
return l.splitDuration
}

will never be reached.

Therefore, for users currently using the config file (while the flag is not removed), I see two options:

  1. global default value of 30 minutes is overwritten by the value of conf.SplitQueriesByInterval
  2. Solution here implemented: simply log a warning and use the default value of 30 minutes

What do you think?

@ssncferreira ssncferreira changed the title Deprecate cortex' querier split_queries_by_interval Move cortex' querier split_queries_by_interval to limits config Jan 26, 2022
@ssncferreira ssncferreira force-pushed the deprecate_querier_split_queries_by_interval branch from faa9a0e to 411a5ff Compare January 26, 2022 20:22
@ssncferreira ssncferreira force-pushed the deprecate_querier_split_queries_by_interval branch from 411a5ff to 8399387 Compare January 26, 2022 20:38
@ssncferreira
Copy link
Contributor Author

Closing in favor of #5243

@ssncferreira ssncferreira deleted the deprecate_querier_split_queries_by_interval branch January 27, 2022 18:29
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.

4 participants