Skip to content

Commit d172631

Browse files
committed
Fail with a better error when if there are no ingest nodes (#48272)
when executing enrich execute policy api.
1 parent 3f93300 commit d172631

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(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<ExecuteEnrichPolicyStatus>() {
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
@@ -134,6 +134,19 @@ public void testEnrichDedicatedIngestNode() {
134134
enrich(keys, ingestOnlyNode);
135135
}
136136

137+
public void testEnrichNoIngestNodes() {
138+
Settings settings = Settings.builder()
139+
.put(Node.NODE_MASTER_SETTING.getKey(), true)
140+
.put(Node.NODE_DATA_SETTING.getKey(), true)
141+
.put(Node.NODE_INGEST_SETTING.getKey(), false)
142+
.build();
143+
internalCluster().startNode(settings);
144+
145+
createSourceIndex(64);
146+
Exception e = expectThrows(IllegalStateException.class, EnrichMultiNodeIT::createAndExecutePolicy);
147+
assertThat(e.getMessage(), equalTo("no ingest nodes in this cluster"));
148+
}
149+
137150
private static void enrich(List<String> keys, String coordinatingNode) {
138151
int numDocs = 256;
139152
BulkRequest bulkRequest = new BulkRequest("my-index");

0 commit comments

Comments
 (0)