Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ public IndexLifecycleService(
.addSettingsUpdateConsumer(LifecycleSettings.LIFECYCLE_POLL_INTERVAL_SETTING, this::updatePollInterval);
}

public void maybeRunAsyncAction(ClusterState clusterState, IndexMetadata indexMetadata, StepKey nextStepKey) {
final var state = clusterState.projectState();
public void maybeRunAsyncAction(ProjectState state, IndexMetadata indexMetadata, StepKey nextStepKey) {
lifecycleRunner.maybeRunAsyncAction(state, indexMetadata, indexMetadata.getLifecyclePolicyName(), nextStepKey);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public void clusterStateProcessed(ClusterState oldState, ClusterState newState)
);
return;
}
indexLifecycleService.maybeRunAsyncAction(newState, newIndexMetadata, concreteTargetKey.get());
indexLifecycleService.maybeRunAsyncAction(newProjectState, newIndexMetadata, concreteTargetKey.get());
}
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
import org.elasticsearch.cluster.AckedClusterStateUpdateTask;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.ClusterStateUpdateTask;
import org.elasticsearch.cluster.ProjectState;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.metadata.LifecycleExecutionState;
import org.elasticsearch.cluster.project.ProjectResolver;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.core.SuppressForbidden;
Expand All @@ -36,15 +38,17 @@ public class TransportRetryAction extends TransportMasterNodeAction<RetryActionR

private static final Logger logger = LogManager.getLogger(TransportRetryAction.class);

IndexLifecycleService indexLifecycleService;
private final IndexLifecycleService indexLifecycleService;
private final ProjectResolver projectResolver;

@Inject
public TransportRetryAction(
TransportService transportService,
ClusterService clusterService,
ThreadPool threadPool,
ActionFilters actionFilters,
IndexLifecycleService indexLifecycleService
IndexLifecycleService indexLifecycleService,
ProjectResolver projectResolver
) {
super(
ILMActions.RETRY.name(),
Expand All @@ -57,6 +61,7 @@ public TransportRetryAction(
EsExecutors.DIRECT_EXECUTOR_SERVICE
);
this.indexLifecycleService = indexLifecycleService;
this.projectResolver = projectResolver;
}

@Override
Expand All @@ -66,29 +71,30 @@ protected void masterOperation(
ClusterState state,
ActionListener<AcknowledgedResponse> listener
) {
final var projectState = projectResolver.getProjectState(state);
if (request.requireError() == false) {
maybeRunAsyncAction(state, request.indices());
maybeRunAsyncAction(projectState, request.indices());
listener.onResponse(AcknowledgedResponse.TRUE);
return;
}
submitUnbatchedTask("ilm-re-run", new AckedClusterStateUpdateTask(request, listener) {
@Override
public ClusterState execute(ClusterState currentState) {
final var project = state.metadata().getProject();
final var project = state.metadata().getProject(projectState.projectId());
final var updatedProject = indexLifecycleService.moveIndicesToPreviouslyFailedStep(project, request.indices());
return ClusterState.builder(currentState).putProjectMetadata(updatedProject).build();
}

@Override
public void clusterStateProcessed(ClusterState oldState, ClusterState newState) {
maybeRunAsyncAction(newState, request.indices());
maybeRunAsyncAction(newState.projectState(projectState.projectId()), request.indices());
}
});
}

private void maybeRunAsyncAction(ClusterState state, String[] indices) {
private void maybeRunAsyncAction(ProjectState state, String[] indices) {
for (String index : indices) {
IndexMetadata idxMeta = state.metadata().getProject().index(index);
IndexMetadata idxMeta = state.metadata().index(index);
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, skipping async action check");
Expand Down