Skip to content

Commit fa3d548

Browse files
authored
Fix transport serialization of EnrichStatsAction.Request (#121735)
In #121256, we changed the superclass of the request to `LocalClusterStateRequest` to make the action run on the local node instead of the master node. Most of the actions that have been updated thusfar to run on the local node used to extend `MasterNodeReadRequest` and thus serialized a `local` field. This request class, however, extended `MasterNodeRequest`, meaning that it didn't serialize that field.
1 parent ba343c1 commit fa3d548

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,6 @@ tests:
382382
- class: org.elasticsearch.xpack.esql.action.CrossClustersCancellationIT
383383
method: testCancelSkipUnavailable
384384
issue: https://github.com/elastic/elasticsearch/issues/121631
385-
- class: org.elasticsearch.upgrades.UpgradeClusterClientYamlTestSuiteIT
386-
method: test {p0=mixed_cluster/110_enrich/Enrich stats query smoke test for mixed cluster}
387-
issue: https://github.com/elastic/elasticsearch/issues/121642
388385
- class: org.elasticsearch.search.CrossClusterSearchUnavailableClusterIT
389386
method: testSearchSkipUnavailable
390387
issue: https://github.com/elastic/elasticsearch/issues/121497

server/src/main/java/org/elasticsearch/action/support/local/LocalClusterStateRequest.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,23 @@ protected LocalClusterStateRequest(TimeValue masterTimeout) {
4141
*/
4242
@UpdateForV10(owner = UpdateForV10.Owner.DISTRIBUTED_COORDINATION)
4343
protected LocalClusterStateRequest(StreamInput in) throws IOException {
44+
this(in, true);
45+
}
46+
47+
/**
48+
* This constructor exists solely for BwC purposes. It should exclusively be used by requests that used to extend
49+
* {@link org.elasticsearch.action.support.master.MasterNodeRequest} and still need to be able to serialize incoming request.
50+
*/
51+
@UpdateForV10(owner = UpdateForV10.Owner.DISTRIBUTED_COORDINATION)
52+
protected LocalClusterStateRequest(StreamInput in, boolean readLocal) throws IOException {
4453
super(in);
4554
masterTimeout = in.readTimeValue();
4655
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_15_0)) {
4756
in.readVLong();
4857
}
49-
in.readBoolean();
58+
if (readLocal) {
59+
in.readBoolean();
60+
}
5061
}
5162

5263
@Override

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ public Request(TimeValue masterNodeTimeout) {
4646
}
4747

4848
/**
49-
* NB prior to 9.0 this was a TransportMasterNodeReadAction so for BwC we must remain able to read these requests until
49+
* NB prior to 9.0 this was a TransportMasterNodeAction so for BwC we must remain able to read these requests until
5050
* we no longer need to support calling this action remotely.
5151
*/
5252
@UpdateForV10(owner = UpdateForV10.Owner.DATA_MANAGEMENT)
5353
public Request(StreamInput in) throws IOException {
54-
super(in);
54+
// This request extended MasterNodeRequest instead of MasterNodeReadRequest, meaning that it didn't serialize the `local` field.
55+
super(in, false);
5556
}
5657

5758
@Override
@@ -90,7 +91,7 @@ public List<CacheStats> getCacheStats() {
9091
}
9192

9293
/**
93-
* NB prior to 9.0 this was a TransportMasterNodeReadAction so for BwC we must remain able to write these responses until
94+
* NB prior to 9.0 this was a TransportMasterNodeAction so for BwC we must remain able to write these responses until
9495
* we no longer need to support calling this action remotely.
9596
*/
9697
@UpdateForV10(owner = UpdateForV10.Owner.DATA_MANAGEMENT)
@@ -181,7 +182,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
181182
public record ExecutingPolicy(String name, TaskInfo taskInfo) implements Writeable, ToXContentFragment {
182183

183184
/**
184-
* NB prior to 9.0 this was a TransportMasterNodeReadAction so for BwC we must remain able to write these responses until
185+
* NB prior to 9.0 this was a TransportMasterNodeAction so for BwC we must remain able to write these responses until
185186
* we no longer need to support calling this action remotely.
186187
*/
187188
@UpdateForV10(owner = UpdateForV10.Owner.DATA_MANAGEMENT)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class TransportEnrichStatsAction extends TransportLocalClusterStateAction
3737
private final Client client;
3838

3939
/**
40-
* NB prior to 9.0 this was a TransportMasterNodeReadAction so for BwC it must be registered with the TransportService until
40+
* NB prior to 9.0 this was a TransportMasterNodeAction so for BwC it must be registered with the TransportService until
4141
* we no longer need to support calling this action remotely.
4242
*/
4343
@UpdateForV10(owner = UpdateForV10.Owner.DATA_MANAGEMENT)

0 commit comments

Comments
 (0)