Skip to content

Commit 885a551

Browse files
authored
Don't return or accept node_version in the Desired Nodes API (#119049)
Re-submission of #114580 > node_version was deprecated in #104209 (8.13) and shouldn't be set or returned in 9.0 Resolve ES-9443
1 parent b440e06 commit 885a551

File tree

7 files changed

+21
-192
lines changed

7 files changed

+21
-192
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ private void addClusterNodesToDesiredNodesWithProcessorsOrProcessorRanges(int ve
8282
Settings.builder().put(NODE_NAME_SETTING.getKey(), nodeName).build(),
8383
randomDoubleProcessorCount(),
8484
ByteSizeValue.ofGb(randomIntBetween(10, 24)),
85-
ByteSizeValue.ofGb(randomIntBetween(128, 256)),
86-
null
85+
ByteSizeValue.ofGb(randomIntBetween(128, 256))
8786
)
8887
)
8988
.toList();
@@ -94,8 +93,7 @@ private void addClusterNodesToDesiredNodesWithProcessorsOrProcessorRanges(int ve
9493
Settings.builder().put(NODE_NAME_SETTING.getKey(), nodeName).build(),
9594
new DesiredNode.ProcessorsRange(minProcessors, minProcessors + randomIntBetween(10, 20)),
9695
ByteSizeValue.ofGb(randomIntBetween(10, 24)),
97-
ByteSizeValue.ofGb(randomIntBetween(128, 256)),
98-
null
96+
ByteSizeValue.ofGb(randomIntBetween(128, 256))
9997
);
10098
}).toList();
10199
}

rest-api-spec/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,12 @@ tasks.named("yamlRestCompatTestTransform").configure ({ task ->
7474
task.skipTest("index/91_metrics_no_subobjects/Metrics object indexing with synthetic source", "_source.mode mapping attribute is no-op since 9.0.0")
7575
task.skipTest("index/91_metrics_no_subobjects/Root without subobjects with synthetic source", "_source.mode mapping attribute is no-op since 9.0.0")
7676
task.skipTest("indices.create/20_synthetic_source/synthetic_source with copy_to inside nested object", "temporary until backported")
77+
task.skipTest(
78+
"cluster.desired_nodes/10_basic/Test delete desired nodes with node_version generates a warning",
79+
"node_version warning is removed in 9.0"
80+
)
81+
task.skipTest(
82+
"cluster.desired_nodes/10_basic/Test update desired nodes with node_version generates a warning",
83+
"node_version warning is removed in 9.0"
84+
)
7785
})

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/cluster.desired_nodes/10_basic.yml

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -59,61 +59,6 @@ teardown:
5959
- contains: { nodes: { settings: { node: { name: "instance-000187" } }, processors: 8.5, memory: "64gb", storage: "128gb" } }
6060
- contains: { nodes: { settings: { node: { name: "instance-000188" } }, processors: 16.0, memory: "128gb", storage: "1tb" } }
6161
---
62-
"Test update desired nodes with node_version generates a warning":
63-
- skip:
64-
reason: "contains is a newly added assertion"
65-
features: ["contains", "allowed_warnings"]
66-
- do:
67-
cluster.state: {}
68-
69-
# Get master node id
70-
- set: { master_node: master }
71-
72-
- do:
73-
nodes.info: {}
74-
- set: { nodes.$master.version: es_version }
75-
76-
- do:
77-
_internal.update_desired_nodes:
78-
history_id: "test"
79-
version: 1
80-
body:
81-
nodes:
82-
- { settings: { "node.name": "instance-000187" }, processors: 8.5, memory: "64gb", storage: "128gb", node_version: $es_version }
83-
allowed_warnings:
84-
- "[version removal] Specifying node_version in desired nodes requests is deprecated."
85-
- match: { replaced_existing_history_id: false }
86-
87-
- do:
88-
_internal.get_desired_nodes: {}
89-
- match:
90-
$body:
91-
history_id: "test"
92-
version: 1
93-
nodes:
94-
- { settings: { node: { name: "instance-000187" } }, processors: 8.5, memory: "64gb", storage: "128gb", node_version: $es_version }
95-
96-
- do:
97-
_internal.update_desired_nodes:
98-
history_id: "test"
99-
version: 2
100-
body:
101-
nodes:
102-
- { settings: { "node.name": "instance-000187" }, processors: 8.5, memory: "64gb", storage: "128gb", node_version: $es_version }
103-
- { settings: { "node.name": "instance-000188" }, processors: 16.0, memory: "128gb", storage: "1tb", node_version: $es_version }
104-
allowed_warnings:
105-
- "[version removal] Specifying node_version in desired nodes requests is deprecated."
106-
- match: { replaced_existing_history_id: false }
107-
108-
- do:
109-
_internal.get_desired_nodes: {}
110-
111-
- match: { history_id: "test" }
112-
- match: { version: 2 }
113-
- length: { nodes: 2 }
114-
- contains: { nodes: { settings: { node: { name: "instance-000187" } }, processors: 8.5, memory: "64gb", storage: "128gb", node_version: $es_version } }
115-
- contains: { nodes: { settings: { node: { name: "instance-000188" } }, processors: 16.0, memory: "128gb", storage: "1tb", node_version: $es_version } }
116-
---
11762
"Test update move to a new history id":
11863
- skip:
11964
reason: "contains is a newly added assertion"
@@ -199,46 +144,6 @@ teardown:
199144
_internal.get_desired_nodes: {}
200145
- match: { status: 404 }
201146
---
202-
"Test delete desired nodes with node_version generates a warning":
203-
- skip:
204-
features: allowed_warnings
205-
- do:
206-
cluster.state: {}
207-
208-
- set: { master_node: master }
209-
210-
- do:
211-
nodes.info: {}
212-
- set: { nodes.$master.version: es_version }
213-
214-
- do:
215-
_internal.update_desired_nodes:
216-
history_id: "test"
217-
version: 1
218-
body:
219-
nodes:
220-
- { settings: { "node.external_id": "instance-000187" }, processors: 8.0, memory: "64gb", storage: "128gb", node_version: $es_version }
221-
allowed_warnings:
222-
- "[version removal] Specifying node_version in desired nodes requests is deprecated."
223-
- match: { replaced_existing_history_id: false }
224-
225-
- do:
226-
_internal.get_desired_nodes: {}
227-
- match:
228-
$body:
229-
history_id: "test"
230-
version: 1
231-
nodes:
232-
- { settings: { node: { external_id: "instance-000187" } }, processors: 8.0, memory: "64gb", storage: "128gb", node_version: $es_version }
233-
234-
- do:
235-
_internal.delete_desired_nodes: {}
236-
237-
- do:
238-
catch: missing
239-
_internal.get_desired_nodes: {}
240-
- match: { status: 404 }
241-
---
242147
"Test update desired nodes is idempotent":
243148
- skip:
244149
reason: "contains is a newly added assertion"

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ static TransportVersion def(int id) {
178178
public static final TransportVersion REMOVE_SNAPSHOT_FAILURES = def(9_002_0_00);
179179
public static final TransportVersion TRANSPORT_STATS_HANDLING_TIME_REQUIRED = def(9_003_0_00);
180180

181+
public static final TransportVersion REMOVE_DESIRED_NODE_VERSION = def(9_004_0_00);
182+
181183
/*
182184
* STOP! READ THIS FIRST! No, really,
183185
* ____ _____ ___ ____ _ ____ _____ _ ____ _____ _ _ ___ ____ _____ ___ ____ ____ _____ _

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

Lines changed: 7 additions & 80 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.xcontent.ConstructingObjectParser;
2724
import org.elasticsearch.xcontent.ObjectParser;
2825
import org.elasticsearch.xcontent.ParseField;
@@ -36,7 +33,6 @@
3633
import java.util.Objects;
3734
import java.util.Set;
3835
import java.util.TreeSet;
39-
import java.util.regex.Pattern;
4036

4137
import static java.lang.String.format;
4238
import static org.elasticsearch.node.Node.NODE_EXTERNAL_ID_SETTING;
@@ -52,8 +48,6 @@ public final class DesiredNode implements Writeable, ToXContentObject, Comparabl
5248
private static final ParseField PROCESSORS_RANGE_FIELD = new ParseField("processors_range");
5349
private static final ParseField MEMORY_FIELD = new ParseField("memory");
5450
private static final ParseField STORAGE_FIELD = new ParseField("storage");
55-
@UpdateForV9(owner = UpdateForV9.Owner.DISTRIBUTED_COORDINATION) // Remove deprecated field
56-
private static final ParseField VERSION_FIELD = new ParseField("node_version");
5751

5852
public static final ConstructingObjectParser<DesiredNode, Void> PARSER = new ConstructingObjectParser<>(
5953
"desired_node",
@@ -63,8 +57,7 @@ public final class DesiredNode implements Writeable, ToXContentObject, Comparabl
6357
(Processors) args[1],
6458
(ProcessorsRange) args[2],
6559
(ByteSizeValue) args[3],
66-
(ByteSizeValue) args[4],
67-
(String) args[5]
60+
(ByteSizeValue) args[4]
6861
)
6962
);
7063

@@ -98,12 +91,6 @@ static <T> void configureParser(ConstructingObjectParser<T, Void> parser) {
9891
STORAGE_FIELD,
9992
ObjectParser.ValueType.STRING
10093
);
101-
parser.declareField(
102-
ConstructingObjectParser.optionalConstructorArg(),
103-
(p, c) -> p.text(),
104-
VERSION_FIELD,
105-
ObjectParser.ValueType.STRING
106-
);
10794
}
10895

10996
private final Settings settings;
@@ -112,21 +99,9 @@ static <T> void configureParser(ConstructingObjectParser<T, Void> parser) {
11299
private final ByteSizeValue memory;
113100
private final ByteSizeValue storage;
114101

115-
@UpdateForV9(owner = UpdateForV9.Owner.DISTRIBUTED_COORDINATION) // Remove deprecated version field
116-
private final String version;
117102
private final String externalId;
118103
private final Set<DiscoveryNodeRole> roles;
119104

120-
@Deprecated
121-
public DesiredNode(Settings settings, ProcessorsRange processorsRange, ByteSizeValue memory, ByteSizeValue storage, String version) {
122-
this(settings, null, processorsRange, memory, storage, version);
123-
}
124-
125-
@Deprecated
126-
public DesiredNode(Settings settings, double processors, ByteSizeValue memory, ByteSizeValue storage, String version) {
127-
this(settings, Processors.of(processors), null, memory, storage, version);
128-
}
129-
130105
public DesiredNode(Settings settings, ProcessorsRange processorsRange, ByteSizeValue memory, ByteSizeValue storage) {
131106
this(settings, null, processorsRange, memory, storage);
132107
}
@@ -136,17 +111,6 @@ public DesiredNode(Settings settings, double processors, ByteSizeValue memory, B
136111
}
137112

138113
DesiredNode(Settings settings, Processors processors, ProcessorsRange processorsRange, ByteSizeValue memory, ByteSizeValue storage) {
139-
this(settings, processors, processorsRange, memory, storage, null);
140-
}
141-
142-
DesiredNode(
143-
Settings settings,
144-
Processors processors,
145-
ProcessorsRange processorsRange,
146-
ByteSizeValue memory,
147-
ByteSizeValue storage,
148-
@Deprecated String version
149-
) {
150114
assert settings != null;
151115
assert memory != null;
152116
assert storage != null;
@@ -180,7 +144,6 @@ public DesiredNode(Settings settings, double processors, ByteSizeValue memory, B
180144
this.processorsRange = processorsRange;
181145
this.memory = memory;
182146
this.storage = storage;
183-
this.version = version;
184147
this.externalId = NODE_EXTERNAL_ID_SETTING.get(settings);
185148
this.roles = Collections.unmodifiableSortedSet(new TreeSet<>(DiscoveryNode.getRolesFromSettings(settings)));
186149
}
@@ -198,25 +161,10 @@ public static DesiredNode readFrom(StreamInput in) throws IOException {
198161
}
199162
final var memory = ByteSizeValue.readFrom(in);
200163
final var storage = ByteSizeValue.readFrom(in);
201-
final String version;
202-
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_13_0)) {
203-
version = in.readOptionalString();
204-
} else {
205-
version = Version.readVersion(in).toString();
164+
if (in.getTransportVersion().before(TransportVersions.REMOVE_DESIRED_NODE_VERSION)) {
165+
in.readOptionalString();
206166
}
207-
return new DesiredNode(settings, processors, processorsRange, memory, storage, version);
208-
}
209-
210-
private static final Pattern SEMANTIC_VERSION_PATTERN = Pattern.compile("^(\\d+\\.\\d+\\.\\d+)\\D?.*");
211-
212-
private static Version parseLegacyVersion(String version) {
213-
if (version != null) {
214-
var semanticVersionMatcher = SEMANTIC_VERSION_PATTERN.matcher(version);
215-
if (semanticVersionMatcher.matches()) {
216-
return Version.fromString(semanticVersionMatcher.group(1));
217-
}
218-
}
219-
return null;
167+
return new DesiredNode(settings, processors, processorsRange, memory, storage);
220168
}
221169

222170
@Override
@@ -232,16 +180,8 @@ public void writeTo(StreamOutput out) throws IOException {
232180
}
233181
memory.writeTo(out);
234182
storage.writeTo(out);
235-
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_13_0)) {
236-
out.writeOptionalString(version);
237-
} else {
238-
Version parsedVersion = parseLegacyVersion(version);
239-
if (version == null) {
240-
// Some node is from before we made the version field not required. If so, fill in with the current node version.
241-
Version.writeVersion(Version.CURRENT, out);
242-
} else {
243-
Version.writeVersion(parsedVersion, out);
244-
}
183+
if (out.getTransportVersion().before(TransportVersions.REMOVE_DESIRED_NODE_VERSION)) {
184+
out.writeOptionalString(null);
245185
}
246186
}
247187

@@ -269,14 +209,6 @@ public void toInnerXContent(XContentBuilder builder, Params params) throws IOExc
269209
}
270210
builder.field(MEMORY_FIELD.getPreferredName(), memory);
271211
builder.field(STORAGE_FIELD.getPreferredName(), storage);
272-
addDeprecatedVersionField(builder);
273-
}
274-
275-
@UpdateForV9(owner = UpdateForV9.Owner.DISTRIBUTED_COORDINATION) // Remove deprecated field from response
276-
private void addDeprecatedVersionField(XContentBuilder builder) throws IOException {
277-
if (version != null) {
278-
builder.field(VERSION_FIELD.getPreferredName(), version);
279-
}
280212
}
281213

282214
public boolean hasMasterRole() {
@@ -356,7 +288,6 @@ private boolean equalsWithoutProcessorsSpecification(DesiredNode that) {
356288
return Objects.equals(settings, that.settings)
357289
&& Objects.equals(memory, that.memory)
358290
&& Objects.equals(storage, that.storage)
359-
&& Objects.equals(version, that.version)
360291
&& Objects.equals(externalId, that.externalId)
361292
&& Objects.equals(roles, that.roles);
362293
}
@@ -369,7 +300,7 @@ public boolean equalsWithProcessorsCloseTo(DesiredNode that) {
369300

370301
@Override
371302
public int hashCode() {
372-
return Objects.hash(settings, processors, processorsRange, memory, storage, version, externalId, roles);
303+
return Objects.hash(settings, processors, processorsRange, memory, storage, externalId, roles);
373304
}
374305

375306
@Override
@@ -398,10 +329,6 @@ public String toString() {
398329
+ '}';
399330
}
400331

401-
public boolean hasVersion() {
402-
return Strings.isNullOrBlank(version) == false;
403-
}
404-
405332
public record ProcessorsRange(Processors min, @Nullable Processors max) implements Writeable, ToXContentObject {
406333

407334
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/rest/action/admin/cluster/RestUpdateDesiredNodesAction.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
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;
16-
import org.elasticsearch.common.logging.DeprecationLogger;
1715
import org.elasticsearch.rest.BaseRestHandler;
1816
import org.elasticsearch.rest.RestRequest;
1917
import org.elasticsearch.rest.action.RestToXContentListener;
@@ -27,10 +25,6 @@
2725

2826
public class RestUpdateDesiredNodesAction extends BaseRestHandler {
2927

30-
private final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestUpdateDesiredNodesAction.class);
31-
private static final String VERSION_DEPRECATION_MESSAGE =
32-
"[version removal] Specifying node_version in desired nodes requests is deprecated.";
33-
3428
@Override
3529
public String getName() {
3630
return "update_desired_nodes";
@@ -59,10 +53,6 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
5953
);
6054
}
6155

62-
if (updateDesiredNodesRequest.getNodes().stream().anyMatch(DesiredNode::hasVersion)) {
63-
deprecationLogger.compatibleCritical("desired_nodes_version", VERSION_DEPRECATION_MESSAGE);
64-
}
65-
6656
return restChannel -> client.execute(
6757
UpdateDesiredNodesAction.INSTANCE,
6858
updateDesiredNodesRequest,

0 commit comments

Comments
 (0)