Skip to content

Commit ad54405

Browse files
authored
Fail with a better error when if there are no ingest nodes (#48272)
when executing enrich execute policy api.
1 parent 48184df commit ad54405

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/TransportExecuteEnrichPolicyAction.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ protected ExecuteEnrichPolicyAction.Response read(StreamInput in) throws IOExcep
6262
@Override
6363
protected void masterOperation(Task task, ExecuteEnrichPolicyAction.Request request, ClusterState state,
6464
ActionListener<ExecuteEnrichPolicyAction.Response> listener) {
65+
if (state.getNodes().getIngestNodes().isEmpty()) {
66+
// if we don't fail here then reindex will fail with a more complicated error.
67+
// (EnrichPolicyRunner uses a pipeline with reindex)
68+
throw new IllegalStateException("no ingest nodes in this cluster");
69+
}
70+
6571
if (request.isWaitForCompletion()) {
6672
executor.runPolicy(request, new ActionListener<>() {
6773
@Override

x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichMultiNodeIT.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,19 @@ public void testEnrichDedicatedIngestNode() {
119119
enrich(keys, ingestOnlyNode);
120120
}
121121

122+
public void testEnrichNoIngestNodes() {
123+
Settings settings = Settings.builder()
124+
.put(Node.NODE_MASTER_SETTING.getKey(), true)
125+
.put(Node.NODE_DATA_SETTING.getKey(), true)
126+
.put(Node.NODE_INGEST_SETTING.getKey(), false)
127+
.build();
128+
internalCluster().startNode(settings);
129+
130+
createSourceIndex(64);
131+
Exception e = expectThrows(IllegalStateException.class, EnrichMultiNodeIT::createAndExecutePolicy);
132+
assertThat(e.getMessage(), equalTo("no ingest nodes in this cluster"));
133+
}
134+
122135
private static void enrich(List<String> keys, String coordinatingNode) {
123136
int numDocs = 256;
124137
BulkRequest bulkRequest = new BulkRequest("my-index");

0 commit comments

Comments
 (0)