-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Scripted metric aggregations: add deprecation warning and system property to control legacy params #31597
Scripted metric aggregations: add deprecation warning and system property to control legacy params #31597
Conversation
…erty to control legacy params Scripted metric aggregation params._agg/_aggs are replaced by state/states context variables. By default the old params are still present, and a deprecation warning is emitted when Scripted Metric Aggregations are used. A new system property can be used to disable the legacy params. This functionality will be removed in a future revision.
Pinging @elastic/es-search-aggs |
@rationull @rjernst I think I've missed something here. Was it intended that #30111 was backported to 6.x so we can deprecate the use of |
@rjernst's suggestion in a comment on backwards compatibility in #30111 mentioned it may be backported to 6.x, but my assumption was that even if not, the old functionality should be deprecated for a release regardless of of whether that release is 6 or 7. If that's not correct then this can be disregarded and I can submit a PR removing the old functionality with no deprecation step. (I'm not trying to push a particular schedule here - whatever you all think makes the most sense.) |
@rationull you are right that this PR would be needed to deprecate the old functionality in master even if we don't back-port so this PR is definitely needed. The question is whether #30111 should have been back-ported to 6.x. @rjernst I am on vacation after today so if I should have back-ported #30111 then I am happy either for you to do the back-port of the commit or I can do it when I return. If you could leave a comment either here or on #30111 indicating what should be done that would be great. |
Yes, #30111 should be backported to 6.x I will do that next week. |
The back port of #30111 is complete. |
Thanks @rjernst. Then this should be tagged v6.4.0 too presumably? |
Yes, I've added the 6.4.0 label. |
Thanks for backporting this @rjernst |
Updated with latest from master. @colings86 does this look OK to you and would you mind kicking it to Jenkins? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the ping @rationull, this slipped off my list to review following my vacation so the reminder was definitely needed. I left a small comment but I'll set off CI so we can catch any failures in the meantime too
aggParams.put("_agg", new HashMap<String, Object>()); | ||
Object aggState = new HashMap<String, Object>(); | ||
if (ScriptedMetricAggContexts.deprecatedAggParamEnabled()) { | ||
if (!aggParams.containsKey("_agg")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we tend to prefer aggParams.containsKey("_agg") == false
as its more obvious to read since !
can easily be missed
@elasticmachine test this please |
@colings86 thanks, I will address the comment when I address the test failure. Looks like a trivial failure -- I neglected to add the expected warning headers to the docs. |
@colings86 fixed the style nit and the test failures. The docs sample test setup is pretty slick! Would you mind kicking this to CI again? |
@elasticmachine test this please |
@rationull the latest failure looks unrelated to your changes but would you be able to update your branch with the latest master and I'll kick off CI again to see if we can get a clean run? |
I agree that this failure looks unrelated. I haven't managed to reproduce it in several runs; I wonder if it's a timing issue that would disappear even with another run as-is? The |
@colings86 the branch is updated now. |
@elasticmachine test this please |
@@ -26,6 +26,7 @@ POST ledger/_search?size=0 | |||
-------------------------------------------------- | |||
// CONSOLE | |||
// TEST[setup:ledger] | |||
// TEST[warning:params._agg/_aggs for scripted metric aggregations are deprecated, use state/states (not in params) instead. Set system property es.aggregations.enableDeprecatedScriptedMetricAggParam = false to disable this deprecated behavior.] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for not seeing this earlier: I think we should make the test cluster set the system property so the deprecated behaviour is not used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it should be set to the new behavior in all tests, and a specific test added for the bwc behavior. See https://github.com/elastic/elasticsearch/pull/30975/files#diff-407c748a710cb1e33230c1fd06da7f16R694 for how it was done recently for another bwc change (although adding the sysprop in BuildPlugin should really have a comment indicating the purpose and when it can be removed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent -- thanks for the feedback. I already have a commit in another branch updating the various tests to use the new context variables (PR to follow this one) so I can bring over those changes and add another dedicated test class for the old behavior similar to ScriptDocValuesMissingV6BehaviourTests
from that example.
I should be able to get back to this some evening this week. In the meantime to make sure we're on the same page, please let me know if this is different from what you had in mind:
- The deprecated behavior will be disabled in general via setting
enableDeprecatedScriptedMetricAggParam
to false centrally in BuildPlugin.groovy. With a comment that this gets remove presumably in 7.0. - The deprecated behavior will be enabled again for a single dedicated integration test class (because this will get us better coverage across the affected classes vs a unit test).
Some of the test changes are substantial (ScriptedMetricIT specifically) so heads up this review will get bigger.
@elasticmachine ok to test |
Merged in the latest from master. Not sure what's going on with the CI failure -- |
I agree it does not look related, and it also does not reproduce for me. Let's try again. @elasticmachine test this please |
Looks like the same failure. @colings86 do you have any ideas? I do not see with that AckIT has to do with scripted metric aggregations. |
Merged in master again and the builds have passed this time. |
This looks fine from my side now, @colings86 do you want to review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM2, I'll merge and backport this now
@rationull thanks again for working on this. Are you able to create a PR for removing the deprecation stuff in master (7.0) as well (the TODOs in the code)? |
Backport pending for 6.x branch, waiting for build on #32944 |
@colings86 absolutely -- I'll make a PR for removing the deprecated stuff this weekend. |
Awesome, thanks 👍 |
* elastic/master: (46 commits) NETWORKING: Make RemoteClusterConn. Lazy Resolve DNS (#32764) [DOCS] Splits the users API documentation into multiple pages (#32825) [DOCS] Splits the token APIs into separate pages (#32865) [DOCS] Creates redirects for role management APIs page Bypassing failing test PainlessDomainSplitIT#testHRDSplit (#32966) TEST: Mute testRetentionPolicyChangeDuringRecovery [DOCS] Fixes more broken links to role management APIs [Docs] Tweaks and fixes to rollup docs [DOCS] Fixes links to role management APIs [ML][TEST] Fix BasicRenormalizationIT after adding multibucket feature [DOCS] Splits the roles API documentation into multiple pages (#32794) [TEST] Run pre 6.4 nodes in non-FIPS JVMs (#32901) Make Geo Context Mapping Parsing More Strict (#32821) [ML] fix updating opened jobs scheduled events (#31651) (#32881) Scripted metric aggregations: add deprecation warning and system property to control legacy params (#31597) Tests: Fix timezone conversion in DateTimeUnitTests Enable FIPS140LicenseBootstrapCheck (#32903) Fix InternalAutoDateHistogram reproducible failure (#32723) Remove assertion in testDocStats on deletedDocs counter (#32914) HLRC: Move ML request converters into their own class (#32906) ...
@colings86 I created #32979 for removing the deprecated code and TODOs. |
) property to control legacy params (#31597) * Scripted metric aggregations: add deprecation warning and system property to control legacy params Scripted metric aggregation params._agg/_aggs are replaced by state/states context variables. By default the old params are still present, and a deprecation warning is emitted when Scripted Metric Aggregations are used. A new system property can be used to disable the legacy params. This functionality will be removed in a future revision. * Fix minor style issue and docs test failure * Disable deprecated params._agg/_aggs in tests and revise tests to use state/states instead * Add integration test covering deprecated scripted metrics aggs params._agg/_aggs access * Disable deprecated params._agg/_aggs in docs integration tests and revise stored scripts to use state/states instead * Revert unnecessary migrations doc change A relevant note should be added in the changes destined for 7.0; this PR is going to be backported to 6.x. * Replace deprecated _agg param bwc integration test with a couple of unit tests * Fix compatibility test after merge * Rename backwards compatibility system property per code review feedback * Tweak deprecation warning text per review feedback buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy server/src/test/java/org/elasticsearch/search/aggregations/metrics/scrip ted/ScriptedMetricAggregatorTests.java /Users/colings86/dev/work/git/elasticsearch/.git/worktrees/elasticsearch -6.x/CHERRY_PICK_HEAD buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy server/src/main/java/org/elasticsearch/script/ScriptedMetricAggContexts. java server/src/main/java/org/elasticsearch/search/aggregations/metrics/scrip ted/InternalScriptedMetric.java server/src/main/java/org/elasticsearch/search/aggregations/metrics/scrip ted/ScriptedMetricAggregatorFactory.java server/src/test/java/org/elasticsearch/search/aggregations/metrics/Scrip tedMetricIT.java server/src/test/java/org/elasticsearch/search/aggregations/metrics/scrip ted/InternalScriptedMetricAggStateV6CompatTests.java server/src/test/java/org/elasticsearch/search/aggregations/metrics/scrip ted/InternalScriptedMetricTests.java server/src/test/java/org/elasticsearch/search/aggregations/metrics/scrip ted/ScriptedMetricAggregatorAggStateV6CompatTests.java server/src/test/java/org/elasticsearch/search/aggregations/metrics/scrip ted/ScriptedMetricAggregatorTests.java
) property to control legacy params (#31597) * Scripted metric aggregations: add deprecation warning and system property to control legacy params Scripted metric aggregation params._agg/_aggs are replaced by state/states context variables. By default the old params are still present, and a deprecation warning is emitted when Scripted Metric Aggregations are used. A new system property can be used to disable the legacy params. This functionality will be removed in a future revision. * Fix minor style issue and docs test failure * Disable deprecated params._agg/_aggs in tests and revise tests to use state/states instead * Add integration test covering deprecated scripted metrics aggs params._agg/_aggs access * Disable deprecated params._agg/_aggs in docs integration tests and revise stored scripts to use state/states instead * Revert unnecessary migrations doc change A relevant note should be added in the changes destined for 7.0; this PR is going to be backported to 6.x. * Replace deprecated _agg param bwc integration test with a couple of unit tests * Fix compatibility test after merge * Rename backwards compatibility system property per code review feedback * Tweak deprecation warning text per review feedback buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy server/src/test/java/org/elasticsearch/search/aggregations/metrics/scrip ted/ScriptedMetricAggregatorTests.java /Users/colings86/dev/work/git/elasticsearch/.git/worktrees/elasticsearch -6.x/CHERRY_PICK_HEAD buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy server/src/main/java/org/elasticsearch/script/ScriptedMetricAggContexts. java server/src/main/java/org/elasticsearch/search/aggregations/metrics/scrip ted/InternalScriptedMetric.java server/src/main/java/org/elasticsearch/search/aggregations/metrics/scrip ted/ScriptedMetricAggregatorFactory.java server/src/test/java/org/elasticsearch/search/aggregations/metrics/Scrip tedMetricIT.java server/src/test/java/org/elasticsearch/search/aggregations/metrics/scrip ted/InternalScriptedMetricAggStateV6CompatTests.java server/src/test/java/org/elasticsearch/search/aggregations/metrics/scrip ted/InternalScriptedMetricTests.java server/src/test/java/org/elasticsearch/search/aggregations/metrics/scrip ted/ScriptedMetricAggregatorAggStateV6CompatTests.java server/src/test/java/org/elasticsearch/search/aggregations/metrics/scrip ted/ScriptedMetricAggregatorTests.java
Removing the "backport pending" label since this has been merged to 6.5 with edb577f |
This is a followup to PR #30111 implementing issue #29328.
This implements the suggestion from @rjernst that the legacy
params._agg/_aggs
should be available by default and disabled via a system property. A deprecation warning is emitted when scripted metric aggregations are used with the deprecated params enabled.This is to be followed up with another PR removing the deprecated behavior (and updating relevant tests). I have that implemented but will finalize it after making any requested changes here, and presumably it wouldn't get merged until this is ported to the appropriate release branch and a target branch is selected for removing the old params.