Skip to content

Commit

Permalink
Remove health historical features and upgrade test (elastic#116928)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoop authored Nov 18, 2024
1 parent 81e3afa commit 08daf65
Show file tree
Hide file tree
Showing 11 changed files with 7 additions and 121 deletions.

This file was deleted.

17 changes: 0 additions & 17 deletions server/src/main/java/org/elasticsearch/health/HealthFeatures.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,17 @@

package org.elasticsearch.health;

import org.elasticsearch.Version;
import org.elasticsearch.features.FeatureSpecification;
import org.elasticsearch.features.NodeFeature;

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

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");

@Override
public Set<NodeFeature> getFeatures() {
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
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.elasticsearch.core.Tuple;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.gateway.GatewayService;
import org.elasticsearch.health.HealthFeatures;

import java.util.List;
import java.util.stream.Stream;
Expand Down Expand Up @@ -137,7 +136,7 @@ private void updateOnHealthNodeEnabledChange(boolean enabled) {

private boolean canPostClusterStateUpdates(ClusterState state) {
// 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.health.Diagnosis;
import org.elasticsearch.health.HealthFeatures;
import org.elasticsearch.health.HealthIndicatorDetails;
import org.elasticsearch.health.HealthIndicatorImpact;
import org.elasticsearch.health.HealthIndicatorResult;
Expand Down Expand Up @@ -91,15 +90,6 @@ public HealthIndicatorResult calculate(boolean verbose, int maxAffectedResources
ClusterState clusterState = clusterService.state();
Map<String, DiskHealthInfo> diskHealthInfoMap = healthInfo.diskInfoByNode();
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
* wrong with health data collection on the health node. Either way, we immediately return UNKNOWN. If there are at least
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.elasticsearch.common.util.concurrent.RunOnce;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.health.HealthFeatures;
import org.elasticsearch.health.metadata.HealthMetadata;
import org.elasticsearch.health.node.action.HealthNodeNotDiscoveredException;
import org.elasticsearch.health.node.selection.HealthNode;
Expand Down Expand Up @@ -200,7 +199,6 @@ public void clusterChanged(ClusterChangedEvent event) {
}
}
prerequisitesFulfilled = event.state().clusterRecovered()
&& featureService.clusterHasFeature(event.state(), HealthFeatures.SUPPORTS_HEALTH)
&& HealthMetadata.getFromClusterState(event.state()) != null
&& currentHealthNode != null
&& currentMasterNode != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.health.Diagnosis;
import org.elasticsearch.health.HealthFeatures;
import org.elasticsearch.health.HealthIndicatorDetails;
import org.elasticsearch.health.HealthIndicatorImpact;
import org.elasticsearch.health.HealthIndicatorResult;
Expand Down Expand Up @@ -111,15 +110,6 @@ public HealthIndicatorResult calculate(boolean verbose, int maxAffectedResources
var state = clusterService.state();
var healthMetadata = HealthMetadata.getFromClusterState(state);
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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.health.HealthFeatures;
import org.elasticsearch.node.NodeClosedException;
import org.elasticsearch.persistent.AllocatedPersistentTask;
import org.elasticsearch.persistent.PersistentTaskParams;
Expand Down Expand Up @@ -157,11 +156,8 @@ public PersistentTasksCustomMetadata.Assignment getAssignment(

// visible for testing
void startTask(ClusterChangedEvent event) {
// Wait until every node in the cluster supports health checks
if (event.localNodeMaster()
&& event.state().clusterRecovered()
&& HealthNode.findTask(event.state()) == null
&& featureService.clusterHasFeature(event.state(), HealthFeatures.SUPPORTS_HEALTH)) {
// Wait until master is stable before starting health task
if (event.localNodeMaster() && event.state().clusterRecovered() && HealthNode.findTask(event.state()) == null) {
persistentTasksService.sendStartRequest(
TASK_NAME,
TASK_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.health.Diagnosis;
import org.elasticsearch.health.HealthFeatures;
import org.elasticsearch.health.HealthIndicatorDetails;
import org.elasticsearch.health.HealthIndicatorImpact;
import org.elasticsearch.health.HealthIndicatorResult;
Expand Down Expand Up @@ -1085,12 +1084,8 @@ static ClusterState createClusterState(
Collection<DiscoveryNode> nodes,
Map<String, Set<String>> indexNameToNodeIdsMap
) {
Map<String, Set<String>> features = new HashMap<>();
DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder();
for (DiscoveryNode node : nodes) {
nodesBuilder = nodesBuilder.add(node);
features.put(node.getId(), Set.of(HealthFeatures.SUPPORTS_HEALTH.id()));
}
nodes.forEach(nodesBuilder::add);
nodesBuilder.localNodeId(randomFrom(nodes).getId());
nodesBuilder.masterNodeId(randomFrom(nodes).getId());
ClusterBlocks.Builder clusterBlocksBuilder = new ClusterBlocks.Builder();
Expand Down Expand Up @@ -1125,7 +1120,6 @@ static ClusterState createClusterState(
state.metadata(metadata.generateClusterUuidIfNeeded().build());
state.routingTable(routingTable.build());
state.blocks(clusterBlocksBuilder);
state.nodeFeatures(features);
return state.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.health.HealthFeatures;
import org.elasticsearch.health.HealthIndicatorDetails;
import org.elasticsearch.health.HealthStatus;
import org.elasticsearch.health.metadata.HealthMetadata;
Expand Down Expand Up @@ -451,11 +450,7 @@ private ClusterState createClusterState(
metadata.put(idxMetadata);
}

var features = Set.of(HealthFeatures.SUPPORTS_SHARDS_CAPACITY_INDICATOR.id());
return ClusterState.builder(clusterState)
.metadata(metadata)
.nodeFeatures(Map.of(dataNode.getId(), features, frozenNode.getId(), features))
.build();
return ClusterState.builder(clusterState).metadata(metadata).build();
}

private static IndexMetadata.Builder createIndexInDataNode(int shards) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
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.injection.guice.Inject;
import org.elasticsearch.protocol.xpack.XPackUsageRequest;
Expand All @@ -30,10 +28,7 @@
*/
public class HealthApiUsageTransportAction extends XPackUsageFeatureTransportAction {

static final NodeFeature SUPPORTS_HEALTH_STATS = new NodeFeature("health.supports_health_stats");

private final Client client;
private final FeatureService featureService;

@Inject
public HealthApiUsageTransportAction(
Expand All @@ -42,8 +37,7 @@ public HealthApiUsageTransportAction(
ThreadPool threadPool,
ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver,
Client client,
FeatureService featureService
Client client
) {
super(
XPackUsageFeatureAction.HEALTH.name(),
Expand All @@ -54,7 +48,6 @@ public HealthApiUsageTransportAction(
indexNameExpressionResolver
);
this.client = client;
this.featureService = featureService;
}

@Override
Expand All @@ -70,7 +63,7 @@ protected void masterOperation(
client.threadPool().getThreadContext()
);

if (state.clusterRecovered() && featureService.clusterHasFeature(state, SUPPORTS_HEALTH_STATS)) {
if (state.clusterRecovered()) {
HealthApiStatsAction.Request statsRequest = new HealthApiStatsAction.Request();
statsRequest.setParentTask(clusterService.localNode().getId(), task.getId());
client.execute(HealthApiStatsAction.INSTANCE, statsRequest, preservingListener.delegateFailureAndWrap((l, r) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@

package org.elasticsearch.xpack.core;

import org.elasticsearch.Version;
import org.elasticsearch.features.FeatureSpecification;
import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.license.License;
import org.elasticsearch.xpack.core.datatiers.NodesDataTiersUsageTransportAction;

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

/**
Expand All @@ -32,9 +30,4 @@ public Set<NodeFeature> getFeatures() {
LOGSDB_TELMETRY_STATS
);
}

@Override
public Map<NodeFeature, Version> getHistoricalFeatures() {
return Map.of(HealthApiUsageTransportAction.SUPPORTS_HEALTH_STATS, Version.V_8_7_0);
}
}

0 comments on commit 08daf65

Please sign in to comment.