Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flip node shutdown feature flag to default to true on snapshot builds #75962

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions build-tools-internal/src/main/groovy/elasticsearch.run.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ testClusters {
throw new IllegalArgumentException("Unsupported self-generated license type: [" + licenseType + "[basic] or [trial].")
}
setting 'xpack.security.enabled', 'true'
if (VersionProperties.elasticsearch.toString().endsWith('-SNAPSHOT')) {
setting 'es.shutdown_feature_flag_enabled', 'true'
}
keystore 'bootstrap.password', 'password'
user username: 'elastic-admin', password: 'elastic-password', role: 'superuser'
}
Expand Down
3 changes: 0 additions & 3 deletions docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ testClusters.matching { it.name == "integTest"}.configureEach {
setting 'xpack.license.self_generated.type', 'trial'
setting 'indices.lifecycle.history_index_enabled', 'false'
setting 'ingest.geoip.downloader.enabled', 'false'
if (VersionProperties.elasticsearch.toString().endsWith('-SNAPSHOT')) {
setting 'es.shutdown_feature_flag_enabled', 'true'
}
systemProperty 'es.geoip_v2_feature_flag_enabled', 'true'
keystorePassword 'keystore-password'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ private void wipeCluster() throws Exception {
* If any nodes are registered for shutdown, removes their metadata.
*/
@SuppressWarnings("unchecked")
private static void deleteAllNodeShutdownMetadata() throws IOException {
protected void deleteAllNodeShutdownMetadata() throws IOException {
Request getShutdownStatus = new Request("GET", "_nodes/shutdown");
Map<String, Object> statusResponse = responseAsMap(adminClient().performRequest(getShutdownStatus));
if (statusResponse.containsKey("_nodes") && statusResponse.containsKey("cluster_name")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
Expand All @@ -42,6 +43,29 @@ protected Settings restClientSettings() {
return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", token).build();
}

@SuppressWarnings("unchecked")
@Override
protected void deleteAllNodeShutdownMetadata() throws IOException {
Request getShutdownStatus = new Request("GET", "_nodes/shutdown");
getShutdownStatus.setOptions(RequestOptions.DEFAULT.toBuilder().addHeader("Authorization", OPERATOR_AUTH_HEADER));
Map<String, Object> statusResponse = responseAsMap(adminClient().performRequest(getShutdownStatus));
if (statusResponse.containsKey("_nodes") && statusResponse.containsKey("cluster_name")) {
// If the response contains these two keys, the feature flag isn't enabled on this cluster, so skip out now.
// We can't check the system property directly because it only gets set for the cluster under test's JVM, not for the test
// runner's JVM.
return;
}
List<Map<String, Object>> nodesArray = (List<Map<String, Object>>) statusResponse.get("nodes");
List<String> nodeIds = nodesArray.stream()
.map(nodeShutdownMetadata -> (String) nodeShutdownMetadata.get("node_id"))
.collect(Collectors.toUnmodifiableList());
for (String nodeId : nodeIds) {
Request deleteRequest = new Request("DELETE", "_nodes/" + nodeId + "/shutdown");
deleteRequest.setOptions(RequestOptions.DEFAULT.toBuilder().addHeader("Authorization", OPERATOR_AUTH_HEADER));
assertOK(adminClient().performRequest(deleteRequest));
}
}

public void testNonOperatorSuperuserWillFailToCallOperatorOnlyApiWhenOperatorPrivilegesIsEnabled() throws IOException {
final Request postVotingConfigExclusionsRequest = new Request("POST", "_cluster/voting_config_exclusions?node_names=foo");
final ResponseException responseException = expectThrows(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ limited_operator:
- "monitor"
- "cluster:admin/settings/update"
- "cluster:admin/snapshot/restore"
- "cluster:admin/shutdown/*"
3 changes: 0 additions & 3 deletions x-pack/plugin/shutdown/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ testClusters.all {
testDistribution = 'default'
setting 'xpack.security.enabled', 'true'
setting 'xpack.license.self_generated.type', 'trial'
if (VersionProperties.elasticsearch.toString().endsWith('-SNAPSHOT')) {
setting 'es.shutdown_feature_flag_enabled', 'true'
}
keystore 'bootstrap.password', 'x-pack-test-password'
user username: "x_pack_rest_user", password: "x-pack-test-password"
}
3 changes: 0 additions & 3 deletions x-pack/plugin/shutdown/qa/multi-node/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ testClusters.all {
testDistribution = 'DEFAULT'
numberOfNodes = 4

if (VersionProperties.elasticsearch.toString().endsWith('-SNAPSHOT')) {
setting 'es.shutdown_feature_flag_enabled', 'true'
}
setting 'xpack.security.enabled', 'true'
user username: clusterCredentials.username, password: clusterCredentials.password, role: 'superuser'
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,21 @@ public class ShutdownPlugin extends Plugin implements ActionPlugin {
public static final String SHUTDOWN_FEATURE_ENABLED_FLAG = "es.shutdown_feature_flag_enabled";
public static final Setting<Boolean> SHUTDOWN_FEATURE_ENABLED_FLAG_SETTING = Setting.boolSetting(
SHUTDOWN_FEATURE_ENABLED_FLAG,
false,
enabled -> {
if (enabled != null && enabled && Build.CURRENT.isSnapshot() == false) {
throw new IllegalArgumentException("shutdown plugin may not be enabled on a non-snapshot build");
(settings) -> {
final String enabled = settings.get(SHUTDOWN_FEATURE_ENABLED_FLAG);
// Enabled by default on snapshot builds, disabled on release builds
if (Build.CURRENT.isSnapshot()) {
if (enabled != null && enabled.equalsIgnoreCase("false")) {
return "false";
} else {
return "true";
}
} else {
if (enabled != null && enabled.equalsIgnoreCase("true")) {
throw new IllegalArgumentException("shutdown plugin may not be enabled on a non-snapshot build");
} else {
return "false";
}
}
},
Setting.Property.NodeScope
Expand Down