-
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
Support copy alias in rollover #892
Support copy alias in rollover #892
Conversation
ce71221
to
181c359
Compare
Codecov Report
@@ Coverage Diff @@
## 2.9 #892 +/- ##
============================================
+ Coverage 75.95% 75.97% +0.01%
- Complexity 2891 2897 +6
============================================
Files 366 366
Lines 16558 16624 +66
Branches 2397 2411 +14
============================================
+ Hits 12577 12630 +53
- Misses 2601 2608 +7
- Partials 1380 1386 +6
|
Signed-off-by: bowenlan-amzn <[email protected]>
181c359
to
140d021
Compare
why is copyAlias defaulting to false. it seems like a very useful feature. |
have we done any upgrade testing to ensure we are not introducing regression in mapping to verify ISM config index mapping change works as expected? |
...lin/org/opensearch/indexmanagement/indexstatemanagement/step/rollover/AttemptRolloverStep.kt
Show resolved
Hide resolved
...lin/org/opensearch/indexmanagement/indexstatemanagement/step/rollover/AttemptRolloverStep.kt
Show resolved
Hide resolved
@@ -632,4 +630,102 @@ class RolloverActionIT : IndexStateManagementRestTestCase() { | |||
} | |||
assertTrue("New rollover index does not exist.", indexExists("$indexNameBase-000002")) | |||
} | |||
|
|||
@Suppress("UNCHECKED_CAST") | |||
fun `test rollover with copy 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.
we should also add a test case where copy alias fails.
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.
For the failed cases where alias API throw exception, we don't have an way to mock that in IT in ISM code base. Should be sth we can look into later.
...lin/org/opensearch/indexmanagement/indexstatemanagement/step/rollover/AttemptRolloverStep.kt
Show resolved
Hide resolved
...lin/org/opensearch/indexmanagement/indexstatemanagement/step/rollover/AttemptRolloverStep.kt
Outdated
Show resolved
Hide resolved
Signed-off-by: bowenlan-amzn <[email protected]>
Signed-off-by: bowenlan-amzn <[email protected]>
if (conditions != null) "conditions" to conditions else null | ||
).toMap() | ||
} else { | ||
stepStatus = StepStatus.FAILED |
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 we mark this failed after rollover is completed it would send a wrong message right.
what failed here is the copyalias step which should be logged and somehow notified to user.
Or can we have a different message that
"rollover completed but copy alias failed"
How will user handle this by himself?
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.
Cx can copy by themselves, uses retry API to move to next state, or let this rollover step auto retry.
We don't support running 2 steps continuously right now, so copy alias is not implemented as a separate step. If separate, it will only be done in the next job run but the requirement is to do it right after rollover or with rollover.
...lin/org/opensearch/indexmanagement/indexstatemanagement/step/rollover/AttemptRolloverStep.kt
Outdated
Show resolved
Hide resolved
@@ -288,5 +385,13 @@ class AttemptRolloverStep(private val action: RolloverAction) : Step(name) { | |||
fun getSkipRolloverMessage(index: String) = "Skipped rollover action for [index=$index]" | |||
fun getAlreadyRolledOverMessage(index: String, alias: String) = | |||
"This index has already been rolled over using this alias, treating as a success [index=$index, alias=$alias]" | |||
fun getSuccessCopyAliasMessage(index: String, newIndex: String) = | |||
"Successfully rolled over and copied alias from [index=$index] to [index=$newIndex]" | |||
fun getFailedCopyAliasMessage(index: String, newIndex: 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.
when there is failure we should also append the exception cause message.
this is a current problem in ISM that we would have to deep dive logs for the cause.
let's add it here.
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.
General exception message will be put into the cause
field of info. Specific exception message is rewritten in customer friendly way in message
field.
Shouldn't we make this change in core and add option to copy aliases in rollover api? |
Signed-off-by: bowenlan-amzn <[email protected]>
9a0c192
to
a0a42de
Compare
Of course it's best to support this in core and the open issue is here #849 |
Signed-off-by: bowenlan-amzn <[email protected]>
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.
LGTM.
thanks for the changes, @bowenlan-amzn
Hope users can update existing ISM policies and set copyAlias=true |
* Support copy alias in rollover Signed-off-by: bowenlan-amzn <[email protected]> * Add more tests Signed-off-by: bowenlan-amzn <[email protected]> * Add bwc test Signed-off-by: bowenlan-amzn <[email protected]> * Enhance tests Signed-off-by: bowenlan-amzn <[email protected]> * Improve not acknowledge call scenario Signed-off-by: bowenlan-amzn <[email protected]> --------- Signed-off-by: bowenlan-amzn <[email protected]>
* Support copy alias in rollover * Add more tests * Add bwc test * Enhance tests * Improve not acknowledge call scenario --------- Signed-off-by: bowenlan-amzn <[email protected]>
Issue #, if available:
#734
Description of changes:
copy_alias
under rollover action, that can let user choose whether to copy the alias from old index to new index during rollover.rolled_over_index_name
saved in metadata.rolled_over_index_name
is saved after rollover succeededcopy_alias
,rolled_over_index_name
are added to the ISM config index mapping, making sure it won't be added by dynamic mapping and causes mapping conflict regressioncopy_alias
in policy.action will be handled during create/update policy path. The policy field in managed_index is of object type so no problem there.rolled_over_index_name
in metadata will be handled during updateMetadata in Runner, the mapping will first be updated then the metadata document will be saved.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.