Skip to content

Conversation

@afhassan
Copy link
Contributor

What this PR does:
Cortex supports holt_winters() for backwards compatibility. However this behaviour is currently broken as the function is only added to the engine parser at runtime and is not added to cortex_parser when it is initialized, causing queries to fail with error:

bad_data: 1:1: parse error: unknown function with name "holt_winters"

Which issue(s) this PR fixes:
Fixes #

Checklist

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

Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

Can we also refactor the code a little bit? The same code exists in

func EnableExperimentalPromQLFunctions(enablePromQLExperimentalFunctions, enableHoltWinters bool) {
.

We should try to consolidate the code. It sounds a miss of not adding holt winters here when we added the cortex parser module. If that's the case we should remove the same code above.

holtWinters.Experimental = false
holtWinters.Name = "holt_winters"
fns["holt_winters"] = &holtWinters
promql.FunctionCalls["holt_winters"] = promql.FunctionCalls["double_exponential_smoothing"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a test?
Also I am trying to understand why our integration test didn't capture this issue before. https://github.com/cortexproject/cortex/blob/master/integration/backward_compatibility_test.go#L161

Copy link
Contributor

Choose a reason for hiding this comment

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

Also I think this should be behind a feature flag as well. Same as

func EnableExperimentalPromQLFunctions(enablePromQLExperimentalFunctions, enableHoltWinters bool) {
. Even though we hardcode to true today we may want to expose a flag so that we can disable the fallback in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored it to register holt_winters for both parsers in the same place with a flag set to true.

The reason backward_compatibility_test did not catch the issue is that cortexparser was never used in it. We use it for validation in query-frontend, but there were no flags set that use cortexparser for validation. I added max_query_limit and that triggered the error.

Signed-off-by: Ahmed Hassan <afayekhassan@gmail.com>
Signed-off-by: Ahmed Hassan <afayekhassan@gmail.com>
Signed-off-by: Ahmed Hassan <afayekhassan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants