-
Notifications
You must be signed in to change notification settings - Fork 113
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
alias in rollup target_index field #445
alias in rollup target_index field #445
Conversation
fad78ae
to
ad231f9
Compare
ee3d235
to
d121174
Compare
7a6bade
to
89031ce
Compare
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
…ensearch-project#435) * tests * small refactor/improvements * added wildcard check when creating rollup job; removed resolving targetIndex on Rollup init; added test for wildcards * lint fixes * moved target_index validation in getRollup resp handler * removed catch block * exception fix * linter fix * fixed IT fail * added Exception catch block Signed-off-by: Petar Dzepina <[email protected]>
* reverted old error messages * reverted checking for matching jobs on whole set instead of job by job; Added picking rollup job deterministic * fixed sorting Signed-off-by: Petar Dzepina <[email protected]>
* fixed failing rollupInterceptorIT test * reverted old error messages * reverted checking for matching jobs on whole set instead of job by job; Added picking rollup job deterministic * fixed sorting * added ITs for multi rollup index search * added ITs for multi rollup index search#2 * detekt fixes * changed index names and rollup job * detekt fix * empty commit to trigger test pipeline Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
* defekt fixes * tests * small refactor/improvements * added wildcard check when creating rollup job; removed resolving targetIndex on Rollup init; added test for wildcards * lint fixes * moved target_index validation in getRollup resp handler * added using toMap() * exception fix * linter fix * fixed IT fail * added Exception catch block Signed-off-by: Petar Dzepina <[email protected]>
89031ce
to
8b9a825
Compare
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #445 +/- ##
============================================
- Coverage 75.84% 75.82% -0.03%
- Complexity 2482 2514 +32
============================================
Files 316 316
Lines 14551 14633 +82
Branches 2250 2276 +26
============================================
+ Hits 11036 11095 +59
- Misses 2251 2271 +20
- Partials 1264 1267 +3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
...main/kotlin/org/opensearch/indexmanagement/rollup/util/RollupFieldValueExpressionResolver.kt
Show resolved
Hide resolved
src/main/kotlin/org/opensearch/indexmanagement/rollup/settings/RollupSettings.kt
Show resolved
Hide resolved
src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupMapperService.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupMapperService.kt
Outdated
Show resolved
Hide resolved
src/test/kotlin/org/opensearch/indexmanagement/rollup/runner/RollupRunnerIT.kt
Show resolved
Hide resolved
src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupMapperService.kt
Outdated
Show resolved
Hide resolved
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupMapperService.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupMapperService.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupMapperService.kt
Outdated
Show resolved
Hide resolved
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Petar Dzepina <[email protected]>
rollup: Rollup, | ||
targetIndexResolvedName: String, |
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.
A couple of documentation chages:
- Let us add KDoc for description of parameters and return values. Explain the various terminology and any assumptions we are making with their operation.
- rename
rollup
torollupJob
- rename
targetIndexResolvedName
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.
- done
- "rollup" is used throughout all Rollup related files. We should probably rename all or none.
- What do you suggest? This is called "resolved name" since it can be resolved to concrete index name from mustache script or from alias
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.
- I was thinking of calling it plainly as
concreteIndex
?
src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupMapperService.kt
Outdated
Show resolved
Hide resolved
if (rollup.isTargetIndexAlias()) { | ||
if (aliasValidationResult !is RollupJobValidationResult.Valid) { | ||
return aliasValidationResult | ||
} else if (!isRollupIndex(targetIndexResolvedName, clusterService.state())) { |
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.
Can you elaborate more on this if
condition? From what I gather:
If Target Index is an alias and the alias is not valid and the target index isn't a Rollup Index, then => Prepare Target Index.
These conditions seem orthogonal and don't make a coherent sense of what we are trying to do here. Are we saying this function will validate and update and create a Target index? It seems too many responsibilities present within a single function.
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.
If Target Index is an alias and the alias IS valid and the target index isn't a Rollup Index
Only then we would "prepare target_index"
isRollupIndex would check for existence of rollup setting in index. This will be false if we're at first job run, because in case of alias, user setup index and not us.
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.
Thank you for adding the context.
Can we add all these cases to validateAndAttemptToUpdateTargetIndex()
documentation? We are appending new alias
feature on top of the existing functionality in `validateAndAttemptToUpdateTargetIndex(), so let us update the KDoc for this function.
src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupMapperService.kt
Show resolved
Hide resolved
src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupMapperService.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupMapperService.kt
Show resolved
Hide resolved
src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupMapperService.kt
Show resolved
Hide resolved
@@ -96,6 +163,52 @@ class RollupMapperService( | |||
} | |||
} | |||
|
|||
suspend fun addRollupSettingToIndex(targetIndexResolvedName: String, hasLegacyPlugin: Boolean): Boolean { | |||
val settings = if (hasLegacyPlugin) { | |||
Settings.builder().put(LegacyOpenDistroRollupSettings.ROLLUP_INDEX.key, true).build() |
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.
Does the builder have the retries built it ?
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.
You mean on updateSettings call on client? If yes, then exception would be thrown and job would fail. We don't have any retry in place for these kind of errors.
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.
This is a conversation outside this PR, but I am assuming we do not retry the updateSettings
call as we expect the next cycle of ISM execution to take care of any transient errors ?
src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupMapperService.kt
Outdated
Show resolved
Hide resolved
// 2. Put rollup mappings | ||
val putMappingRequest: PutMappingRequest = | ||
PutMappingRequest(targetIndexResolvedName).source(IndexManagementIndices.rollupTargetMappings, XContentType.JSON) | ||
val respMappings: AcknowledgedResponse = client.admin().indices().suspendUntil { | ||
putMapping(putMappingRequest, it) | ||
} | ||
if (!respMappings.isAcknowledged) { | ||
return RollupJobValidationResult.Invalid("Failed to put initial rollup mappings for target index [$targetIndexResolvedName]") | ||
} |
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.
This code has been repeated multiple times in repo (refer this), can we instead re-use the checkAndUpdateIndexMapping() helper function in IndexUtils.kt
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.
checkAndUpdateIndexMapping() wouldn't work because of shouldUpdate call
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.
shouldUpdateIndex()
will fail because at this point there are no Index mapping. Would it make sense to add a mappingCheck
as param, default value as true to checkAndUpdateIndexMapping() and then re-use it ?
Signed-off-by: Petar Dzepina <[email protected]>
* added support for mustache scripting of rollup.target_index field (#435) * tests * small refactor/improvements * added wildcard check when creating rollup job; removed resolving targetIndex on Rollup init; added test for wildcards * lint fixes * moved target_index validation in getRollup resp handler * removed catch block * fixed IT fail * added Exception catch block Signed-off-by: Petar Dzepina <[email protected]> (cherry picked from commit 70cf4ea)
* added support for mustache scripting of rollup.target_index field (#435) * tests * small refactor/improvements * added wildcard check when creating rollup job; removed resolving targetIndex on Rollup init; added test for wildcards * lint fixes * moved target_index validation in getRollup resp handler * removed catch block * fixed IT fail * added Exception catch block Signed-off-by: Petar Dzepina <[email protected]> (cherry picked from commit 70cf4ea)
* added support for mustache scripting of rollup.target_index field (#435) * tests * small refactor/improvements * added wildcard check when creating rollup job; removed resolving targetIndex on Rollup init; added test for wildcards * lint fixes * moved target_index validation in getRollup resp handler * removed catch block * fixed IT fail * added Exception catch block Signed-off-by: Petar Dzepina <[email protected]> (cherry picked from commit 70cf4ea) Co-authored-by: Petar Dzepina <[email protected]>
* added support for mustache scripting of rollup.target_index field (#435) * tests * small refactor/improvements * added wildcard check when creating rollup job; removed resolving targetIndex on Rollup init; added test for wildcards * lint fixes * moved target_index validation in getRollup resp handler * removed catch block * fixed IT fail * added Exception catch block Signed-off-by: Petar Dzepina <[email protected]> (cherry picked from commit 70cf4ea) Co-authored-by: Petar Dzepina <[email protected]>
if (rollupJobs != null && | ||
(rollupJobs.size > 1 || rollupJobs[0].id != rollup.id) | ||
) { | ||
errorMessage = "More than one rollup job present on the backing index, cannot add alias for target index: [$targetIndexResolvedName]" |
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.
Do we really add alias to target index at any point?
Or we should say More than one rollup job present on the backing index of the target alias, cannot perform rollup to this target alias.
…ch-project#586) * added support for mustache scripting of rollup.target_index field (opensearch-project#435) * tests * small refactor/improvements * added wildcard check when creating rollup job; removed resolving targetIndex on Rollup init; added test for wildcards * lint fixes * moved target_index validation in getRollup resp handler * removed catch block * fixed IT fail * added Exception catch block Signed-off-by: Petar Dzepina <[email protected]> (cherry picked from commit 70cf4ea) Co-authored-by: Petar Dzepina <[email protected]>
…ch-project#586) * added support for mustache scripting of rollup.target_index field (opensearch-project#435) * tests * small refactor/improvements * added wildcard check when creating rollup job; removed resolving targetIndex on Rollup init; added test for wildcards * lint fixes * moved target_index validation in getRollup resp handler * removed catch block * fixed IT fail * added Exception catch block Signed-off-by: Petar Dzepina <[email protected]> (cherry picked from commit 70cf4ea) Co-authored-by: Petar Dzepina <[email protected]> Signed-off-by: Ronnak Saxena <[email protected]>
Signed-off-by: Petar Dzepina [email protected]
Issue #, if available: #61
Description of changes:
Added support for using alias in rollup's target_index field
CheckList:
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.