Skip to content

Commit 6012c42

Browse files
authored
Merge branch 'main' into feature/add-inference-custom-model
2 parents 12e465e + b218f69 commit 6012c42

File tree

36 files changed

+153
-230
lines changed

36 files changed

+153
-230
lines changed

modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/GeoIpTaskParams.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public String getWriteableName() {
4444

4545
@Override
4646
public TransportVersion getMinimalSupportedVersion() {
47-
return TransportVersions.V_7_13_0;
47+
return TransportVersions.ZERO;
4848
}
4949

5050
@Override

modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/GeoIpTaskState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public String getWriteableName() {
132132

133133
@Override
134134
public TransportVersion getMinimalSupportedVersion() {
135-
return TransportVersions.V_7_13_0;
135+
return TransportVersions.ZERO;
136136
}
137137

138138
@Override

server/src/main/java/module-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@
429429
provides org.elasticsearch.features.FeatureSpecification
430430
with
431431
org.elasticsearch.action.bulk.BulkFeatures,
432-
org.elasticsearch.features.FeatureInfrastructureFeatures,
432+
org.elasticsearch.features.InfrastructureFeatures,
433433
org.elasticsearch.rest.action.admin.cluster.ClusterRerouteFeatures,
434434
org.elasticsearch.index.mapper.MapperFeatures,
435435
org.elasticsearch.index.IndexFeatures,

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ static TransportVersion def(int id) {
6060
public static final TransportVersion V_7_8_1 = def(7_08_01_99);
6161
public static final TransportVersion V_7_9_0 = def(7_09_00_99);
6262
public static final TransportVersion V_7_10_0 = def(7_10_00_99);
63-
public static final TransportVersion V_7_13_0 = def(7_13_00_99);
64-
public static final TransportVersion V_7_14_0 = def(7_14_00_99);
6563
public static final TransportVersion V_7_15_0 = def(7_15_00_99);
6664
public static final TransportVersion V_7_15_1 = def(7_15_01_99);
6765
public static final TransportVersion V_7_16_0 = def(7_16_00_99);

server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/NodesCapabilitiesRequest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111

1212
import org.elasticsearch.action.support.nodes.BaseNodesRequest;
1313
import org.elasticsearch.common.Strings;
14+
import org.elasticsearch.core.Nullable;
1415
import org.elasticsearch.core.RestApiVersion;
1516
import org.elasticsearch.rest.RestRequest;
1617

18+
import java.util.Optional;
1719
import java.util.Set;
1820

1921
public class NodesCapabilitiesRequest extends BaseNodesRequest {
@@ -22,7 +24,7 @@ public class NodesCapabilitiesRequest extends BaseNodesRequest {
2224
private String path = "/";
2325
private Set<String> parameters = Set.of();
2426
private Set<String> capabilities = Set.of();
25-
private RestApiVersion restApiVersion = RestApiVersion.current();
27+
private @Nullable RestApiVersion restApiVersion;
2628

2729
public NodesCapabilitiesRequest() {
2830
// send to all nodes
@@ -75,7 +77,7 @@ public NodesCapabilitiesRequest restApiVersion(RestApiVersion restApiVersion) {
7577
return this;
7678
}
7779

78-
public RestApiVersion restApiVersion() {
79-
return restApiVersion;
80+
public Optional<RestApiVersion> restApiVersion() {
81+
return Optional.ofNullable(restApiVersion);
8082
}
8183
}

server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/TransportNodesCapabilitiesAction.java

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
import org.elasticsearch.common.io.stream.StreamInput;
1919
import org.elasticsearch.common.io.stream.StreamOutput;
2020
import org.elasticsearch.core.RestApiVersion;
21-
import org.elasticsearch.core.UpdateForV9;
21+
import org.elasticsearch.features.FeatureService;
22+
import org.elasticsearch.features.InfrastructureFeatures;
2223
import org.elasticsearch.injection.guice.Inject;
2324
import org.elasticsearch.rest.RestController;
2425
import org.elasticsearch.rest.RestRequest;
@@ -41,14 +42,16 @@ public class TransportNodesCapabilitiesAction extends TransportNodesAction<
4142
public static final ActionType<NodesCapabilitiesResponse> TYPE = new ActionType<>("cluster:monitor/nodes/capabilities");
4243

4344
private final RestController restController;
45+
private final FeatureService featureService;
4446

4547
@Inject
4648
public TransportNodesCapabilitiesAction(
4749
ThreadPool threadPool,
4850
ClusterService clusterService,
4951
TransportService transportService,
5052
ActionFilters actionFilters,
51-
RestController restController
53+
RestController restController,
54+
FeatureService featureService
5255
) {
5356
super(
5457
TYPE.name(),
@@ -59,6 +62,7 @@ public TransportNodesCapabilitiesAction(
5962
threadPool.executor(ThreadPool.Names.MANAGEMENT)
6063
);
6164
this.restController = restController;
65+
this.featureService = featureService;
6266
}
6367

6468
@Override
@@ -72,13 +76,21 @@ protected NodesCapabilitiesResponse newResponse(
7276

7377
@Override
7478
protected NodeCapabilitiesRequest newNodeRequest(NodesCapabilitiesRequest request) {
75-
return new NodeCapabilitiesRequest(
76-
request.method(),
77-
request.path(),
78-
request.parameters(),
79-
request.capabilities(),
80-
request.restApiVersion()
81-
);
79+
RestApiVersion restVersion;
80+
if (request.restApiVersion().isPresent()) {
81+
// explicit version - just use it, and see what happens
82+
restVersion = request.restApiVersion().get();
83+
} else if (featureService.clusterHasFeature(clusterService.state(), InfrastructureFeatures.CURRENT_VERSION)) {
84+
restVersion = RestApiVersion.current(); // every node is at least this major version, so use that
85+
} else {
86+
// not all nodes are the current version. previous major version nodes do not understand
87+
// the new REST API version, so query using the previous version.
88+
// Capabilities can come and go, so it's ok for the response to change
89+
// when the nodes change
90+
restVersion = RestApiVersion.previous();
91+
}
92+
93+
return new NodeCapabilitiesRequest(request.method(), request.path(), request.parameters(), request.capabilities(), restVersion);
8294
}
8395

8496
@Override
@@ -129,10 +141,6 @@ public NodeCapabilitiesRequest(
129141
this.restApiVersion = restApiVersion;
130142
}
131143

132-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) // 8.x blows up in a mixed cluster when trying to read RestApiVersion.forMajor(9)
133-
// ./gradlew ":qa:mixed-cluster:v8.16.0#mixedClusterTest"
134-
// -Dtests.class="org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT"
135-
// -Dtests.method="test {p0=capabilities/10_basic/Capabilities API}"
136144
@Override
137145
public void writeTo(StreamOutput out) throws IOException {
138146
super.writeTo(out);
@@ -141,9 +149,7 @@ public void writeTo(StreamOutput out) throws IOException {
141149
out.writeString(path);
142150
out.writeCollection(parameters, StreamOutput::writeString);
143151
out.writeCollection(capabilities, StreamOutput::writeString);
144-
// Fixme: lies! all lies!
145-
out.writeVInt(8);
146-
// out.writeVInt(restApiVersion.major);
152+
out.writeVInt(restApiVersion.major);
147153
}
148154
}
149155
}

server/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksRequest.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
package org.elasticsearch.action.admin.cluster.node.tasks.list;
1111

12-
import org.elasticsearch.TransportVersions;
1312
import org.elasticsearch.action.ActionRequestValidationException;
1413
import org.elasticsearch.action.support.tasks.BaseTasksRequest;
1514
import org.elasticsearch.common.Strings;
@@ -44,19 +43,15 @@ public ListTasksRequest(StreamInput in) throws IOException {
4443
super(in);
4544
detailed = in.readBoolean();
4645
waitForCompletion = in.readBoolean();
47-
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_13_0)) {
48-
descriptions = in.readStringArray();
49-
}
46+
descriptions = in.readStringArray();
5047
}
5148

5249
@Override
5350
public void writeTo(StreamOutput out) throws IOException {
5451
super.writeTo(out);
5552
out.writeBoolean(detailed);
5653
out.writeBoolean(waitForCompletion);
57-
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_13_0)) {
58-
out.writeStringArray(descriptions);
59-
}
54+
out.writeStringArray(descriptions);
6055
}
6156

6257
@Override

server/src/main/java/org/elasticsearch/cluster/ClusterInfo.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public class ClusterInfo implements ChunkedToXContent, Writeable {
4949

5050
public static final ClusterInfo EMPTY = new ClusterInfo();
5151

52-
public static final TransportVersion DATA_SET_SIZE_SIZE_VERSION = TransportVersions.V_7_13_0;
5352
public static final TransportVersion DATA_PATH_NEW_KEY_VERSION = TransportVersions.V_8_6_0;
5453

5554
private final Map<String, DiskUsage> leastAvailableSpaceUsage;
@@ -94,9 +93,7 @@ public ClusterInfo(StreamInput in) throws IOException {
9493
this.leastAvailableSpaceUsage = in.readImmutableMap(DiskUsage::new);
9594
this.mostAvailableSpaceUsage = in.readImmutableMap(DiskUsage::new);
9695
this.shardSizes = in.readImmutableMap(StreamInput::readLong);
97-
this.shardDataSetSizes = in.getTransportVersion().onOrAfter(DATA_SET_SIZE_SIZE_VERSION)
98-
? in.readImmutableMap(ShardId::new, StreamInput::readLong)
99-
: Map.of();
96+
this.shardDataSetSizes = in.readImmutableMap(ShardId::new, StreamInput::readLong);
10097
this.dataPath = in.getTransportVersion().onOrAfter(DATA_PATH_NEW_KEY_VERSION)
10198
? in.readImmutableMap(NodeAndShard::new, StreamInput::readString)
10299
: in.readImmutableMap(nested -> NodeAndShard.from(new ShardRouting(nested)), StreamInput::readString);
@@ -108,9 +105,7 @@ public void writeTo(StreamOutput out) throws IOException {
108105
out.writeMap(this.leastAvailableSpaceUsage, StreamOutput::writeWriteable);
109106
out.writeMap(this.mostAvailableSpaceUsage, StreamOutput::writeWriteable);
110107
out.writeMap(this.shardSizes, (o, v) -> o.writeLong(v == null ? -1 : v));
111-
if (out.getTransportVersion().onOrAfter(DATA_SET_SIZE_SIZE_VERSION)) {
112-
out.writeMap(this.shardDataSetSizes, StreamOutput::writeWriteable, StreamOutput::writeLong);
113-
}
108+
out.writeMap(this.shardDataSetSizes, StreamOutput::writeWriteable, StreamOutput::writeLong);
114109
if (out.getTransportVersion().onOrAfter(DATA_PATH_NEW_KEY_VERSION)) {
115110
out.writeMap(this.dataPath, StreamOutput::writeWriteable, StreamOutput::writeString);
116111
} else {

server/src/main/java/org/elasticsearch/cluster/metadata/NodesShutdownMetadata.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
*/
4444
public class NodesShutdownMetadata implements Metadata.ClusterCustom {
4545
public static final String TYPE = "node_shutdown";
46-
public static final TransportVersion NODE_SHUTDOWN_VERSION = TransportVersions.V_7_13_0;
4746
public static final NodesShutdownMetadata EMPTY = new NodesShutdownMetadata(Map.of());
4847

4948
private static final ParseField NODES_FIELD = new ParseField("nodes");
@@ -173,7 +172,7 @@ public String getWriteableName() {
173172

174173
@Override
175174
public TransportVersion getMinimalSupportedVersion() {
176-
return NODE_SHUTDOWN_VERSION;
175+
return TransportVersions.ZERO;
177176
}
178177

179178
@Override
@@ -236,7 +235,7 @@ static Diff<SingleNodeShutdownMetadata> readNodesDiffFrom(StreamInput in) throws
236235

237236
@Override
238237
public TransportVersion getMinimalSupportedVersion() {
239-
return NODE_SHUTDOWN_VERSION;
238+
return TransportVersions.ZERO;
240239
}
241240

242241
}

server/src/main/java/org/elasticsearch/features/FeatureInfrastructureFeatures.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)