From c41897e9c4730a7131b7cf1077c9e9d54237329c Mon Sep 17 00:00:00 2001 From: Simon Cooper Date: Thu, 9 Jan 2025 15:17:22 +0000 Subject: [PATCH] Remove the features supported feature (#119758) This removes the features_supported feature from the codebase, as all nodes communicable with 9.0 will support features --- .../upgrades/ClusterFeatureMigrationIT.java | 61 ------------------- .../features/ClusterFeaturesIT.java | 3 +- .../FeatureInfrastructureFeatures.java | 9 --- .../features/FeatureService.java | 4 -- .../features/FeatureSpecification.java | 2 +- 5 files changed, 2 insertions(+), 77 deletions(-) delete mode 100644 qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ClusterFeatureMigrationIT.java diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ClusterFeatureMigrationIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ClusterFeatureMigrationIT.java deleted file mode 100644 index 2b3e10acc15e..000000000000 --- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ClusterFeatureMigrationIT.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -package org.elasticsearch.upgrades; - -import com.carrotsearch.randomizedtesting.annotations.Name; - -import org.elasticsearch.client.Request; -import org.elasticsearch.common.xcontent.support.XContentMapValues; -import org.elasticsearch.features.FeatureService; -import org.junit.Before; - -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.Matchers.hasSize; - -public class ClusterFeatureMigrationIT extends AbstractRollingUpgradeTestCase { - - @Before - public void checkMigrationVersion() { - assumeFalse( - "This checks migrations from before cluster features were introduced", - oldClusterHasFeature(FeatureService.FEATURES_SUPPORTED) - ); - } - - public ClusterFeatureMigrationIT(@Name("upgradedNodes") int upgradedNodes) { - super(upgradedNodes); - } - - public void testClusterFeatureMigration() throws IOException { - if (isUpgradedCluster()) { - // check the nodes all have a feature in their cluster state (there should always be features_supported) - var response = entityAsMap(adminClient().performRequest(new Request("GET", "/_cluster/state/nodes"))); - List nodeFeatures = (List) XContentMapValues.extractValue("nodes_features", response); - assertThat(nodeFeatures, hasSize(adminClient().getNodes().size())); - - Map> features = nodeFeatures.stream() - .map(o -> (Map) o) - .collect(Collectors.toMap(m -> (String) m.get("node_id"), m -> (List) m.get("features"))); - - Set missing = features.entrySet() - .stream() - .filter(e -> e.getValue().contains(FeatureService.FEATURES_SUPPORTED.id()) == false) - .map(Map.Entry::getKey) - .collect(Collectors.toSet()); - assertThat(missing + " out of " + features.keySet() + " does not have the required feature", missing, empty()); - } - } -} diff --git a/server/src/internalClusterTest/java/org/elasticsearch/features/ClusterFeaturesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/features/ClusterFeaturesIT.java index 74fd945ed377..b756b4ca770c 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/features/ClusterFeaturesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/features/ClusterFeaturesIT.java @@ -30,7 +30,6 @@ public class ClusterFeaturesIT extends ESIntegTestCase { FeatureService service = internalCluster().getCurrentMasterNodeInstance(FeatureService.class); - assertThat(service.getNodeFeatures(), hasKey(FeatureService.FEATURES_SUPPORTED.id())); assertThat(service.getNodeFeatures(), hasKey(FeatureService.TEST_FEATURES_ENABLED.id())); // check the nodes all have a feature in their cluster state (there should always be features_supported) @@ -38,7 +37,7 @@ public class ClusterFeaturesIT extends ESIntegTestCase { var features = response.getState().clusterFeatures().nodeFeatures(); Set missing = features.entrySet() .stream() - .filter(e -> e.getValue().contains(FeatureService.FEATURES_SUPPORTED.id()) == false) + .filter(e -> e.getValue().contains(FeatureService.TEST_FEATURES_ENABLED.id()) == false) .map(Map.Entry::getKey) .collect(Collectors.toSet()); assertThat(missing + " out of " + features.keySet() + " does not have the required feature", missing, empty()); diff --git a/server/src/main/java/org/elasticsearch/features/FeatureInfrastructureFeatures.java b/server/src/main/java/org/elasticsearch/features/FeatureInfrastructureFeatures.java index 76afb5eba8a4..b61d866b0f1b 100644 --- a/server/src/main/java/org/elasticsearch/features/FeatureInfrastructureFeatures.java +++ b/server/src/main/java/org/elasticsearch/features/FeatureInfrastructureFeatures.java @@ -13,18 +13,9 @@ import java.util.Set; /** * This class specifies features for the features functionality itself. - *

- * This adds a feature {@code features_supported} indicating that a node supports node features. - * Nodes that do not support features won't have this feature in its feature set, - * so this can be checked without needing to look at the node version. */ public class FeatureInfrastructureFeatures implements FeatureSpecification { - @Override - public Set getFeatures() { - return Set.of(FeatureService.FEATURES_SUPPORTED); - } - @Override public Set getTestFeatures() { return Set.of(FeatureService.TEST_FEATURES_ENABLED); diff --git a/server/src/main/java/org/elasticsearch/features/FeatureService.java b/server/src/main/java/org/elasticsearch/features/FeatureService.java index da71b8f0ec2f..9f4ec6209c6f 100644 --- a/server/src/main/java/org/elasticsearch/features/FeatureService.java +++ b/server/src/main/java/org/elasticsearch/features/FeatureService.java @@ -26,10 +26,6 @@ import java.util.Map; */ public class FeatureService { - /** - * A feature indicating that node features are supported. - */ - public static final NodeFeature FEATURES_SUPPORTED = new NodeFeature("features_supported", true); public static final NodeFeature TEST_FEATURES_ENABLED = new NodeFeature("test_features_enabled"); private static final Logger logger = LogManager.getLogger(FeatureService.class); diff --git a/server/src/main/java/org/elasticsearch/features/FeatureSpecification.java b/server/src/main/java/org/elasticsearch/features/FeatureSpecification.java index c37bc4488f10..391dad48f734 100644 --- a/server/src/main/java/org/elasticsearch/features/FeatureSpecification.java +++ b/server/src/main/java/org/elasticsearch/features/FeatureSpecification.java @@ -31,7 +31,7 @@ import java.util.Set; */ public interface FeatureSpecification { /** - * Returns a set of regular features that this node supports. + * Returns a set of features that this node supports. */ default Set getFeatures() { return Set.of();