Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert NodeMetadata check to simple comparison #101644

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions server/src/main/java/org/elasticsearch/env/NodeMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void verifyUpgradeToCurrentVersion() {
assert (nodeVersion.equals(Version.V_EMPTY) == false) || (Version.CURRENT.major <= Version.V_7_0_0.major + 1)
: "version is required in the node metadata from v9 onwards";

if (NodeMetadata.isNodeVersionWireCompatible(nodeVersion.toString()) == false) {
if (nodeVersion.before(Version.CURRENT.minimumCompatibilityVersion())) {
throw new IllegalStateException(
"cannot upgrade a node from version ["
+ nodeVersion
Expand Down Expand Up @@ -222,20 +222,4 @@ public NodeMetadata fromXContent(XContentParser parser) throws IOException {

public static final MetadataStateFormat<NodeMetadata> FORMAT = new NodeMetadataStateFormat(false);

/**
* Check whether a node version is compatible with the current minimum transport version.
* @param version A version identifier as a string
* @throws IllegalArgumentException if version is not a valid transport version identifier
* @return true if the version is compatible, false otherwise
*/
// visible for testing
static boolean isNodeVersionWireCompatible(String version) {
try {
Version esVersion = Version.fromString(version);
return esVersion.onOrAfter(Version.CURRENT.minimumCompatibilityVersion());
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Cannot parse [" + version + "] as a transport version identifier", e);
}
}

}
18 changes: 0 additions & 18 deletions server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.elasticsearch.index.IndexVersions;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.EqualsHashCodeTestUtils;
import org.elasticsearch.test.TransportVersionUtils;
import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.test.index.IndexVersionUtils;

Expand Down Expand Up @@ -160,23 +159,6 @@ public void testUpgradeMarksPreviousVersion() {
assertThat(nodeMetadata.previousNodeVersion(), equalTo(version));
}

public void testIsNodeVersionWireCompatible() {
String nodeVersion = VersionUtils.randomCompatibleVersion(random(), Version.CURRENT).toString();
assertTrue(NodeMetadata.isNodeVersionWireCompatible(nodeVersion));
nodeVersion = VersionUtils.getPreviousVersion(Version.CURRENT.minimumCompatibilityVersion()).toString();
assertFalse(NodeMetadata.isNodeVersionWireCompatible(nodeVersion));

String transportVersion = TransportVersionUtils.randomCompatibleVersion(random()).toString();
IllegalArgumentException e1 = expectThrows(
IllegalArgumentException.class,
() -> NodeMetadata.isNodeVersionWireCompatible(transportVersion)
);
assertThat(e1.getMessage(), equalTo("Cannot parse [" + transportVersion + "] as a transport version identifier"));

IllegalArgumentException e2 = expectThrows(IllegalArgumentException.class, () -> NodeMetadata.isNodeVersionWireCompatible("x.y.z"));
assertThat(e2.getMessage(), equalTo("Cannot parse [x.y.z] as a transport version identifier"));
}

public static Version tooNewVersion() {
return Version.fromId(between(Version.CURRENT.id + 1, 99999999));
}
Expand Down