Fail with a better error when if there are no ingest nodes (#48272)
when executing enrich execute policy api.
This commit is contained in:
parent
0ec0ab64c9
commit
bbe50eca72
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue