do index refresh of the internal transform index with the system user instead of using the calling user which does not have sufficient rights if security is enabled fixes #51728
This commit is contained in:
parent
21224caeaf
commit
ed170cc548
|
@ -43,7 +43,6 @@ import org.elasticsearch.xpack.core.transform.action.StopTransformAction.Respons
|
||||||
import org.elasticsearch.xpack.core.transform.transforms.TransformState;
|
import org.elasticsearch.xpack.core.transform.transforms.TransformState;
|
||||||
import org.elasticsearch.xpack.core.transform.transforms.TransformTaskParams;
|
import org.elasticsearch.xpack.core.transform.transforms.TransformTaskParams;
|
||||||
import org.elasticsearch.xpack.core.transform.transforms.TransformTaskState;
|
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.TransformServices;
|
||||||
import org.elasticsearch.xpack.transform.persistence.TransformConfigManager;
|
import org.elasticsearch.xpack.transform.persistence.TransformConfigManager;
|
||||||
import org.elasticsearch.xpack.transform.transforms.TransformTask;
|
import org.elasticsearch.xpack.transform.transforms.TransformTask;
|
||||||
|
@ -67,7 +66,6 @@ public class TransportStopTransformAction extends TransportTasksAction<Transform
|
||||||
private final ThreadPool threadPool;
|
private final ThreadPool threadPool;
|
||||||
private final TransformConfigManager transformConfigManager;
|
private final TransformConfigManager transformConfigManager;
|
||||||
private final PersistentTasksService persistentTasksService;
|
private final PersistentTasksService persistentTasksService;
|
||||||
private final Client client;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportStopTransformAction(
|
public TransportStopTransformAction(
|
||||||
|
@ -105,7 +103,6 @@ public class TransportStopTransformAction extends TransportTasksAction<Transform
|
||||||
this.threadPool = threadPool;
|
this.threadPool = threadPool;
|
||||||
this.transformConfigManager = transformServices.getConfigManager();
|
this.transformConfigManager = transformServices.getConfigManager();
|
||||||
this.persistentTasksService = persistentTasksService;
|
this.persistentTasksService = persistentTasksService;
|
||||||
this.client = client;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void validateTaskState(ClusterState state, List<String> transformIds, boolean isForce) {
|
static void validateTaskState(ClusterState state, List<String> transformIds, boolean isForce) {
|
||||||
|
@ -274,13 +271,10 @@ public class TransportStopTransformAction extends TransportTasksAction<Transform
|
||||||
private ActionListener<Response> waitForStopListener(Request request, ActionListener<Response> listener) {
|
private ActionListener<Response> waitForStopListener(Request request, ActionListener<Response> listener) {
|
||||||
|
|
||||||
ActionListener<Response> onStopListener = ActionListener.wrap(
|
ActionListener<Response> onStopListener = ActionListener.wrap(
|
||||||
waitResponse -> client.admin()
|
waitResponse -> transformConfigManager.refresh(ActionListener.wrap(r -> listener.onResponse(waitResponse), e -> {
|
||||||
.indices()
|
logger.warn("Could not refresh state, state information might be outdated", e);
|
||||||
.prepareRefresh(TransformInternalIndexConstants.LATEST_INDEX_NAME)
|
listener.onResponse(waitResponse);
|
||||||
.execute(ActionListener.wrap(r -> listener.onResponse(waitResponse), e -> {
|
})),
|
||||||
logger.info("Failed to refresh internal index after delete", e);
|
|
||||||
listener.onResponse(waitResponse);
|
|
||||||
})),
|
|
||||||
listener::onFailure
|
listener::onFailure
|
||||||
);
|
);
|
||||||
return ActionListener.wrap(
|
return ActionListener.wrap(
|
||||||
|
|
|
@ -14,6 +14,8 @@ import org.elasticsearch.ResourceAlreadyExistsException;
|
||||||
import org.elasticsearch.ResourceNotFoundException;
|
import org.elasticsearch.ResourceNotFoundException;
|
||||||
import org.elasticsearch.action.ActionListener;
|
import org.elasticsearch.action.ActionListener;
|
||||||
import org.elasticsearch.action.DocWriteRequest;
|
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.bulk.BulkItemResponse;
|
||||||
import org.elasticsearch.action.index.IndexAction;
|
import org.elasticsearch.action.index.IndexAction;
|
||||||
import org.elasticsearch.action.index.IndexRequest;
|
import org.elasticsearch.action.index.IndexRequest;
|
||||||
|
@ -634,6 +636,17 @@ public class IndexBasedTransformConfigManager implements TransformConfigManager
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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(
|
private void parseTransformLenientlyFromSource(
|
||||||
BytesReference source,
|
BytesReference source,
|
||||||
String transformId,
|
String transformId,
|
||||||
|
|
|
@ -149,4 +149,5 @@ public interface TransformConfigManager {
|
||||||
|
|
||||||
void getTransformStoredDocs(Collection<String> transformIds, ActionListener<List<TransformStoredDoc>> listener);
|
void getTransformStoredDocs(Collection<String> transformIds, ActionListener<List<TransformStoredDoc>> listener);
|
||||||
|
|
||||||
|
void refresh(ActionListener<Boolean> listener);
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,4 +214,9 @@ public class InMemoryTransformConfigManager implements TransformConfigManager {
|
||||||
listener.onResponse(docs);
|
listener.onResponse(docs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refresh(ActionListener<Boolean> listener) {
|
||||||
|
listener.onResponse(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue