|
@@ -11,6 +11,7 @@ import org.apache.logging.log4j.LogManager;
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
import org.apache.lucene.util.SetOnce;
|
|
|
import org.elasticsearch.ElasticsearchException;
|
|
|
+import org.elasticsearch.ElasticsearchSecurityException;
|
|
|
import org.elasticsearch.ResourceNotFoundException;
|
|
|
import org.elasticsearch.action.ActionListener;
|
|
|
import org.elasticsearch.action.index.IndexRequest;
|
|
@@ -21,6 +22,7 @@ import org.elasticsearch.common.logging.LoggerMessageFormat;
|
|
|
import org.elasticsearch.common.util.CollectionUtils;
|
|
|
import org.elasticsearch.core.TimeValue;
|
|
|
import org.elasticsearch.core.Tuple;
|
|
|
+import org.elasticsearch.health.HealthStatus;
|
|
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
|
import org.elasticsearch.index.query.QueryBuilder;
|
|
|
import org.elasticsearch.index.query.QueryBuilders;
|
|
@@ -271,22 +273,25 @@ public abstract class TransformIndexer extends AsyncTwoPhaseIndexer<TransformInd
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- SetOnce<Map<String, String>> deducedDestIndexMappings = new SetOnce<>();
|
|
|
-
|
|
|
- ActionListener<Void> finalListener = ActionListener.wrap(r -> {
|
|
|
- try {
|
|
|
- // if we haven't set the page size yet, if it is set we might have reduced it after running into an out of memory
|
|
|
- if (context.getPageSize() == 0) {
|
|
|
- configurePageSize(getConfig().getSettings().getMaxPageSearchSize());
|
|
|
- }
|
|
|
+ if (context.getAuthState() != null && HealthStatus.RED.equals(context.getAuthState().getStatus())) {
|
|
|
+ // AuthorizationState status is RED which means there was permission check error during PUT or _update.
|
|
|
+ listener.onFailure(
|
|
|
+ new ElasticsearchSecurityException(
|
|
|
+ TransformMessages.getMessage(TransformMessages.TRANSFORM_CANNOT_START_WITHOUT_PERMISSIONS, getConfig().getId())
|
|
|
+ )
|
|
|
+ );
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- runState = determineRunStateAtStart();
|
|
|
- listener.onResponse(true);
|
|
|
- } catch (Exception e) {
|
|
|
- listener.onFailure(e);
|
|
|
- return;
|
|
|
+ ActionListener<Void> finalListener = listener.delegateFailureAndWrap((l, r) -> {
|
|
|
+ // if we haven't set the page size yet, if it is set we might have reduced it after running into an out of memory
|
|
|
+ if (context.getPageSize() == 0) {
|
|
|
+ configurePageSize(getConfig().getSettings().getMaxPageSearchSize());
|
|
|
}
|
|
|
- }, listener::onFailure);
|
|
|
+
|
|
|
+ runState = determineRunStateAtStart();
|
|
|
+ l.onResponse(true);
|
|
|
+ });
|
|
|
|
|
|
// On each run, we need to get the total number of docs and reset the count of processed docs
|
|
|
// Since multiple checkpoints can be executed in the task while it is running on the same node, we need to gather
|
|
@@ -334,6 +339,7 @@ public abstract class TransformIndexer extends AsyncTwoPhaseIndexer<TransformInd
|
|
|
}
|
|
|
}, listener::onFailure);
|
|
|
|
|
|
+ var deducedDestIndexMappings = new SetOnce<Map<String, String>>();
|
|
|
var shouldMaybeCreateDestIndexForUnattended = context.getCheckpoint() == 0
|
|
|
&& TransformEffectiveSettings.isUnattended(transformConfig.getSettings());
|
|
|
|