Remove health historical features and upgrade test (#116928)

This commit is contained in:
Simon Cooper 2024-11-18 14:30:11 +00:00 committed by GitHub
parent 81e3afaafa
commit 08daf65592
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 7 additions and 121 deletions

View file

@ -1,45 +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.apache.http.util.EntityUtils;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.hamcrest.Matchers;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import static org.hamcrest.CoreMatchers.equalTo;
public class HealthNodeUpgradeIT extends AbstractRollingUpgradeTestCase {
public HealthNodeUpgradeIT(@Name("upgradedNodes") int upgradedNodes) {
super(upgradedNodes);
}
public void testHealthNode() throws Exception {
if (clusterHasFeature("health.supports_health")) {
assertBusy(() -> {
Response response = client().performRequest(new Request("GET", "_cat/tasks"));
String tasks = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
assertThat(tasks, Matchers.containsString("health-node"));
});
assertBusy(() -> {
String path = clusterHasFeature("health.supports_health_report_api") ? "_health_report" : "_internal/_health";
Response response = client().performRequest(new Request("GET", path));
Map<String, Object> health_report = entityAsMap(response.getEntity());
assertThat(health_report.get("status"), equalTo("green"));
});
}
}
}

View file

@ -9,34 +9,17 @@
package org.elasticsearch.health; package org.elasticsearch.health;
import org.elasticsearch.Version;
import org.elasticsearch.features.FeatureSpecification; import org.elasticsearch.features.FeatureSpecification;
import org.elasticsearch.features.NodeFeature; import org.elasticsearch.features.NodeFeature;
import java.util.Map;
import java.util.Set; import java.util.Set;
public class HealthFeatures implements FeatureSpecification { public class HealthFeatures implements FeatureSpecification {
public static final NodeFeature SUPPORTS_HEALTH = new NodeFeature("health.supports_health");
public static final NodeFeature SUPPORTS_HEALTH_REPORT_API = new NodeFeature("health.supports_health_report_api");
public static final NodeFeature SUPPORTS_SHARDS_CAPACITY_INDICATOR = new NodeFeature("health.shards_capacity_indicator");
public static final NodeFeature SUPPORTS_EXTENDED_REPOSITORY_INDICATOR = new NodeFeature("health.extended_repository_indicator"); public static final NodeFeature SUPPORTS_EXTENDED_REPOSITORY_INDICATOR = new NodeFeature("health.extended_repository_indicator");
@Override @Override
public Set<NodeFeature> getFeatures() { public Set<NodeFeature> getFeatures() {
return Set.of(SUPPORTS_EXTENDED_REPOSITORY_INDICATOR); return Set.of(SUPPORTS_EXTENDED_REPOSITORY_INDICATOR);
} }
@Override
public Map<NodeFeature, Version> getHistoricalFeatures() {
return Map.of(
SUPPORTS_HEALTH,
Version.V_8_5_0, // health accessible via /_internal/_health
SUPPORTS_HEALTH_REPORT_API,
Version.V_8_7_0, // health accessible via /_health_report
SUPPORTS_SHARDS_CAPACITY_INDICATOR,
Version.V_8_8_0
);
}
} }

View file

@ -28,7 +28,6 @@ import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.Tuple; import org.elasticsearch.core.Tuple;
import org.elasticsearch.features.FeatureService; import org.elasticsearch.features.FeatureService;
import org.elasticsearch.gateway.GatewayService; import org.elasticsearch.gateway.GatewayService;
import org.elasticsearch.health.HealthFeatures;
import java.util.List; import java.util.List;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -137,7 +136,7 @@ public class HealthMetadataService {
private boolean canPostClusterStateUpdates(ClusterState state) { private boolean canPostClusterStateUpdates(ClusterState state) {
// Wait until every node in the cluster supports health checks // Wait until every node in the cluster supports health checks
return isMaster && state.clusterRecovered() && featureService.clusterHasFeature(state, HealthFeatures.SUPPORTS_HEALTH); return isMaster && state.clusterRecovered();
} }
private void updateOnClusterStateChange(ClusterChangedEvent event) { private void updateOnClusterStateChange(ClusterChangedEvent event) {

View file

@ -20,7 +20,6 @@ import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.features.FeatureService; import org.elasticsearch.features.FeatureService;
import org.elasticsearch.health.Diagnosis; import org.elasticsearch.health.Diagnosis;
import org.elasticsearch.health.HealthFeatures;
import org.elasticsearch.health.HealthIndicatorDetails; import org.elasticsearch.health.HealthIndicatorDetails;
import org.elasticsearch.health.HealthIndicatorImpact; import org.elasticsearch.health.HealthIndicatorImpact;
import org.elasticsearch.health.HealthIndicatorResult; import org.elasticsearch.health.HealthIndicatorResult;
@ -91,15 +90,6 @@ public class DiskHealthIndicatorService implements HealthIndicatorService {
ClusterState clusterState = clusterService.state(); ClusterState clusterState = clusterService.state();
Map<String, DiskHealthInfo> diskHealthInfoMap = healthInfo.diskInfoByNode(); Map<String, DiskHealthInfo> diskHealthInfoMap = healthInfo.diskInfoByNode();
if (diskHealthInfoMap == null || diskHealthInfoMap.isEmpty()) { if (diskHealthInfoMap == null || diskHealthInfoMap.isEmpty()) {
if (featureService.clusterHasFeature(clusterState, HealthFeatures.SUPPORTS_HEALTH) == false) {
return createIndicator(
HealthStatus.GREEN,
"No disk usage data available. The cluster currently has mixed versions (an upgrade may be in progress).",
HealthIndicatorDetails.EMPTY,
List.of(),
List.of()
);
}
/* /*
* If there is no disk health info, that either means that a new health node was just elected, or something is seriously * If there is no disk health info, that either means that a new health node was just elected, or something is seriously
* wrong with health data collection on the health node. Either way, we immediately return UNKNOWN. If there are at least * wrong with health data collection on the health node. Either way, we immediately return UNKNOWN. If there are at least

View file

@ -25,7 +25,6 @@ import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
import org.elasticsearch.common.util.concurrent.RunOnce; import org.elasticsearch.common.util.concurrent.RunOnce;
import org.elasticsearch.core.TimeValue; import org.elasticsearch.core.TimeValue;
import org.elasticsearch.features.FeatureService; import org.elasticsearch.features.FeatureService;
import org.elasticsearch.health.HealthFeatures;
import org.elasticsearch.health.metadata.HealthMetadata; import org.elasticsearch.health.metadata.HealthMetadata;
import org.elasticsearch.health.node.action.HealthNodeNotDiscoveredException; import org.elasticsearch.health.node.action.HealthNodeNotDiscoveredException;
import org.elasticsearch.health.node.selection.HealthNode; import org.elasticsearch.health.node.selection.HealthNode;
@ -200,7 +199,6 @@ public class LocalHealthMonitor implements ClusterStateListener {
} }
} }
prerequisitesFulfilled = event.state().clusterRecovered() prerequisitesFulfilled = event.state().clusterRecovered()
&& featureService.clusterHasFeature(event.state(), HealthFeatures.SUPPORTS_HEALTH)
&& HealthMetadata.getFromClusterState(event.state()) != null && HealthMetadata.getFromClusterState(event.state()) != null
&& currentHealthNode != null && currentHealthNode != null
&& currentMasterNode != null; && currentMasterNode != null;

View file

@ -16,7 +16,6 @@ import org.elasticsearch.common.TriFunction;
import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.features.FeatureService; import org.elasticsearch.features.FeatureService;
import org.elasticsearch.health.Diagnosis; import org.elasticsearch.health.Diagnosis;
import org.elasticsearch.health.HealthFeatures;
import org.elasticsearch.health.HealthIndicatorDetails; import org.elasticsearch.health.HealthIndicatorDetails;
import org.elasticsearch.health.HealthIndicatorImpact; import org.elasticsearch.health.HealthIndicatorImpact;
import org.elasticsearch.health.HealthIndicatorResult; import org.elasticsearch.health.HealthIndicatorResult;
@ -111,15 +110,6 @@ public class ShardsCapacityHealthIndicatorService implements HealthIndicatorServ
var state = clusterService.state(); var state = clusterService.state();
var healthMetadata = HealthMetadata.getFromClusterState(state); var healthMetadata = HealthMetadata.getFromClusterState(state);
if (healthMetadata == null || healthMetadata.getShardLimitsMetadata() == null) { if (healthMetadata == null || healthMetadata.getShardLimitsMetadata() == null) {
if (featureService.clusterHasFeature(state, HealthFeatures.SUPPORTS_SHARDS_CAPACITY_INDICATOR) == false) {
return createIndicator(
HealthStatus.GREEN,
"No shard limits configured yet. The cluster currently has mixed versions (an upgrade may be in progress).",
HealthIndicatorDetails.EMPTY,
List.of(),
List.of()
);
}
return unknownIndicator(); return unknownIndicator();
} }

View file

@ -23,7 +23,6 @@ import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.features.FeatureService; import org.elasticsearch.features.FeatureService;
import org.elasticsearch.health.HealthFeatures;
import org.elasticsearch.node.NodeClosedException; import org.elasticsearch.node.NodeClosedException;
import org.elasticsearch.persistent.AllocatedPersistentTask; import org.elasticsearch.persistent.AllocatedPersistentTask;
import org.elasticsearch.persistent.PersistentTaskParams; import org.elasticsearch.persistent.PersistentTaskParams;
@ -157,11 +156,8 @@ public final class HealthNodeTaskExecutor extends PersistentTasksExecutor<Health
// visible for testing // visible for testing
void startTask(ClusterChangedEvent event) { void startTask(ClusterChangedEvent event) {
// Wait until every node in the cluster supports health checks // Wait until master is stable before starting health task
if (event.localNodeMaster() if (event.localNodeMaster() && event.state().clusterRecovered() && HealthNode.findTask(event.state()) == null) {
&& event.state().clusterRecovered()
&& HealthNode.findTask(event.state()) == null
&& featureService.clusterHasFeature(event.state(), HealthFeatures.SUPPORTS_HEALTH)) {
persistentTasksService.sendStartRequest( persistentTasksService.sendStartRequest(
TASK_NAME, TASK_NAME,
TASK_NAME, TASK_NAME,

View file

@ -29,7 +29,6 @@ import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.features.FeatureService; import org.elasticsearch.features.FeatureService;
import org.elasticsearch.health.Diagnosis; import org.elasticsearch.health.Diagnosis;
import org.elasticsearch.health.HealthFeatures;
import org.elasticsearch.health.HealthIndicatorDetails; import org.elasticsearch.health.HealthIndicatorDetails;
import org.elasticsearch.health.HealthIndicatorImpact; import org.elasticsearch.health.HealthIndicatorImpact;
import org.elasticsearch.health.HealthIndicatorResult; import org.elasticsearch.health.HealthIndicatorResult;
@ -1085,12 +1084,8 @@ public class DiskHealthIndicatorServiceTests extends ESTestCase {
Collection<DiscoveryNode> nodes, Collection<DiscoveryNode> nodes,
Map<String, Set<String>> indexNameToNodeIdsMap Map<String, Set<String>> indexNameToNodeIdsMap
) { ) {
Map<String, Set<String>> features = new HashMap<>();
DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(); DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder();
for (DiscoveryNode node : nodes) { nodes.forEach(nodesBuilder::add);
nodesBuilder = nodesBuilder.add(node);
features.put(node.getId(), Set.of(HealthFeatures.SUPPORTS_HEALTH.id()));
}
nodesBuilder.localNodeId(randomFrom(nodes).getId()); nodesBuilder.localNodeId(randomFrom(nodes).getId());
nodesBuilder.masterNodeId(randomFrom(nodes).getId()); nodesBuilder.masterNodeId(randomFrom(nodes).getId());
ClusterBlocks.Builder clusterBlocksBuilder = new ClusterBlocks.Builder(); ClusterBlocks.Builder clusterBlocksBuilder = new ClusterBlocks.Builder();
@ -1125,7 +1120,6 @@ public class DiskHealthIndicatorServiceTests extends ESTestCase {
state.metadata(metadata.generateClusterUuidIfNeeded().build()); state.metadata(metadata.generateClusterUuidIfNeeded().build());
state.routingTable(routingTable.build()); state.routingTable(routingTable.build());
state.blocks(clusterBlocksBuilder); state.blocks(clusterBlocksBuilder);
state.nodeFeatures(features);
return state.build(); return state.build();
} }

View file

@ -21,7 +21,6 @@ import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.features.FeatureService; import org.elasticsearch.features.FeatureService;
import org.elasticsearch.health.HealthFeatures;
import org.elasticsearch.health.HealthIndicatorDetails; import org.elasticsearch.health.HealthIndicatorDetails;
import org.elasticsearch.health.HealthStatus; import org.elasticsearch.health.HealthStatus;
import org.elasticsearch.health.metadata.HealthMetadata; import org.elasticsearch.health.metadata.HealthMetadata;
@ -451,11 +450,7 @@ public class ShardsCapacityHealthIndicatorServiceTests extends ESTestCase {
metadata.put(idxMetadata); metadata.put(idxMetadata);
} }
var features = Set.of(HealthFeatures.SUPPORTS_SHARDS_CAPACITY_INDICATOR.id()); return ClusterState.builder(clusterState).metadata(metadata).build();
return ClusterState.builder(clusterState)
.metadata(metadata)
.nodeFeatures(Map.of(dataNode.getId(), features, frozenNode.getId(), features))
.build();
} }
private static IndexMetadata.Builder createIndexInDataNode(int shards) { private static IndexMetadata.Builder createIndexInDataNode(int shards) {

View file

@ -13,8 +13,6 @@ import org.elasticsearch.client.internal.Client;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.health.stats.HealthApiStatsAction; import org.elasticsearch.health.stats.HealthApiStatsAction;
import org.elasticsearch.injection.guice.Inject; import org.elasticsearch.injection.guice.Inject;
import org.elasticsearch.protocol.xpack.XPackUsageRequest; import org.elasticsearch.protocol.xpack.XPackUsageRequest;
@ -30,10 +28,7 @@ import org.elasticsearch.xpack.core.action.XPackUsageFeatureTransportAction;
*/ */
public class HealthApiUsageTransportAction extends XPackUsageFeatureTransportAction { public class HealthApiUsageTransportAction extends XPackUsageFeatureTransportAction {
static final NodeFeature SUPPORTS_HEALTH_STATS = new NodeFeature("health.supports_health_stats");
private final Client client; private final Client client;
private final FeatureService featureService;
@Inject @Inject
public HealthApiUsageTransportAction( public HealthApiUsageTransportAction(
@ -42,8 +37,7 @@ public class HealthApiUsageTransportAction extends XPackUsageFeatureTransportAct
ThreadPool threadPool, ThreadPool threadPool,
ActionFilters actionFilters, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver, IndexNameExpressionResolver indexNameExpressionResolver,
Client client, Client client
FeatureService featureService
) { ) {
super( super(
XPackUsageFeatureAction.HEALTH.name(), XPackUsageFeatureAction.HEALTH.name(),
@ -54,7 +48,6 @@ public class HealthApiUsageTransportAction extends XPackUsageFeatureTransportAct
indexNameExpressionResolver indexNameExpressionResolver
); );
this.client = client; this.client = client;
this.featureService = featureService;
} }
@Override @Override
@ -70,7 +63,7 @@ public class HealthApiUsageTransportAction extends XPackUsageFeatureTransportAct
client.threadPool().getThreadContext() client.threadPool().getThreadContext()
); );
if (state.clusterRecovered() && featureService.clusterHasFeature(state, SUPPORTS_HEALTH_STATS)) { if (state.clusterRecovered()) {
HealthApiStatsAction.Request statsRequest = new HealthApiStatsAction.Request(); HealthApiStatsAction.Request statsRequest = new HealthApiStatsAction.Request();
statsRequest.setParentTask(clusterService.localNode().getId(), task.getId()); statsRequest.setParentTask(clusterService.localNode().getId(), task.getId());
client.execute(HealthApiStatsAction.INSTANCE, statsRequest, preservingListener.delegateFailureAndWrap((l, r) -> { client.execute(HealthApiStatsAction.INSTANCE, statsRequest, preservingListener.delegateFailureAndWrap((l, r) -> {

View file

@ -7,13 +7,11 @@
package org.elasticsearch.xpack.core; package org.elasticsearch.xpack.core;
import org.elasticsearch.Version;
import org.elasticsearch.features.FeatureSpecification; import org.elasticsearch.features.FeatureSpecification;
import org.elasticsearch.features.NodeFeature; import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.license.License; import org.elasticsearch.license.License;
import org.elasticsearch.xpack.core.datatiers.NodesDataTiersUsageTransportAction; import org.elasticsearch.xpack.core.datatiers.NodesDataTiersUsageTransportAction;
import java.util.Map;
import java.util.Set; import java.util.Set;
/** /**
@ -32,9 +30,4 @@ public class XPackFeatures implements FeatureSpecification {
LOGSDB_TELMETRY_STATS LOGSDB_TELMETRY_STATS
); );
} }
@Override
public Map<NodeFeature, Version> getHistoricalFeatures() {
return Map.of(HealthApiUsageTransportAction.SUPPORTS_HEALTH_STATS, Version.V_8_7_0);
}
} }