Skip to content

Commit 2a66a34

Browse files
authored
Remove Node Shutdown API feature flag (#76588)
This PR removes the Node Shutdown API feature flag. The Node Shutdown API will now always be available.
1 parent 3de609e commit 2a66a34

File tree

8 files changed

+17
-95
lines changed

8 files changed

+17
-95
lines changed

test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -763,23 +763,19 @@ private void wipeCluster() throws Exception {
763763
*/
764764
@SuppressWarnings("unchecked")
765765
protected void deleteAllNodeShutdownMetadata() throws IOException {
766-
if (minimumNodeVersion().onOrAfter(Version.V_7_15_0)) {
767-
Request getShutdownStatus = new Request("GET", "_nodes/shutdown");
768-
Map<String, Object> statusResponse = responseAsMap(adminClient().performRequest(getShutdownStatus));
769-
if (statusResponse.containsKey("_nodes") && statusResponse.containsKey("cluster_name")) {
770-
// If the response contains these two keys, the feature flag isn't enabled on this cluster, so skip out now.
771-
// We can't check the system property directly because it only gets set for the cluster under test's JVM, not for the test
772-
// runner's JVM.
773-
return;
774-
}
775-
List<Map<String, Object>> nodesArray = (List<Map<String, Object>>) statusResponse.get("nodes");
776-
List<String> nodeIds = nodesArray.stream()
777-
.map(nodeShutdownMetadata -> (String) nodeShutdownMetadata.get("node_id"))
778-
.collect(Collectors.toList());
779-
for (String nodeId : nodeIds) {
780-
Request deleteRequest = new Request("DELETE", "_nodes/" + nodeId + "/shutdown");
781-
assertOK(adminClient().performRequest(deleteRequest));
782-
}
766+
if (hasXPack() == false || minimumNodeVersion().before(Version.V_7_15_0)) {
767+
// Node shutdown APIs are only present in xpack
768+
return;
769+
}
770+
Request getShutdownStatus = new Request("GET", "_nodes/shutdown");
771+
Map<String, Object> statusResponse = responseAsMap(adminClient().performRequest(getShutdownStatus));
772+
List<Map<String, Object>> nodesArray = (List<Map<String, Object>>) statusResponse.get("nodes");
773+
List<String> nodeIds = nodesArray.stream()
774+
.map(nodeShutdownMetadata -> (String) nodeShutdownMetadata.get("node_id"))
775+
.collect(Collectors.toList());
776+
for (String nodeId : nodeIds) {
777+
Request deleteRequest = new Request("DELETE", "_nodes/" + nodeId + "/shutdown");
778+
assertOK(adminClient().performRequest(deleteRequest));
783779
}
784780
}
785781

x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/MlNodeShutdownIT.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
package org.elasticsearch.xpack.ml.integration;
99

1010
import org.apache.lucene.util.SetOnce;
11-
import org.elasticsearch.Build;
1211
import org.elasticsearch.cluster.metadata.Metadata;
1312
import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata;
1413
import org.elasticsearch.common.unit.ByteSizeValue;
@@ -37,9 +36,6 @@ public class MlNodeShutdownIT extends BaseMlIntegTestCase {
3736

3837
public void testJobsVacateShuttingDownNode() throws Exception {
3938

40-
// TODO: delete this condition when the shutdown API is always available
41-
assumeTrue("shutdown API is behind a snapshot-only feature flag", Build.CURRENT.isSnapshot());
42-
4339
internalCluster().ensureAtLeastNumDataNodes(3);
4440
ensureStableCluster();
4541

@@ -105,9 +101,6 @@ public void testJobsVacateShuttingDownNode() throws Exception {
105101

106102
public void testCloseJobVacatingShuttingDownNode() throws Exception {
107103

108-
// TODO: delete this condition when the shutdown API is always available
109-
assumeTrue("shutdown API is behind a snapshot-only feature flag", Build.CURRENT.isSnapshot());
110-
111104
internalCluster().ensureAtLeastNumDataNodes(3);
112105
ensureStableCluster();
113106

x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
package org.elasticsearch.xpack.ml.support;
88

99
import org.apache.logging.log4j.Logger;
10-
import org.elasticsearch.Build;
1110
import org.elasticsearch.action.ActionListener;
1211
import org.elasticsearch.action.DocWriteRequest;
1312
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksAction;
@@ -133,10 +132,6 @@ protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
133132
settings.put(MonitoringService.ENABLED.getKey(), false);
134133
settings.put(MonitoringService.ELASTICSEARCH_COLLECTION_ENABLED.getKey(), false);
135134
settings.put(LifecycleSettings.LIFECYCLE_HISTORY_INDEX_ENABLED_SETTING.getKey(), false);
136-
// TODO: put this setting unconditionally once the shutdown API is not protected by a feature flag
137-
if (Build.CURRENT.isSnapshot()) {
138-
settings.put(ShutdownPlugin.SHUTDOWN_FEATURE_ENABLED_FLAG, true);
139-
}
140135
return settings.build();
141136
}
142137

x-pack/plugin/security/qa/operator-privileges-tests/src/javaRestTest/java/org/elasticsearch/xpack/security/operator/OperatorPrivilegesIT.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ protected void deleteAllNodeShutdownMetadata() throws IOException {
4949
Request getShutdownStatus = new Request("GET", "_nodes/shutdown");
5050
getShutdownStatus.setOptions(RequestOptions.DEFAULT.toBuilder().addHeader("Authorization", OPERATOR_AUTH_HEADER));
5151
Map<String, Object> statusResponse = responseAsMap(adminClient().performRequest(getShutdownStatus));
52-
if (statusResponse.containsKey("_nodes") && statusResponse.containsKey("cluster_name")) {
53-
// If the response contains these two keys, the feature flag isn't enabled on this cluster, so skip out now.
54-
// We can't check the system property directly because it only gets set for the cluster under test's JVM, not for the test
55-
// runner's JVM.
56-
return;
57-
}
5852
List<Map<String, Object>> nodesArray = (List<Map<String, Object>>) statusResponse.get("nodes");
5953
List<String> nodeIds = nodesArray.stream()
6054
.map(nodeShutdownMetadata -> (String) nodeShutdownMetadata.get("node_id"))

x-pack/plugin/shutdown/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownIT.java

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

88
package org.elasticsearch.xpack.shutdown;
99

10-
import org.elasticsearch.Build;
1110
import org.elasticsearch.client.Request;
1211
import org.elasticsearch.client.Response;
1312
import org.elasticsearch.client.ResponseException;
@@ -47,7 +46,6 @@ public void testRemoveCRUD() throws Exception {
4746

4847
@SuppressWarnings("unchecked")
4948
public void checkCRUD(String type, String allocationDelay) throws Exception {
50-
assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot());
5149
String nodeIdToShutdown = getRandomNodeId();
5250

5351
// Ensure if we do a GET before the cluster metadata is set up, we don't get an error
@@ -83,7 +81,6 @@ public void testPutShutdownIsIdempotentForRemove() throws Exception {
8381

8482
@SuppressWarnings("unchecked")
8583
private void checkPutShutdownIdempotency(String type) throws Exception {
86-
assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot());
8784
String nodeIdToShutdown = getRandomNodeId();
8885

8986
// PUT the shutdown once
@@ -120,7 +117,6 @@ public void testPutShutdownCanChangeTypeFromRemoveToRestart() throws Exception {
120117

121118
@SuppressWarnings("unchecked")
122119
public void checkTypeChange(String fromType, String toType) throws Exception {
123-
assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot());
124120
String nodeIdToShutdown = getRandomNodeId();
125121
String type = fromType;
126122

@@ -153,7 +149,6 @@ public void checkTypeChange(String fromType, String toType) throws Exception {
153149
*/
154150
@SuppressWarnings("unchecked")
155151
public void testAllocationPreventedForRemoval() throws Exception {
156-
assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot());
157152
String nodeIdToShutdown = getRandomNodeId();
158153
putNodeShutdown(nodeIdToShutdown, "REMOVE");
159154

@@ -200,7 +195,6 @@ public void testAllocationPreventedForRemoval() throws Exception {
200195
*/
201196
@SuppressWarnings("unchecked")
202197
public void testShardsMoveOffRemovingNode() throws Exception {
203-
assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot());
204198
String nodeIdToShutdown = getRandomNodeId();
205199

206200
final String indexName = "test-idx";
@@ -252,7 +246,6 @@ public void testShardsMoveOffRemovingNode() throws Exception {
252246
}
253247

254248
public void testShardsCanBeAllocatedAfterShutdownDeleted() throws Exception {
255-
assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot());
256249
String nodeIdToShutdown = getRandomNodeId();
257250
putNodeShutdown(nodeIdToShutdown, "REMOVE");
258251

@@ -275,7 +268,6 @@ public void testShardsCanBeAllocatedAfterShutdownDeleted() throws Exception {
275268
}
276269

277270
public void testStalledShardMigrationProperlyDetected() throws Exception {
278-
assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot());
279271
String nodeIdToShutdown = getRandomNodeId();
280272
int numberOfShards = randomIntBetween(1,5);
281273

@@ -328,7 +320,6 @@ public void testStalledShardMigrationProperlyDetected() throws Exception {
328320
* Ensures that attempting to delete the status of a node that is not registered for shutdown gives a 404 response code.
329321
*/
330322
public void testDeleteNodeNotRegisteredForShutdown() throws Exception {
331-
assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot());
332323
Request deleteReq = new Request("DELETE", "_nodes/this-node-doesnt-exist/shutdown");
333324
ResponseException ex = expectThrows(ResponseException.class, () -> client().performRequest(deleteReq));
334325
assertThat(ex.getResponse().getStatusLine().getStatusCode(), is(404));

x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownPluginsIT.java

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

1010
import org.apache.logging.log4j.LogManager;
1111
import org.apache.logging.log4j.Logger;
12-
import org.elasticsearch.Build;
1312
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
1413
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
1514
import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata;
1615
import org.elasticsearch.cluster.node.DiscoveryNode;
17-
import org.elasticsearch.common.settings.Settings;
1816
import org.elasticsearch.plugins.Plugin;
1917
import org.elasticsearch.plugins.ShutdownAwarePlugin;
2018
import org.elasticsearch.test.ESIntegTestCase;
@@ -41,11 +39,8 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
4139
}
4240

4341
public void testShutdownAwarePlugin() throws Exception {
44-
assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot());
45-
// Start two nodes, one will be marked as shutting down
46-
Settings enabledSettings = Settings.builder().put(ShutdownPlugin.SHUTDOWN_FEATURE_ENABLED_FLAG, true).build();
47-
final String node1 = internalCluster().startNode(enabledSettings);
48-
final String node2 = internalCluster().startNode(enabledSettings);
42+
final String node1 = internalCluster().startNode();
43+
final String node2 = internalCluster().startNode();
4944

5045
final String shutdownNode;
5146
final String remainNode;

x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownTasksIT.java

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

1010
import org.apache.logging.log4j.LogManager;
1111
import org.apache.logging.log4j.Logger;
12-
import org.elasticsearch.Build;
1312
import org.elasticsearch.ResourceAlreadyExistsException;
1413
import org.elasticsearch.Version;
1514
import org.elasticsearch.action.ActionListener;
@@ -26,7 +25,6 @@
2625
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
2726
import org.elasticsearch.common.io.stream.StreamInput;
2827
import org.elasticsearch.common.io.stream.StreamOutput;
29-
import org.elasticsearch.common.settings.Settings;
3028
import org.elasticsearch.common.settings.SettingsModule;
3129
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
3230
import org.elasticsearch.common.xcontent.XContentBuilder;
@@ -77,11 +75,9 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
7775
}
7876

7977
public void testTasksAreNotAssignedToShuttingDownNode() throws Exception {
80-
assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot());
8178
// Start two nodes, one will be marked as shutting down
82-
Settings enabledSettings = Settings.builder().put(ShutdownPlugin.SHUTDOWN_FEATURE_ENABLED_FLAG, true).build();
83-
final String node1 = internalCluster().startNode(enabledSettings);
84-
final String node2 = internalCluster().startNode(enabledSettings);
79+
final String node1 = internalCluster().startNode();
80+
final String node2 = internalCluster().startNode();
8581

8682
final String shutdownNode;
8783
final String candidateNode;

x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownPlugin.java

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77
package org.elasticsearch.xpack.shutdown;
88

9-
import org.elasticsearch.Build;
109
import org.elasticsearch.action.ActionRequest;
1110
import org.elasticsearch.action.ActionResponse;
1211
import org.elasticsearch.action.support.master.AcknowledgedResponse;
@@ -17,7 +16,6 @@
1716
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
1817
import org.elasticsearch.common.settings.ClusterSettings;
1918
import org.elasticsearch.common.settings.IndexScopedSettings;
20-
import org.elasticsearch.common.settings.Setting;
2119
import org.elasticsearch.common.settings.Settings;
2220
import org.elasticsearch.common.settings.SettingsFilter;
2321
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
@@ -39,34 +37,6 @@
3937
import java.util.function.Supplier;
4038

4139
public class ShutdownPlugin extends Plugin implements ActionPlugin {
42-
43-
public static final String SHUTDOWN_FEATURE_ENABLED_FLAG = "es.shutdown_feature_flag_enabled";
44-
public static final Setting<Boolean> SHUTDOWN_FEATURE_ENABLED_FLAG_SETTING = Setting.boolSetting(
45-
SHUTDOWN_FEATURE_ENABLED_FLAG,
46-
(settings) -> {
47-
final String enabled = settings.get(SHUTDOWN_FEATURE_ENABLED_FLAG);
48-
// Enabled by default on snapshot builds, disabled on release builds
49-
if (Build.CURRENT.isSnapshot()) {
50-
if (enabled != null && enabled.equalsIgnoreCase("false")) {
51-
return "false";
52-
} else {
53-
return "true";
54-
}
55-
} else {
56-
if (enabled != null && enabled.equalsIgnoreCase("true")) {
57-
throw new IllegalArgumentException("shutdown plugin may not be enabled on a non-snapshot build");
58-
} else {
59-
return "false";
60-
}
61-
}
62-
},
63-
Setting.Property.NodeScope
64-
);
65-
66-
public boolean isEnabled(Settings settings) {
67-
return SHUTDOWN_FEATURE_ENABLED_FLAG_SETTING.get(settings);
68-
}
69-
7040
@Override
7141
public Collection<Object> createComponents(
7242
Client client,
@@ -114,14 +84,6 @@ public List<RestHandler> getRestHandlers(
11484
IndexNameExpressionResolver indexNameExpressionResolver,
11585
Supplier<DiscoveryNodes> nodesInCluster
11686
) {
117-
if (isEnabled(settings) == false) {
118-
return Collections.emptyList();
119-
}
12087
return Arrays.asList(new RestPutShutdownNodeAction(), new RestDeleteShutdownNodeAction(), new RestGetShutdownStatusAction());
12188
}
122-
123-
@Override
124-
public List<Setting<?>> getSettings() {
125-
return Collections.singletonList(SHUTDOWN_FEATURE_ENABLED_FLAG_SETTING);
126-
}
12789
}

0 commit comments

Comments
 (0)