Skip to content
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

[7.6][Transform] Fix stats can return old state information if security is enabled #51739

Merged
merged 1 commit into from
Feb 12, 2020
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 @@ -43,7 +43,6 @@
import org.elasticsearch.xpack.core.transform.transforms.TransformState;
import org.elasticsearch.xpack.core.transform.transforms.TransformTaskParams;
import org.elasticsearch.xpack.core.transform.transforms.TransformTaskState;
import org.elasticsearch.xpack.core.transform.transforms.persistence.TransformInternalIndexConstants;
import org.elasticsearch.xpack.transform.TransformServices;
import org.elasticsearch.xpack.transform.persistence.TransformConfigManager;
import org.elasticsearch.xpack.transform.transforms.TransformTask;
Expand All @@ -67,7 +66,6 @@ public class TransportStopTransformAction extends TransportTasksAction<Transform
private final ThreadPool threadPool;
private final TransformConfigManager transformConfigManager;
private final PersistentTasksService persistentTasksService;
private final Client client;

@Inject
public TransportStopTransformAction(
Expand Down Expand Up @@ -105,7 +103,6 @@ protected TransportStopTransformAction(
this.threadPool = threadPool;
this.transformConfigManager = transformServices.getConfigManager();
this.persistentTasksService = persistentTasksService;
this.client = client;
}

static void validateTaskState(ClusterState state, List<String> transformIds, boolean isForce) {
Expand Down Expand Up @@ -274,13 +271,10 @@ protected StopTransformAction.Response newResponse(
private ActionListener<Response> waitForStopListener(Request request, ActionListener<Response> listener) {

ActionListener<Response> onStopListener = ActionListener.wrap(
waitResponse -> client.admin()
.indices()
.prepareRefresh(TransformInternalIndexConstants.LATEST_INDEX_NAME)
.execute(ActionListener.wrap(r -> listener.onResponse(waitResponse), e -> {
logger.info("Failed to refresh internal index after delete", e);
listener.onResponse(waitResponse);
})),
waitResponse -> transformConfigManager.refresh(ActionListener.wrap(r -> listener.onResponse(waitResponse), e -> {
logger.warn("Could not refresh state, state information might be outdated", e);
listener.onResponse(waitResponse);
})),
listener::onFailure
);
return ActionListener.wrap(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.DocWriteRequest;
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
import org.elasticsearch.action.bulk.BulkItemResponse;
import org.elasticsearch.action.index.IndexAction;
import org.elasticsearch.action.index.IndexRequest;
Expand Down Expand Up @@ -634,6 +636,17 @@ public void getTransformStoredDocs(Collection<String> transformIds, ActionListen
);
}

@Override
public void refresh(ActionListener<Boolean> listener) {
executeAsyncWithOrigin(
client.threadPool().getThreadContext(),
TRANSFORM_ORIGIN,
new RefreshRequest(TransformInternalIndexConstants.LATEST_INDEX_NAME),
ActionListener.<RefreshResponse>wrap(r -> listener.onResponse(true), listener::onFailure),
client.admin().indices()::refresh
);
}

private void parseTransformLenientlyFromSource(
BytesReference source,
String transformId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,5 @@ void putOrUpdateTransformStoredDoc(

void getTransformStoredDocs(Collection<String> transformIds, ActionListener<List<TransformStoredDoc>> listener);

void refresh(ActionListener<Boolean> listener);
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,9 @@ public void getTransformStoredDocs(Collection<String> transformIds, ActionListen
listener.onResponse(docs);
}

@Override
public void refresh(ActionListener<Boolean> listener) {
listener.onResponse(true);
}

}