-
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
[ILM] fix retry so it picks up latest policy and executes async action #35406
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
12e71a4
[ILM] fix retry so it picks up latest policy and executes async action
talevy 7432320
Merge remote-tracking branch 'upstream/master' into ilm-fix-35397
talevy 13f196b
add flag for fetching latest policy definition
talevy 9e5ba12
Merge remote-tracking branch 'upstream/master' into ilm-fix-35397
talevy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,14 @@ | |
import org.elasticsearch.cluster.ClusterState; | ||
import org.elasticsearch.cluster.block.ClusterBlockException; | ||
import org.elasticsearch.cluster.block.ClusterBlockLevel; | ||
import org.elasticsearch.cluster.metadata.IndexMetaData; | ||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; | ||
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.common.inject.Inject; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.transport.TransportService; | ||
import org.elasticsearch.xpack.core.indexlifecycle.LifecycleExecutionState; | ||
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey; | ||
import org.elasticsearch.xpack.core.indexlifecycle.action.RetryAction; | ||
import org.elasticsearch.xpack.core.indexlifecycle.action.RetryAction.Request; | ||
import org.elasticsearch.xpack.core.indexlifecycle.action.RetryAction.Response; | ||
|
@@ -55,6 +58,23 @@ public ClusterState execute(ClusterState currentState) { | |
return indexLifecycleService.moveClusterStateToFailedStep(currentState, request.indices()); | ||
} | ||
|
||
@Override | ||
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { | ||
for (String index : request.indices()) { | ||
IndexMetaData idxMeta = newState.metaData().index(index); | ||
LifecycleExecutionState lifecycleState = LifecycleExecutionState.fromIndexMetadata(idxMeta); | ||
StepKey retryStep = new StepKey(lifecycleState.getPhase(), lifecycleState.getAction(), lifecycleState.getStep()); | ||
if (idxMeta == null) { | ||
// The index has somehow been deleted - there shouldn't be any opportunity for this to happen, but just in case. | ||
logger.debug("index [" + index + "] has been deleted after moving to step [" + | ||
lifecycleState.getStep() + "], skipping async action check"); | ||
return; | ||
} | ||
logger.error("TRYING TRYING"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this log statement got left in accidentally. |
||
indexLifecycleService.maybeRunAsyncAction(newState, idxMeta, retryStep); | ||
} | ||
} | ||
|
||
@Override | ||
protected Response newResponse(boolean acknowledged) { | ||
return new Response(acknowledged); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm not sure this is the right pace to do this. We only want this functionality to occur in the retry API so I think it should only be that code path that gets this phase definition refresh. Maybe we can have a
boolean forcePhaseDefinitionRefresh
parameter and use that to override the behaviour for the retry method. I can also see a case in the future where we might want to have an option on the moveToStep API to force the phase definition to be updated too.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.
yup. this was my issue with this same thing. I thought about creating the boolean flag, but I find flags like this that significantly change behavior to be confusing. I didn't think about move-to-step potentially wanting the same thing, though. Given this potential usage outside of just errors, I think the flag would be appropriate as to not duplicate much of the code. thanks. I will try it and see how it reads