Skip to content

Commit 0400428

Browse files
committed
Remove node_version field from DesiredNode API output
It was deprecated in elastic#104209 (8.13) and shouldn't be set in 9.0
1 parent 4eab631 commit 0400428

5 files changed

Lines changed: 10 additions & 107 deletions

File tree

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DesiredNodesUpgradeIT.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import com.carrotsearch.randomizedtesting.annotations.Name;
1313

14-
import org.elasticsearch.Build;
1514
import org.elasticsearch.action.admin.cluster.desirednodes.UpdateDesiredNodesRequest;
1615
import org.elasticsearch.client.Request;
1716
import org.elasticsearch.client.ResponseException;
@@ -82,8 +81,7 @@ private void assertDesiredNodesUpdatedWithRoundedUpFloatsAreIdempotent() throws
8281
Settings.builder().put(NODE_NAME_SETTING.getKey(), nodeName).build(),
8382
1238.49922909,
8483
ByteSizeValue.ofGb(32),
85-
ByteSizeValue.ofGb(128),
86-
clusterHasFeature(DesiredNode.DESIRED_NODE_VERSION_DEPRECATED) ? null : Build.current().version()
84+
ByteSizeValue.ofGb(128)
8785
)
8886
)
8987
.toList();
@@ -153,8 +151,7 @@ private void addClusterNodesToDesiredNodesWithProcessorsOrProcessorRanges(int ve
153151
Settings.builder().put(NODE_NAME_SETTING.getKey(), nodeName).build(),
154152
processorsPrecision == ProcessorsPrecision.DOUBLE ? randomDoubleProcessorCount() : 0.5f,
155153
ByteSizeValue.ofGb(randomIntBetween(10, 24)),
156-
ByteSizeValue.ofGb(randomIntBetween(128, 256)),
157-
clusterHasFeature(DesiredNode.DESIRED_NODE_VERSION_DEPRECATED) ? null : Build.current().version()
154+
ByteSizeValue.ofGb(randomIntBetween(128, 256))
158155
)
159156
)
160157
.toList();
@@ -167,8 +164,7 @@ private void addClusterNodesToDesiredNodesWithProcessorsOrProcessorRanges(int ve
167164
Settings.builder().put(NODE_NAME_SETTING.getKey(), nodeName).build(),
168165
new DesiredNode.ProcessorsRange(minProcessors, minProcessors + randomIntBetween(10, 20)),
169166
ByteSizeValue.ofGb(randomIntBetween(10, 24)),
170-
ByteSizeValue.ofGb(randomIntBetween(128, 256)),
171-
clusterHasFeature(DesiredNode.DESIRED_NODE_VERSION_DEPRECATED) ? null : Build.current().version()
167+
ByteSizeValue.ofGb(randomIntBetween(128, 256))
172168
);
173169
}).toList();
174170
}
@@ -182,8 +178,7 @@ private void addClusterNodesToDesiredNodesWithIntegerProcessors(int version) thr
182178
Settings.builder().put(NODE_NAME_SETTING.getKey(), nodeName).build(),
183179
randomIntBetween(1, 24),
184180
ByteSizeValue.ofGb(randomIntBetween(10, 24)),
185-
ByteSizeValue.ofGb(randomIntBetween(128, 256)),
186-
clusterHasFeature(DesiredNode.DESIRED_NODE_VERSION_DEPRECATED) ? null : Build.current().version()
181+
ByteSizeValue.ofGb(randomIntBetween(128, 256))
187182
)
188183
)
189184
.toList();

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

Lines changed: 3 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@
1111

1212
import org.elasticsearch.TransportVersion;
1313
import org.elasticsearch.TransportVersions;
14-
import org.elasticsearch.Version;
1514
import org.elasticsearch.cluster.node.DiscoveryNode;
1615
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
17-
import org.elasticsearch.common.Strings;
1816
import org.elasticsearch.common.io.stream.StreamInput;
1917
import org.elasticsearch.common.io.stream.StreamOutput;
2018
import org.elasticsearch.common.io.stream.Writeable;
2119
import org.elasticsearch.common.settings.Settings;
2220
import org.elasticsearch.common.unit.ByteSizeValue;
2321
import org.elasticsearch.common.unit.Processors;
2422
import org.elasticsearch.core.Nullable;
25-
import org.elasticsearch.core.UpdateForV9;
2623
import org.elasticsearch.features.NodeFeature;
2724
import org.elasticsearch.xcontent.ConstructingObjectParser;
2825
import org.elasticsearch.xcontent.ObjectParser;
@@ -38,7 +35,6 @@
3835
import java.util.Set;
3936
import java.util.TreeSet;
4037
import java.util.function.Predicate;
41-
import java.util.regex.Pattern;
4238

4339
import static java.lang.String.format;
4440
import static org.elasticsearch.node.Node.NODE_EXTERNAL_ID_SETTING;
@@ -49,7 +45,6 @@ public final class DesiredNode implements Writeable, ToXContentObject, Comparabl
4945

5046
public static final NodeFeature RANGE_FLOAT_PROCESSORS_SUPPORTED = new NodeFeature("desired_node.range_float_processors");
5147
public static final NodeFeature DOUBLE_PROCESSORS_SUPPORTED = new NodeFeature("desired_node.double_processors");
52-
public static final NodeFeature DESIRED_NODE_VERSION_DEPRECATED = new NodeFeature("desired_node.version_deprecated");
5348

5449
public static final TransportVersion RANGE_FLOAT_PROCESSORS_SUPPORT_TRANSPORT_VERSION = TransportVersions.V_8_3_0;
5550

@@ -58,8 +53,6 @@ public final class DesiredNode implements Writeable, ToXContentObject, Comparabl
5853
private static final ParseField PROCESSORS_RANGE_FIELD = new ParseField("processors_range");
5954
private static final ParseField MEMORY_FIELD = new ParseField("memory");
6055
private static final ParseField STORAGE_FIELD = new ParseField("storage");
61-
@UpdateForV9(owner = UpdateForV9.Owner.DISTRIBUTED_COORDINATION) // Remove deprecated field
62-
private static final ParseField VERSION_FIELD = new ParseField("node_version");
6356

6457
public static final ConstructingObjectParser<DesiredNode, Void> PARSER = new ConstructingObjectParser<>(
6558
"desired_node",
@@ -69,8 +62,7 @@ public final class DesiredNode implements Writeable, ToXContentObject, Comparabl
6962
(Processors) args[1],
7063
(ProcessorsRange) args[2],
7164
(ByteSizeValue) args[3],
72-
(ByteSizeValue) args[4],
73-
(String) args[5]
65+
(ByteSizeValue) args[4]
7466
)
7567
);
7668

@@ -104,12 +96,6 @@ static <T> void configureParser(ConstructingObjectParser<T, Void> parser) {
10496
STORAGE_FIELD,
10597
ObjectParser.ValueType.STRING
10698
);
107-
parser.declareField(
108-
ConstructingObjectParser.optionalConstructorArg(),
109-
(p, c) -> p.text(),
110-
VERSION_FIELD,
111-
ObjectParser.ValueType.STRING
112-
);
11399
}
114100

115101
private final Settings settings;
@@ -118,21 +104,9 @@ static <T> void configureParser(ConstructingObjectParser<T, Void> parser) {
118104
private final ByteSizeValue memory;
119105
private final ByteSizeValue storage;
120106

121-
@UpdateForV9(owner = UpdateForV9.Owner.DISTRIBUTED_COORDINATION) // Remove deprecated version field
122-
private final String version;
123107
private final String externalId;
124108
private final Set<DiscoveryNodeRole> roles;
125109

126-
@Deprecated
127-
public DesiredNode(Settings settings, ProcessorsRange processorsRange, ByteSizeValue memory, ByteSizeValue storage, String version) {
128-
this(settings, null, processorsRange, memory, storage, version);
129-
}
130-
131-
@Deprecated
132-
public DesiredNode(Settings settings, double processors, ByteSizeValue memory, ByteSizeValue storage, String version) {
133-
this(settings, Processors.of(processors), null, memory, storage, version);
134-
}
135-
136110
public DesiredNode(Settings settings, ProcessorsRange processorsRange, ByteSizeValue memory, ByteSizeValue storage) {
137111
this(settings, null, processorsRange, memory, storage);
138112
}
@@ -142,17 +116,6 @@ public DesiredNode(Settings settings, double processors, ByteSizeValue memory, B
142116
}
143117

144118
DesiredNode(Settings settings, Processors processors, ProcessorsRange processorsRange, ByteSizeValue memory, ByteSizeValue storage) {
145-
this(settings, processors, processorsRange, memory, storage, null);
146-
}
147-
148-
DesiredNode(
149-
Settings settings,
150-
Processors processors,
151-
ProcessorsRange processorsRange,
152-
ByteSizeValue memory,
153-
ByteSizeValue storage,
154-
@Deprecated String version
155-
) {
156119
assert settings != null;
157120
assert memory != null;
158121
assert storage != null;
@@ -186,7 +149,6 @@ public DesiredNode(Settings settings, double processors, ByteSizeValue memory, B
186149
this.processorsRange = processorsRange;
187150
this.memory = memory;
188151
this.storage = storage;
189-
this.version = version;
190152
this.externalId = NODE_EXTERNAL_ID_SETTING.get(settings);
191153
this.roles = Collections.unmodifiableSortedSet(new TreeSet<>(DiscoveryNode.getRolesFromSettings(settings)));
192154
}
@@ -205,24 +167,7 @@ public static DesiredNode readFrom(StreamInput in) throws IOException {
205167
final var memory = ByteSizeValue.readFrom(in);
206168
final var storage = ByteSizeValue.readFrom(in);
207169
final String version;
208-
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_13_0)) {
209-
version = in.readOptionalString();
210-
} else {
211-
version = Version.readVersion(in).toString();
212-
}
213-
return new DesiredNode(settings, processors, processorsRange, memory, storage, version);
214-
}
215-
216-
private static final Pattern SEMANTIC_VERSION_PATTERN = Pattern.compile("^(\\d+\\.\\d+\\.\\d+)\\D?.*");
217-
218-
private static Version parseLegacyVersion(String version) {
219-
if (version != null) {
220-
var semanticVersionMatcher = SEMANTIC_VERSION_PATTERN.matcher(version);
221-
if (semanticVersionMatcher.matches()) {
222-
return Version.fromString(semanticVersionMatcher.group(1));
223-
}
224-
}
225-
return null;
170+
return new DesiredNode(settings, processors, processorsRange, memory, storage);
226171
}
227172

228173
@Override
@@ -238,17 +183,6 @@ public void writeTo(StreamOutput out) throws IOException {
238183
}
239184
memory.writeTo(out);
240185
storage.writeTo(out);
241-
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_13_0)) {
242-
out.writeOptionalString(version);
243-
} else {
244-
Version parsedVersion = parseLegacyVersion(version);
245-
if (version == null) {
246-
// Some node is from before we made the version field not required. If so, fill in with the current node version.
247-
Version.writeVersion(Version.CURRENT, out);
248-
} else {
249-
Version.writeVersion(parsedVersion, out);
250-
}
251-
}
252186
}
253187

254188
public static DesiredNode fromXContent(XContentParser parser) throws IOException {
@@ -275,14 +209,6 @@ public void toInnerXContent(XContentBuilder builder, Params params) throws IOExc
275209
}
276210
builder.field(MEMORY_FIELD.getPreferredName(), memory);
277211
builder.field(STORAGE_FIELD.getPreferredName(), storage);
278-
addDeprecatedVersionField(builder);
279-
}
280-
281-
@UpdateForV9(owner = UpdateForV9.Owner.DISTRIBUTED_COORDINATION) // Remove deprecated field from response
282-
private void addDeprecatedVersionField(XContentBuilder builder) throws IOException {
283-
if (version != null) {
284-
builder.field(VERSION_FIELD.getPreferredName(), version);
285-
}
286212
}
287213

288214
public boolean hasMasterRole() {
@@ -366,7 +292,6 @@ private boolean equalsWithoutProcessorsSpecification(DesiredNode that) {
366292
return Objects.equals(settings, that.settings)
367293
&& Objects.equals(memory, that.memory)
368294
&& Objects.equals(storage, that.storage)
369-
&& Objects.equals(version, that.version)
370295
&& Objects.equals(externalId, that.externalId)
371296
&& Objects.equals(roles, that.roles);
372297
}
@@ -379,7 +304,7 @@ public boolean equalsWithProcessorsCloseTo(DesiredNode that) {
379304

380305
@Override
381306
public int hashCode() {
382-
return Objects.hash(settings, processors, processorsRange, memory, storage, version, externalId, roles);
307+
return Objects.hash(settings, processors, processorsRange, memory, storage, externalId, roles);
383308
}
384309

385310
@Override
@@ -408,10 +333,6 @@ public String toString() {
408333
+ '}';
409334
}
410335

411-
public boolean hasVersion() {
412-
return Strings.isNullOrBlank(version) == false;
413-
}
414-
415336
public record ProcessorsRange(Processors min, @Nullable Processors max) implements Writeable, ToXContentObject {
416337

417338
private static final ParseField MIN_FIELD = new ParseField("min");

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,12 @@ public record DesiredNodeWithStatus(DesiredNode desiredNode, Status status)
4444
(Processors) args[1],
4545
(DesiredNode.ProcessorsRange) args[2],
4646
(ByteSizeValue) args[3],
47-
(ByteSizeValue) args[4],
48-
(String) args[5]
47+
(ByteSizeValue) args[4]
4948
),
5049
// An unknown status is expected during upgrades to versions >= STATUS_TRACKING_SUPPORT_VERSION
5150
// the desired node status would be populated when a node in the newer version is elected as
5251
// master, the desired nodes status update happens in NodeJoinExecutor.
53-
args[6] == null ? Status.PENDING : (Status) args[6]
52+
args[5] == null ? Status.PENDING : (Status) args[5]
5453
)
5554
);
5655

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ public Map<NodeFeature, Version> getHistoricalFeatures() {
2929

3030
@Override
3131
public Set<NodeFeature> getFeatures() {
32-
return Set.of(DesiredNode.DESIRED_NODE_VERSION_DEPRECATED);
32+
return Set.of();
3333
}
3434
}

server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestUpdateDesiredNodesAction.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@
1212
import org.elasticsearch.action.admin.cluster.desirednodes.UpdateDesiredNodesAction;
1313
import org.elasticsearch.action.admin.cluster.desirednodes.UpdateDesiredNodesRequest;
1414
import org.elasticsearch.client.internal.node.NodeClient;
15-
import org.elasticsearch.cluster.metadata.DesiredNode;
1615
import org.elasticsearch.common.logging.DeprecationLogger;
1716
import org.elasticsearch.features.NodeFeature;
1817
import org.elasticsearch.rest.BaseRestHandler;
1918
import org.elasticsearch.rest.RestRequest;
2019
import org.elasticsearch.rest.action.RestToXContentListener;
21-
import org.elasticsearch.xcontent.XContentParseException;
2220
import org.elasticsearch.xcontent.XContentParser;
2321

2422
import java.io.IOException;
@@ -67,16 +65,6 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
6765
);
6866
}
6967

70-
if (clusterSupportsFeature.test(DesiredNode.DESIRED_NODE_VERSION_DEPRECATED)) {
71-
if (updateDesiredNodesRequest.getNodes().stream().anyMatch(DesiredNode::hasVersion)) {
72-
deprecationLogger.compatibleCritical("desired_nodes_version", VERSION_DEPRECATION_MESSAGE);
73-
}
74-
} else {
75-
if (updateDesiredNodesRequest.getNodes().stream().anyMatch(n -> n.hasVersion() == false)) {
76-
throw new XContentParseException("[node_version] field is required and must have a valid value");
77-
}
78-
}
79-
8068
return restChannel -> client.execute(
8169
UpdateDesiredNodesAction.INSTANCE,
8270
updateDesiredNodesRequest,

0 commit comments

Comments
 (0)