Support mixed AND/OR rollover conditions via any_of - #1667
Conversation
Add an opt-in grouped rollover syntax (any_of) to the ISM rollover action. Conditions within a group are AND-ed and groups are OR-ed (OR-of-ANDs); rollover triggers when any one group is fully satisfied. The existing flat form is unchanged and remains the default. Grouped stream serialization is version-gated at 3.7.0 for mixed-version cluster safety. Signed-off-by: Prathamesh Ladhe <praladhe@amazon.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1667 +/- ##
==========================================
+ Coverage 76.65% 76.85% +0.20%
==========================================
Files 387 388 +1
Lines 18566 18655 +89
Branches 2601 2619 +18
==========================================
+ Hits 14231 14337 +106
+ Misses 3028 3025 -3
+ Partials 1307 1293 -14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| if (out.version.onOrAfter(TARGET_VERSION)) { | ||
| out.writeBoolean(conditionGroups != null) | ||
| if (conditionGroups != null) out.writeList(conditionGroups) | ||
| } |
There was a problem hiding this comment.
what happens if a grouped policy is sent to a pre-3.7.0 node? suppose we created this policy in new version and Index was created before 3.7.0, what will the behaviour then?
There was a problem hiding this comment.
It never runs there. During a mixed-version upgrade, SkipExecution pauses all ISM (node versions differ), and the transport gate removes the groups before they reach the old node; if the old node parses the JSON directly it just rejects it (Invalid field: [any_of]).
For index created before 3.7.0 it doesn't matter as ISM evaluates live index stats (age/size/docs), not the creation version. Once the cluster is on 3.7+, the grouped policy works exactly as normal.
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 9c002de.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
Signed-off-by: praladhe <praladhe@amazon.com>
Remove io.kotest test dependencies and rewrite the three rollover any_of property-based tests on OpenSearch's built-in randomized testing. Resolves the Code-Diff-Analyzer dependency flag. Signed-off-by: praladhe <praladhe@amazon.com>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
| if (out.version.onOrAfter(Version.V_3_4_0)) { | ||
| out.writeBoolean(preventEmptyRollover) | ||
| } | ||
| if (out.version.onOrAfter(Version.V_3_7_0)) { |
There was a problem hiding this comment.
Since 3.7 is already released, we should change it to 3.8
There was a problem hiding this comment.
Agreed — if this ships in 3.8, V_3_8_0 is the right gate. I've gated on V_3_7_0 for now and will flip these to V_3_8_0 as soon as we bump the dependency to 3.8.0-SNAPSHOT.
tandonks
left a comment
There was a problem hiding this comment.
Cool looks good. Please make sure to followup on the documentation as this is a big change. Thanks for your first contribution :)
Description
Adds support for mixed AND/OR rollover conditions in the ISM
rolloveraction through anew, opt-in grouped syntax (
any_of).Today the rollover action's four conditions (
min_index_age,min_size,min_doc_count,min_primary_shard_size) are combined with pure OR — rollover triggers as soon as any singlecondition is met. There is no way to express "roll over when (age >= 7d AND size >= 50gb) OR
(doc_count >= 100000000)".
This change introduces an alternative OR-of-ANDs form. The action can hold an ordered list
of condition groups under
any_of; the conditions inside a group are AND-ed and the groups areOR-ed. Rollover triggers when any one group is fully satisfied. Because any boolean combination of
the four conditions can be rewritten as OR-of-ANDs, this covers all practical rollover policies.
Example:
{ "rollover": { "any_of": [ { "min_index_age": "7d", "min_size": "50gb" }, { "min_doc_count": 100000000 } ] } }Behavior and compatibility
any_ofform are mutually exclusive within a single rollover action; specifying both is rejected at parse/construction time.any_of, an empty group, non-positive thresholds, and unknown fields inside a group are all rejected with informative errors.3.7.0), following the existingprevent_empty_rollover/3.4.0pattern, so mixed-version clusters operate safely — older nodes never receive groups and fall back to flat behavior.prevent_empty_rolloverempty-index guard is preserved unchanged and still runs before condition evaluation.any_ofarray; flat reporting is unchanged.Changes
RolloverConditionGroupmodel (parsing, validation, XContent + stream serialization).RolloverAction: new optionalconditionGroupsfield, mutual-exclusivity/empty validation, grouped XContent output, and version-gated stream write; newany_ofconstant andTARGET_VERSION.RolloverActionParser: parseany_offrom XContent and version-gated read from stream.evaluateConditionsinManagedIndexUtils: refactored to a shared per-condition comparison helper reused by both flat (OR) and grouped (OR-of-ANDs) paths, keeping flat behavior byte-identical.AttemptRolloverStep: report flat conditions or groupedany_ofcriteria.any_ofand bumpedschema_version29 → 30 (mapping and cached test copy kept in sync; testconfigSchemaVersionupdated).Testing
RolloverActionIT(incl. a new end-to-end groupedany_oftest) andIndexManagementIndicesITpass against a real cluster.3.7.0cluster: a grouped policy rolled over when one group's conditions were satisfied while another group's were not.Public Documentation PR: #12740
API changes companion pull request: #1158
Related Issues
Resolves #1540
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.