Skip to content

Commit

Permalink
Remove some historical features (elastic#116926)
Browse files Browse the repository at this point in the history
Historical features are now trivially true on v9 - so we can remove the features, and the check.
Historical features do not affect cluster state, so this has no compatibility restrictions.
  • Loading branch information
thecoop authored Nov 18, 2024
1 parent 08daf65 commit c832572
Show file tree
Hide file tree
Showing 45 changed files with 51 additions and 613 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,22 @@

package org.elasticsearch.datastreams;

import org.elasticsearch.Version;
import org.elasticsearch.action.admin.indices.rollover.LazyRolloverAction;
import org.elasticsearch.action.datastreams.autosharding.DataStreamAutoShardingService;
import org.elasticsearch.cluster.metadata.DataStreamGlobalRetention;
import org.elasticsearch.datastreams.lifecycle.health.DataStreamLifecycleHealthInfoPublisher;
import org.elasticsearch.features.FeatureSpecification;
import org.elasticsearch.features.NodeFeature;

import java.util.Map;
import java.util.Set;

/**
* Provides the features for data streams that this version of the code supports
*/
public class DataStreamFeatures implements FeatureSpecification {

public static final NodeFeature DATA_STREAM_LIFECYCLE = new NodeFeature("data_stream.lifecycle");
public static final NodeFeature DATA_STREAM_FAILURE_STORE_TSDB_FIX = new NodeFeature("data_stream.failure_store.tsdb_fix");

@Override
public Map<NodeFeature, Version> getHistoricalFeatures() {
return Map.of(DATA_STREAM_LIFECYCLE, Version.V_8_11_0);
}

@Override
public Set<NodeFeature> getFeatures() {
return Set.of(
Expand Down
1 change: 0 additions & 1 deletion server/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@
org.elasticsearch.cluster.service.TransportFeatures,
org.elasticsearch.cluster.metadata.MetadataFeatures,
org.elasticsearch.rest.RestFeatures,
org.elasticsearch.indices.IndicesFeatures,
org.elasticsearch.repositories.RepositoriesFeatures,
org.elasticsearch.action.admin.cluster.allocation.AllocationStatsFeatures,
org.elasticsearch.rest.action.admin.cluster.ClusterRerouteFeatures,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ public void initRestHandlers(Supplier<DiscoveryNodes> nodesInCluster, Predicate<
registerHandler.accept(new RestClusterStateAction(settingsFilter, threadPool));
registerHandler.accept(new RestClusterHealthAction());
registerHandler.accept(new RestClusterUpdateSettingsAction());
registerHandler.accept(new RestClusterGetSettingsAction(settings, clusterSettings, settingsFilter, clusterSupportsFeature));
registerHandler.accept(new RestClusterGetSettingsAction(settings, clusterSettings, settingsFilter));
registerHandler.accept(new RestClusterRerouteAction(settingsFilter));
registerHandler.accept(new RestClusterSearchShardsAction());
registerHandler.accept(new RestPendingClusterTasksAction());
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.elasticsearch.action.ResolvedIndices;
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
import org.elasticsearch.action.admin.indices.mapping.put.TransportAutoPutMappingAction;
import org.elasticsearch.action.admin.indices.mapping.put.TransportPutMappingAction;
import org.elasticsearch.action.admin.indices.stats.CommonStats;
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags;
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags.Flag;
Expand Down Expand Up @@ -79,7 +78,6 @@
import org.elasticsearch.env.ShardLock;
import org.elasticsearch.env.ShardLockObtainFailedException;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.gateway.MetaStateService;
import org.elasticsearch.gateway.MetadataStateFormat;
import org.elasticsearch.index.CloseUtils;
Expand Down Expand Up @@ -211,8 +209,6 @@ public class IndicesService extends AbstractLifecycleComponent
Setting.Property.NodeScope
);

static final NodeFeature SUPPORTS_AUTO_PUT = new NodeFeature("indices.auto_put_supported");

/**
* The node's settings.
*/
Expand Down Expand Up @@ -910,9 +906,7 @@ public void createShard(
.setConcreteIndex(shardRouting.index())
.source(mapping.source().string(), XContentType.JSON);
client.execute(
featureService.clusterHasFeature(clusterService.state(), SUPPORTS_AUTO_PUT)
? TransportAutoPutMappingAction.TYPE
: TransportPutMappingAction.TYPE,
TransportAutoPutMappingAction.TYPE,
putMappingRequestAcknowledgedRequest.ackTimeout(TimeValue.MAX_VALUE).masterNodeTimeout(TimeValue.MAX_VALUE),
new RefCountAwareThreadedActionListener<>(threadPool.generic(), listener.map(ignored -> null))
);
Expand Down
8 changes: 0 additions & 8 deletions server/src/main/java/org/elasticsearch/rest/RestFeatures.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@

package org.elasticsearch.rest;

import org.elasticsearch.Version;
import org.elasticsearch.features.FeatureSpecification;
import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.rest.action.admin.cluster.RestClusterGetSettingsAction;
import org.elasticsearch.rest.action.admin.cluster.RestNodesCapabilitiesAction;

import java.util.Map;
import java.util.Set;

import static org.elasticsearch.search.fetch.subphase.highlight.DefaultHighlighter.UNIFIED_HIGHLIGHTER_MATCHED_FIELDS;
Expand All @@ -29,9 +26,4 @@ public Set<NodeFeature> getFeatures() {
UNIFIED_HIGHLIGHTER_MATCHED_FIELDS
);
}

@Override
public Map<NodeFeature, Version> getHistoricalFeatures() {
return Map.of(RestClusterGetSettingsAction.SUPPORTS_GET_SETTINGS_ACTION, Version.V_8_3_0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@

import org.elasticsearch.action.admin.cluster.settings.ClusterGetSettingsAction;
import org.elasticsearch.action.admin.cluster.settings.RestClusterGetSettingsResponse;
import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest;
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsFilter;
import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.Scope;
Expand All @@ -27,31 +25,21 @@
import java.io.IOException;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;

import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestUtils.getMasterNodeTimeout;

@ServerlessScope(Scope.INTERNAL)
public class RestClusterGetSettingsAction extends BaseRestHandler {

public static final NodeFeature SUPPORTS_GET_SETTINGS_ACTION = new NodeFeature("rest.get_settings_action");

private final Settings settings;
private final ClusterSettings clusterSettings;
private final SettingsFilter settingsFilter;
private final Predicate<NodeFeature> clusterSupportsFeature;

public RestClusterGetSettingsAction(
Settings settings,
ClusterSettings clusterSettings,
SettingsFilter settingsFilter,
Predicate<NodeFeature> clusterSupportsFeature
) {
public RestClusterGetSettingsAction(Settings settings, ClusterSettings clusterSettings, SettingsFilter settingsFilter) {
this.settings = settings;
this.clusterSettings = clusterSettings;
this.settingsFilter = settingsFilter;
this.clusterSupportsFeature = clusterSupportsFeature;
}

@Override
Expand All @@ -72,10 +60,6 @@ private static void setUpRequestParams(MasterNodeReadRequest<?> clusterRequest,
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
final boolean renderDefaults = request.paramAsBoolean("include_defaults", false);

if (clusterSupportsFeature.test(SUPPORTS_GET_SETTINGS_ACTION) == false) {
return prepareLegacyRequest(request, client, renderDefaults);
}

ClusterGetSettingsAction.Request clusterSettingsRequest = new ClusterGetSettingsAction.Request(getMasterNodeTimeout(request));

setUpRequestParams(clusterSettingsRequest, request);
Expand All @@ -89,29 +73,6 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
);
}

private RestChannelConsumer prepareLegacyRequest(final RestRequest request, final NodeClient client, final boolean renderDefaults) {
ClusterStateRequest clusterStateRequest = new ClusterStateRequest(getMasterNodeTimeout(request)).routingTable(false).nodes(false);
setUpRequestParams(clusterStateRequest, request);
return channel -> client.admin()
.cluster()
.state(
clusterStateRequest,
new RestToXContentListener<RestClusterGetSettingsResponse>(channel).map(
r -> response(
new ClusterGetSettingsAction.Response(
r.getState().metadata().persistentSettings(),
r.getState().metadata().transientSettings(),
r.getState().metadata().settings()
),
renderDefaults,
settingsFilter,
clusterSettings,
settings
)
)
);
}

@Override
protected Set<String> responseParams() {
return Settings.FORMAT_PARAMS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ org.elasticsearch.health.HealthFeatures
org.elasticsearch.cluster.service.TransportFeatures
org.elasticsearch.cluster.metadata.MetadataFeatures
org.elasticsearch.rest.RestFeatures
org.elasticsearch.indices.IndicesFeatures
org.elasticsearch.repositories.RepositoriesFeatures
org.elasticsearch.action.admin.cluster.allocation.AllocationStatsFeatures
org.elasticsearch.rest.action.admin.cluster.ClusterRerouteFeatures
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
import org.elasticsearch.index.seqno.RetentionLeaseSyncer;
import org.elasticsearch.index.shard.PrimaryReplicaSyncer;
import org.elasticsearch.indices.EmptySystemIndices;
import org.elasticsearch.indices.IndicesFeatures;
import org.elasticsearch.indices.IndicesModule;
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.indices.IndicesServiceBuilder;
Expand Down Expand Up @@ -2245,7 +2244,7 @@ public RecyclerBytesStreamOutput newNetworkBytesStream() {
.scriptService(scriptService)
.clusterService(clusterService)
.client(client)
.featureService(new FeatureService(List.of(new IndicesFeatures())))
.featureService(new FeatureService(List.of()))
.metaStateService(new MetaStateService(nodeEnv, namedXContentRegistry))
.mapperMetrics(MapperMetrics.NOOP)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xcontent.NamedXContentRegistry;
import org.elasticsearch.xpack.core.ClientHelper;
Expand All @@ -33,16 +32,14 @@ public APMIndexTemplateRegistry(
ClusterService clusterService,
ThreadPool threadPool,
Client client,
NamedXContentRegistry xContentRegistry,
FeatureService featureService
NamedXContentRegistry xContentRegistry
) {
super(
nodeSettings,
clusterService,
threadPool,
client,
xContentRegistry,
featureService,
templateFilter(isDataStreamsLifecycleOnlyMode(clusterService.getSettings()))
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,7 @@ public Collection<?> createComponents(PluginServices services) {
Settings settings = services.environment().settings();
ClusterService clusterService = services.clusterService();
registry.set(
new APMIndexTemplateRegistry(
settings,
clusterService,
services.threadPool(),
services.client(),
services.xContentRegistry(),
services.featureService()
)
new APMIndexTemplateRegistry(settings, clusterService, services.threadPool(), services.client(), services.xContentRegistry())
);
if (enabled) {
APMIndexTemplateRegistry registryInstance = registry.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.datastreams.DataStreamFeatures;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.test.ClusterServiceUtils;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
Expand All @@ -24,7 +22,6 @@
import org.junit.After;
import org.junit.Before;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -56,15 +53,13 @@ public void createRegistryAndClient() {
additionalSettings,
clusterSettings
);
FeatureService featureService = new FeatureService(List.of(new DataStreamFeatures()));

apmIndexTemplateRegistry = new APMIndexTemplateRegistry(
Settings.EMPTY,
clusterService,
threadPool,
client,
NamedXContentRegistry.EMPTY,
featureService
NamedXContentRegistry.EMPTY
);
apmIndexTemplateRegistry.setEnabled(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

package org.elasticsearch.xpack.apmdata;

import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
Expand All @@ -30,8 +29,6 @@
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.datastreams.DataStreamFeatures;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.ingest.IngestMetadata;
import org.elasticsearch.ingest.PipelineConfiguration;
import org.elasticsearch.test.ClusterServiceUtils;
Expand Down Expand Up @@ -92,18 +89,16 @@ public void createRegistryAndClient() {
threadPool = new TestThreadPool(this.getClass().getName());
client = new VerifyingClient(threadPool);
ClusterService clusterService = ClusterServiceUtils.createClusterService(threadPool, clusterSettings);
FeatureService featureService = new FeatureService(List.of(new DataStreamFeatures()));
stackTemplateRegistryAccessor = new StackTemplateRegistryAccessor(
new StackTemplateRegistry(Settings.EMPTY, clusterService, threadPool, client, NamedXContentRegistry.EMPTY, featureService)
new StackTemplateRegistry(Settings.EMPTY, clusterService, threadPool, client, NamedXContentRegistry.EMPTY)
);

apmIndexTemplateRegistry = new APMIndexTemplateRegistry(
Settings.EMPTY,
clusterService,
threadPool,
client,
NamedXContentRegistry.EMPTY,
featureService
NamedXContentRegistry.EMPTY
);
apmIndexTemplateRegistry.setEnabled(true);
}
Expand Down Expand Up @@ -408,25 +403,6 @@ public void testIndexTemplateConventions() throws Exception {
}
}

public void testThatNothingIsInstalledWhenAllNodesAreNotUpdated() {
DiscoveryNode updatedNode = DiscoveryNodeUtils.create("updatedNode");
DiscoveryNode outdatedNode = DiscoveryNodeUtils.create("outdatedNode", ESTestCase.buildNewFakeTransportAddress(), Version.V_8_10_0);
DiscoveryNodes nodes = DiscoveryNodes.builder()
.localNodeId("updatedNode")
.masterNodeId("updatedNode")
.add(updatedNode)
.add(outdatedNode)
.build();

client.setVerifier((a, r, l) -> {
fail("if some cluster mode are not updated to at least v.8.11.0 nothing should happen");
return null;
});

ClusterChangedEvent event = createClusterChangedEvent(Map.of(), Map.of(), nodes);
apmIndexTemplateRegistry.clusterChanged(event);
}

public void testILMComponentTemplatesInstalled() throws Exception {
int ilmFallbackCount = 0;
for (Map.Entry<String, ComponentTemplate> entry : apmIndexTemplateRegistry.getComponentTemplateConfigs().entrySet()) {
Expand Down
Loading

0 comments on commit c832572

Please sign in to comment.