Fail with a better error when if there are no ingest nodes (#48272)

when executing enrich execute policy api.
This commit is contained in:
Martijn van Groningen 2019-10-22 07:41:26 +02:00
parent 0ec0ab64c9
commit bbe50eca72
No known key found for this signature in database
GPG Key ID: AB236F4FCF2AF12A
2 changed files with 19 additions and 0 deletions

View File

@ -62,6 +62,12 @@ public class TransportExecuteEnrichPolicyAction
@Override
protected void masterOperation(ExecuteEnrichPolicyAction.Request request, ClusterState state,
ActionListener<ExecuteEnrichPolicyAction.Response> listener) {
if (state.getNodes().getIngestNodes().isEmpty()) {
// if we don't fail here then reindex will fail with a more complicated error.
// (EnrichPolicyRunner uses a pipeline with reindex)
throw new IllegalStateException("no ingest nodes in this cluster");
}
if (request.isWaitForCompletion()) {
executor.runPolicy(request, new ActionListener<ExecuteEnrichPolicyStatus>() {
@Override

View File

@ -134,6 +134,19 @@ public class EnrichMultiNodeIT extends ESIntegTestCase {
enrich(keys, ingestOnlyNode);
}
public void testEnrichNoIngestNodes() {
Settings settings = Settings.builder()
.put(Node.NODE_MASTER_SETTING.getKey(), true)
.put(Node.NODE_DATA_SETTING.getKey(), true)
.put(Node.NODE_INGEST_SETTING.getKey(), false)
.build();
internalCluster().startNode(settings);
createSourceIndex(64);
Exception e = expectThrows(IllegalStateException.class, EnrichMultiNodeIT::createAndExecutePolicy);
assertThat(e.getMessage(), equalTo("no ingest nodes in this cluster"));
}
private static void enrich(List<String> keys, String coordinatingNode) {
int numDocs = 256;
BulkRequest bulkRequest = new BulkRequest("my-index");