From 00f52b96e6464af142c658ab05a697276b07ae49 Mon Sep 17 00:00:00 2001 From: Simon Cooper Date: Wed, 8 Jan 2025 14:56:04 +0000 Subject: [PATCH] Fix test, and update javadoc --- .../org/elasticsearch/features/FeatureSpecification.java | 8 +++++++- .../autosharding/DataStreamAutoShardingServiceTests.java | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/features/FeatureSpecification.java b/server/src/main/java/org/elasticsearch/features/FeatureSpecification.java index c37bc4488f109..2f016349e5fce 100644 --- a/server/src/main/java/org/elasticsearch/features/FeatureSpecification.java +++ b/server/src/main/java/org/elasticsearch/features/FeatureSpecification.java @@ -20,8 +20,14 @@ * unless they also support that feature (this is known as the 'feature ratchet'). * So once a feature is supported by a cluster, it will always be supported by that cluster in the future. *

+ * The only situation where features can be removed is on a compatibility boundary (normally a new major version). + * Because a new major version can only form a cluster with the highest minor of the previous major, + * any features introduced before that point can be assumed to always be present on that cluster. + * The feature itself can be removed by marking it as assumed by {@link NodeFeature#assumedAfterNextCompatibilityBoundary()}, + * in the last minor, and then removing it and associated conditions in the new major version. + *

* The feature information in cluster state should not normally be directly accessed. - * All feature checks should be done through {@code FeatureService} to ensure that Elasticsearch's + * All feature checks should be done through {@link FeatureService} to ensure that Elasticsearch's * guarantees on the introduction of new functionality are followed; * that is, new functionality is not enabled until all nodes in the cluster support it. *

diff --git a/server/src/test/java/org/elasticsearch/action/datastreams/autosharding/DataStreamAutoShardingServiceTests.java b/server/src/test/java/org/elasticsearch/action/datastreams/autosharding/DataStreamAutoShardingServiceTests.java index ba0f04d174f43..3a43a1df9bf88 100644 --- a/server/src/test/java/org/elasticsearch/action/datastreams/autosharding/DataStreamAutoShardingServiceTests.java +++ b/server/src/test/java/org/elasticsearch/action/datastreams/autosharding/DataStreamAutoShardingServiceTests.java @@ -144,7 +144,11 @@ public Set getFeatures() { { // cluster doesn't have feature - ClusterState stateNoFeature = ClusterState.builder(ClusterName.DEFAULT).metadata(Metadata.builder()).build(); + ClusterState stateNoFeature = ClusterState.builder(ClusterName.DEFAULT) + .nodes(DiscoveryNodes.builder().add(DiscoveryNodeUtils.create("n1")).add(DiscoveryNodeUtils.create("n2"))) + .nodeFeatures(Map.of("n1", Set.of(), "n2", Set.of())) + .metadata(Metadata.builder()) + .build(); Settings settings = Settings.builder().put(DataStreamAutoShardingService.DATA_STREAMS_AUTO_SHARDING_ENABLED, true).build(); DataStreamAutoShardingService noFeatureService = new DataStreamAutoShardingService(