Skip to content

Commit

Permalink
Remove DiscoveryNodes.getSmallestNonClientNodeVersion method (elastic…
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoop authored Dec 12, 2024
1 parent f3dc0bd commit d514315
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode>, SimpleDiffable<D
private final String localNodeId;
@Nullable
private final DiscoveryNode localNode;
private final Version minNonClientNodeVersion;
private final Version maxNodeVersion;
private final Version minNodeVersion;
private final IndexVersion maxDataNodeCompatibleIndexVersion;
Expand All @@ -81,7 +80,6 @@ private DiscoveryNodes(
Map<String, DiscoveryNode> ingestNodes,
@Nullable String masterNodeId,
@Nullable String localNodeId,
Version minNonClientNodeVersion,
Version maxNodeVersion,
Version minNodeVersion,
IndexVersion maxDataNodeCompatibleIndexVersion,
Expand All @@ -98,7 +96,6 @@ private DiscoveryNodes(
assert (masterNodeId == null) == (masterNode == null);
this.localNodeId = localNodeId;
this.localNode = localNodeId == null ? null : nodes.get(localNodeId);
this.minNonClientNodeVersion = minNonClientNodeVersion;
this.minNodeVersion = minNodeVersion;
this.maxNodeVersion = maxNodeVersion;
this.maxDataNodeCompatibleIndexVersion = maxDataNodeCompatibleIndexVersion;
Expand All @@ -117,7 +114,6 @@ public DiscoveryNodes withMasterNodeId(@Nullable String masterNodeId) {
ingestNodes,
masterNodeId,
localNodeId,
minNonClientNodeVersion,
maxNodeVersion,
minNodeVersion,
maxDataNodeCompatibleIndexVersion,
Expand Down Expand Up @@ -346,17 +342,6 @@ public boolean isMixedVersionCluster() {
return minNodeVersion.equals(maxNodeVersion) == false;
}

/**
* Returns the version of the node with the oldest version in the cluster that is not a client node
*
* If there are no non-client nodes, Version.CURRENT will be returned.
*
* @return the oldest version in the cluster
*/
public Version getSmallestNonClientNodeVersion() {
return minNonClientNodeVersion;
}

/**
* Returns the highest index version supported by all data nodes in the cluster
*/
Expand Down Expand Up @@ -853,14 +838,12 @@ public DiscoveryNodes build() {
*/
Version minNodeVersion = null;
Version maxNodeVersion = null;
Version minNonClientNodeVersion = null;
IndexVersion maxDataNodeCompatibleIndexVersion = null;
IndexVersion minSupportedIndexVersion = null;
for (Map.Entry<String, DiscoveryNode> nodeEntry : nodes.entrySet()) {
DiscoveryNode discoNode = nodeEntry.getValue();
Version version = discoNode.getVersion();
if (discoNode.canContainData() || discoNode.isMasterNode()) {
minNonClientNodeVersion = min(minNonClientNodeVersion, version);
maxDataNodeCompatibleIndexVersion = min(maxDataNodeCompatibleIndexVersion, discoNode.getMaxIndexVersion());
}
minNodeVersion = min(minNodeVersion, version);
Expand Down Expand Up @@ -894,7 +877,6 @@ public DiscoveryNodes build() {
filteredNodes(nodes, DiscoveryNode::isIngestNode),
masterNodeId,
localNodeId,
Objects.requireNonNullElse(minNonClientNodeVersion, Version.CURRENT),
Objects.requireNonNullElse(maxNodeVersion, Version.CURRENT),
Objects.requireNonNullElse(minNodeVersion, Version.CURRENT.minimumCompatibilityVersion()),
Objects.requireNonNullElse(maxDataNodeCompatibleIndexVersion, IndexVersion.current()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void clusterChanged(ClusterChangedEvent event) {
}

// if we're in a mixed-version cluster, exit
if (state.nodes().getMaxNodeVersion().after(state.nodes().getSmallestNonClientNodeVersion())) {
if (state.nodes().isMixedVersionCluster()) {
logger.debug("Skipping system indices up-to-date check as cluster has mixed versions");
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ public void testMinMaxNodeVersions() {

assertEquals(Version.fromString("5.0.17"), build.getMaxNodeVersion());
assertEquals(Version.fromString("1.6.0"), build.getMinNodeVersion());
assertEquals(Version.fromString("2.1.0"), build.getSmallestNonClientNodeVersion()); // doesn't include 1.6.0 observer
assertEquals(IndexVersion.fromId(2010099), build.getMaxDataNodeCompatibleIndexVersion()); // doesn't include 2000199 observer
assertEquals(IndexVersion.fromId(2000099), build.getMinSupportedIndexVersion()); // also includes observers
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected void masterOperation(
ClusterState state,
ActionListener<PostStartTrialResponse> listener
) throws Exception {
if (state.nodes().getMaxNodeVersion().after(state.nodes().getSmallestNonClientNodeVersion())) {
if (state.nodes().isMixedVersionCluster()) {
throw new IllegalStateException(
"Please ensure all nodes are on the same version before starting your trial, the highest node version in this cluster is ["
+ state.nodes().getMaxNodeVersion()
Expand Down

0 comments on commit d514315

Please sign in to comment.