Skip to content

Commit

Permalink
Remove es.serverless flag
Browse files Browse the repository at this point in the history
This commit removes the remaining uses of the es.serverless flag. It is
no longer needed given pluggability of the rest and cat cations.
  • Loading branch information
rjernst committed Sep 15, 2023
1 parent 460c2ee commit e8f66ab
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@
import org.elasticsearch.action.update.UpdateAction;
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.NamedRegistry;
Expand Down Expand Up @@ -509,7 +508,6 @@ public class ActionModule extends AbstractModule {
private final RequestValidators<IndicesAliasesRequest> indicesAliasesRequestRequestValidators;
private final ThreadPool threadPool;
private final ReservedClusterStateService reservedClusterStateService;
private final boolean serverlessEnabled;
private final RestExtension restExtension;

public ActionModule(
Expand All @@ -536,7 +534,6 @@ public ActionModule(
this.settingsFilter = settingsFilter;
this.actionPlugins = actionPlugins;
this.threadPool = threadPool;
this.serverlessEnabled = DiscoveryNode.isServerless();
actions = setupActions(actionPlugins);
actionFilters = setupActionFilters(actionPlugins);
autoCreateIndex = new AutoCreateIndex(settings, clusterSettings, indexNameExpressionResolver, systemIndices);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@ public static boolean isStateless(final Settings settings) {
return settings.getAsBoolean(STATELESS_ENABLED_SETTING_NAME, false);
}

/**
* Check if the serverless feature flag is present and set to {@code true}, indicating that the node is
* part of a serverless deployment.
*
* @return true if the serverless feature flag is present and set
*/
public static boolean isServerless() {
return DiscoveryNodeRole.hasServerlessFeatureFlag();
}

static final String COORDINATING_ONLY = "coordinating_only";
public static final TransportVersion EXTERNAL_ID_VERSION = TransportVersions.V_8_3_0;
public static final Comparator<DiscoveryNode> DISCOVERY_NODE_COMPARATOR = Comparator.comparing(DiscoveryNode::getName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@

package org.elasticsearch.cluster.node;

import org.elasticsearch.Build;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.core.Booleans;

import java.lang.reflect.Field;
import java.util.Arrays;
Expand All @@ -28,19 +26,6 @@
*/
public class DiscoveryNodeRole implements Comparable<DiscoveryNodeRole> {

/**
* A feature flag to indicate if serverless is available or not. Defaults to false.
*/
private static final String USE_SERVERLESS_SYSTEM_PROPERTY = "es.serverless";
private static final Boolean USE_SERVERLESS_FEATURE_FLAG;
static {
final Boolean useStateless = Booleans.parseBoolean(System.getProperty(USE_SERVERLESS_SYSTEM_PROPERTY), false);
if (useStateless && Build.current().isSnapshot() == false) {
throw new IllegalArgumentException("Enabling serverless usage is only supported in snapshot builds");
}
USE_SERVERLESS_FEATURE_FLAG = useStateless;
}

private final String roleName;

/**
Expand Down Expand Up @@ -371,8 +356,4 @@ public static Optional<DiscoveryNodeRole> maybeGetRoleFromRoleName(final String
public static DiscoveryNodeRole getRoleFromRoleName(final String roleName) {
return maybeGetRoleFromRoleName(roleName).orElseThrow(() -> new IllegalArgumentException("unknown role [" + roleName + "]"));
}

public static boolean hasServerlessFeatureFlag() {
return USE_SERVERLESS_FEATURE_FLAG;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,7 @@ Collection<Object> createComponents(

final AuthenticationFailureHandler failureHandler = createAuthenticationFailureHandler(realms, extensionComponents);

// operator privileges are enabled either explicitly via the setting or if running serverless
final boolean operatorPrivilegesEnabled = OPERATOR_PRIVILEGES_ENABLED.get(settings) || DiscoveryNode.isServerless();
final boolean operatorPrivilegesEnabled = OPERATOR_PRIVILEGES_ENABLED.get(settings);

if (operatorPrivilegesEnabled) {
logger.info("operator privileges are enabled");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,6 @@ public <T> List<T> loadExtensions(Class<T> extensionPointType) {
}

public void testLoadExtensionsWhenOperatorPrivsAreDisabled() throws Exception {
assumeFalse("feature flag for serverless is expected to be false", DiscoveryNode.isServerless());
Settings.Builder settingsBuilder = Settings.builder().put("xpack.security.enabled", true).put("path.home", createTempDir());

if (randomBoolean()) {
Expand All @@ -951,36 +950,6 @@ public <T> List<T> loadExtensions(Class<T> extensionPointType) {
assertThat(operatorPrivilegesService, is(NOOP_OPERATOR_PRIVILEGES_SERVICE));
}

public void testLoadExtensionsWhenOperatorPrivsAreDisabledAndServerless() throws Exception {
assumeTrue("feature flag for serverless is expected to be true", DiscoveryNode.isServerless());
Settings.Builder settingsBuilder = Settings.builder().put("xpack.security.enabled", true).put("path.home", createTempDir());

if (randomBoolean()) {
settingsBuilder.put(OPERATOR_PRIVILEGES_ENABLED.getKey(), false); // doesn't matter if explicit or implicitly disabled
}

Settings settings = settingsBuilder.build();
constructNewSecurityObject(settings);
security.loadExtensions(new ExtensiblePlugin.ExtensionLoader() {
@Override
@SuppressWarnings("unchecked")
public <T> List<T> loadExtensions(Class<T> extensionPointType) {
List<Object> extensions = new ArrayList<>();
if (extensionPointType == OperatorOnlyRegistry.class) {
if (randomBoolean()) {
extensions.add(new DummyOperatorOnlyRegistry()); // will be used
}
}
return (List<T>) extensions;
}
});
createComponentsUtil(settings);
OperatorPrivileges.OperatorPrivilegesService operatorPrivilegesService = security.getOperatorPrivilegesService();
OperatorOnlyRegistry registry = ((OperatorPrivileges.DefaultOperatorPrivilegesService) operatorPrivilegesService)
.getOperatorOnlyRegistry();
assertThat(registry, instanceOf(DummyOperatorOnlyRegistry.class));
}

private void verifyHasAuthenticationHeaderValue(Exception e, String... expectedValues) {
assertThat(e, instanceOf(ElasticsearchSecurityException.class));
assertThat(((ElasticsearchSecurityException) e).getHeader("WWW-Authenticate"), notNullValue());
Expand Down

0 comments on commit e8f66ab

Please sign in to comment.