Skip to content

Commit c64226c

Browse files
authored
Don't return or accept node_version in the Desired Nodes API (elastic#114580)
It was deprecated in elastic#104209 (8.13) and shouldn't be set or returned in 9.0 The Desired Nodes API is an internal API, and users shouldn't depend on its backward compatibility.
1 parent a270ee3 commit c64226c

File tree

6 files changed

+13
-191
lines changed

6 files changed

+13
-191
lines changed

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();

rest-api-spec/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,6 @@ tasks.named("yamlRestCompatTestTransform").configure ({ task ->
6161
task.skipTest("search/330_fetch_fields/Test search rewrite", "warning does not exist for compatibility")
6262
task.skipTest("indices.create/21_synthetic_source_stored/object param - nested object with stored array", "temporary until backported")
6363
task.skipTest("cat.aliases/10_basic/Deprecated local parameter", "CAT APIs not covered by compatibility policy")
64+
task.skipTest("cluster.desired_nodes/10_basic/Test delete desired nodes with node_version generates a warning", "node_version warning is removed in 9.0")
65+
task.skipTest("cluster.desired_nodes/10_basic/Test update desired nodes with node_version generates a warning", "node_version warning is removed in 9.0")
6466
})

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/cluster/metadata/DesiredNode.java

Lines changed: 5 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414
import org.elasticsearch.Version;
1515
import org.elasticsearch.cluster.node.DiscoveryNode;
1616
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
17-
import org.elasticsearch.common.Strings;
1817
import org.elasticsearch.common.io.stream.StreamInput;
1918
import org.elasticsearch.common.io.stream.StreamOutput;
2019
import org.elasticsearch.common.io.stream.Writeable;
2120
import org.elasticsearch.common.settings.Settings;
2221
import org.elasticsearch.common.unit.ByteSizeValue;
2322
import org.elasticsearch.common.unit.Processors;
2423
import org.elasticsearch.core.Nullable;
25-
import org.elasticsearch.core.UpdateForV9;
2624
import org.elasticsearch.features.NodeFeature;
2725
import org.elasticsearch.xcontent.ConstructingObjectParser;
2826
import org.elasticsearch.xcontent.ObjectParser;
@@ -38,7 +36,6 @@
3836
import java.util.Set;
3937
import java.util.TreeSet;
4038
import java.util.function.Predicate;
41-
import java.util.regex.Pattern;
4239

4340
import static java.lang.String.format;
4441
import static org.elasticsearch.node.Node.NODE_EXTERNAL_ID_SETTING;
@@ -58,8 +55,6 @@ public final class DesiredNode implements Writeable, ToXContentObject, Comparabl
5855
private static final ParseField PROCESSORS_RANGE_FIELD = new ParseField("processors_range");
5956
private static final ParseField MEMORY_FIELD = new ParseField("memory");
6057
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");
6358

6459
public static final ConstructingObjectParser<DesiredNode, Void> PARSER = new ConstructingObjectParser<>(
6560
"desired_node",
@@ -69,8 +64,7 @@ public final class DesiredNode implements Writeable, ToXContentObject, Comparabl
6964
(Processors) args[1],
7065
(ProcessorsRange) args[2],
7166
(ByteSizeValue) args[3],
72-
(ByteSizeValue) args[4],
73-
(String) args[5]
67+
(ByteSizeValue) args[4]
7468
)
7569
);
7670

@@ -104,12 +98,6 @@ static <T> void configureParser(ConstructingObjectParser<T, Void> parser) {
10498
STORAGE_FIELD,
10599
ObjectParser.ValueType.STRING
106100
);
107-
parser.declareField(
108-
ConstructingObjectParser.optionalConstructorArg(),
109-
(p, c) -> p.text(),
110-
VERSION_FIELD,
111-
ObjectParser.ValueType.STRING
112-
);
113101
}
114102

115103
private final Settings settings;
@@ -118,21 +106,9 @@ static <T> void configureParser(ConstructingObjectParser<T, Void> parser) {
118106
private final ByteSizeValue memory;
119107
private final ByteSizeValue storage;
120108

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

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-
136112
public DesiredNode(Settings settings, ProcessorsRange processorsRange, ByteSizeValue memory, ByteSizeValue storage) {
137113
this(settings, null, processorsRange, memory, storage);
138114
}
@@ -142,17 +118,6 @@ public DesiredNode(Settings settings, double processors, ByteSizeValue memory, B
142118
}
143119

144120
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-
) {
156121
assert settings != null;
157122
assert memory != null;
158123
assert storage != null;
@@ -186,7 +151,6 @@ public DesiredNode(Settings settings, double processors, ByteSizeValue memory, B
186151
this.processorsRange = processorsRange;
187152
this.memory = memory;
188153
this.storage = storage;
189-
this.version = version;
190154
this.externalId = NODE_EXTERNAL_ID_SETTING.get(settings);
191155
this.roles = Collections.unmodifiableSortedSet(new TreeSet<>(DiscoveryNode.getRolesFromSettings(settings)));
192156
}
@@ -210,19 +174,7 @@ public static DesiredNode readFrom(StreamInput in) throws IOException {
210174
} else {
211175
version = Version.readVersion(in).toString();
212176
}
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;
177+
return new DesiredNode(settings, processors, processorsRange, memory, storage);
226178
}
227179

228180
@Override
@@ -239,15 +191,9 @@ public void writeTo(StreamOutput out) throws IOException {
239191
memory.writeTo(out);
240192
storage.writeTo(out);
241193
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_13_0)) {
242-
out.writeOptionalString(version);
194+
out.writeOptionalString(null);
243195
} 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-
}
196+
Version.writeVersion(Version.CURRENT, out);
251197
}
252198
}
253199

@@ -275,14 +221,6 @@ public void toInnerXContent(XContentBuilder builder, Params params) throws IOExc
275221
}
276222
builder.field(MEMORY_FIELD.getPreferredName(), memory);
277223
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-
}
286224
}
287225

288226
public boolean hasMasterRole() {
@@ -366,7 +304,6 @@ private boolean equalsWithoutProcessorsSpecification(DesiredNode that) {
366304
return Objects.equals(settings, that.settings)
367305
&& Objects.equals(memory, that.memory)
368306
&& Objects.equals(storage, that.storage)
369-
&& Objects.equals(version, that.version)
370307
&& Objects.equals(externalId, that.externalId)
371308
&& Objects.equals(roles, that.roles);
372309
}
@@ -379,7 +316,7 @@ public boolean equalsWithProcessorsCloseTo(DesiredNode that) {
379316

380317
@Override
381318
public int hashCode() {
382-
return Objects.hash(settings, processors, processorsRange, memory, storage, version, externalId, roles);
319+
return Objects.hash(settings, processors, processorsRange, memory, storage, externalId, roles);
383320
}
384321

385322
@Override
@@ -408,10 +345,6 @@ public String toString() {
408345
+ '}';
409346
}
410347

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

417350
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 & 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)