Skip to content

Commit

Permalink
Fail with a better error when if there are no ingest nodes (#48272)
Browse files Browse the repository at this point in the history
when executing enrich execute policy api.
  • Loading branch information
martijnvg committed Oct 22, 2019
1 parent 3f93300 commit d172631
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ protected ExecuteEnrichPolicyAction.Response read(StreamInput in) throws IOExcep
@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ public void testEnrichDedicatedIngestNode() {
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");
Expand Down

0 comments on commit d172631

Please sign in to comment.