Skip to content

Commit e5d5984

Browse files
Add Missing NamedWritable Registration for ExecuteEnrichPolicyStatus (#62364)
This was missing and caused nodes to drop out of the cluster on serialization failures when ever one tried to get an enrich policy task by name. The test in here is a little dirty but I figured it would be nice to have an actual reproducer for the issue and I couldn't find any infrastructure to nicely time the tasks so I put this on top of existing test infra.
1 parent 4b7160d commit e5d5984

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.elasticsearch.xpack.core.datastreams.DataStreamFeatureSetUsage;
4040
import org.elasticsearch.xpack.core.deprecation.DeprecationInfoAction;
4141
import org.elasticsearch.xpack.core.enrich.EnrichFeatureSetUsage;
42+
import org.elasticsearch.xpack.core.enrich.action.ExecuteEnrichPolicyStatus;
4243
import org.elasticsearch.xpack.core.eql.EqlFeatureSetUsage;
4344
import org.elasticsearch.xpack.core.flattened.FlattenedFeatureSetUsage;
4445
import org.elasticsearch.xpack.core.frozen.FrozenIndicesFeatureSetUsage;
@@ -504,6 +505,7 @@ public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
504505
new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.ANALYTICS, AnalyticsFeatureSetUsage::new),
505506
// Enrich
506507
new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.ENRICH, EnrichFeatureSetUsage::new),
508+
new NamedWriteableRegistry.Entry(Task.Status.class, ExecuteEnrichPolicyStatus.NAME, ExecuteEnrichPolicyStatus::new),
507509
// Searchable snapshots
508510
new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.SEARCHABLE_SNAPSHOTS,
509511
SearchableSnapshotFeatureSetUsage::new),

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
package org.elasticsearch.xpack.enrich;
77

88
import org.apache.lucene.search.TotalHits;
9+
import org.elasticsearch.ResourceNotFoundException;
10+
import org.elasticsearch.action.ActionFuture;
11+
import org.elasticsearch.action.admin.cluster.node.tasks.get.GetTaskResponse;
912
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
1013
import org.elasticsearch.action.bulk.BulkItemResponse;
1114
import org.elasticsearch.action.bulk.BulkRequest;
@@ -23,6 +26,7 @@
2326
import org.elasticsearch.index.reindex.ReindexPlugin;
2427
import org.elasticsearch.ingest.common.IngestCommonPlugin;
2528
import org.elasticsearch.plugins.Plugin;
29+
import org.elasticsearch.tasks.TaskInfo;
2630
import org.elasticsearch.test.ESIntegTestCase;
2731
import org.elasticsearch.xpack.core.enrich.EnrichPolicy;
2832
import org.elasticsearch.xpack.core.enrich.action.DeleteEnrichPolicyAction;
@@ -207,7 +211,27 @@ private static void createAndExecutePolicy() {
207211
);
208212
PutEnrichPolicyAction.Request request = new PutEnrichPolicyAction.Request(POLICY_NAME, enrichPolicy);
209213
client().execute(PutEnrichPolicyAction.INSTANCE, request).actionGet();
210-
client().execute(ExecuteEnrichPolicyAction.INSTANCE, new ExecuteEnrichPolicyAction.Request(POLICY_NAME)).actionGet();
214+
final ActionFuture<ExecuteEnrichPolicyAction.Response> policyExecuteFuture = client().execute(
215+
ExecuteEnrichPolicyAction.INSTANCE,
216+
new ExecuteEnrichPolicyAction.Request(POLICY_NAME)
217+
);
218+
// Make sure we can deserialize enrich policy execution task status
219+
final List<TaskInfo> tasks = client().admin()
220+
.cluster()
221+
.prepareListTasks()
222+
.setActions(EnrichPolicyExecutor.TASK_ACTION)
223+
.get()
224+
.getTasks();
225+
// Best effort, sometimes the enrich policy task will not be visible yet or will have already finished
226+
if (tasks.isEmpty() == false) {
227+
try {
228+
final GetTaskResponse getTaskResponse = client().admin().cluster().prepareGetTask(tasks.get(0).getTaskId()).get();
229+
assertEquals(getTaskResponse.getTask().getTask().getAction(), EnrichPolicyExecutor.TASK_ACTION);
230+
} catch (ResourceNotFoundException e) {
231+
// ignored, could be the task has already finished
232+
}
233+
}
234+
policyExecuteFuture.actionGet();
211235
}
212236

213237
private static void createPipeline() {

0 commit comments

Comments
 (0)