Skip to content

Commit

Permalink
Minor Version cleanup (elastic#104461)
Browse files Browse the repository at this point in the history
* Some minor cleanup - removing some useless Version reference
* Using TransportVersion#toReleaseVersion
  • Loading branch information
ldematte authored Feb 12, 2024
1 parent 6ae7d18 commit 4f2c264
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.elasticsearch.ElasticsearchGenerationException;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.CompositeIndicesRequest;
import org.elasticsearch.action.DocWriteRequest;
Expand All @@ -24,6 +23,7 @@
import org.elasticsearch.cluster.metadata.IndexAbstraction;
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.cluster.routing.IndexRouting;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.UUIDs;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
Expand Down Expand Up @@ -758,7 +758,12 @@ private void writeBody(StreamOutput out) throws IOException {
out.writeMap(dynamicTemplates, StreamOutput::writeString);
} else {
if (dynamicTemplates.isEmpty() == false) {
throw new IllegalArgumentException("[dynamic_templates] parameter requires all nodes on " + Version.V_7_13_0 + " or later");
throw new IllegalArgumentException(
Strings.format(
"[dynamic_templates] parameter requires all nodes on %s or later",
TransportVersions.V_7_13_0.toReleaseVersion()
)
);
}
}
if (out.getTransportVersion().onOrAfter(PIPELINES_HAVE_RUN_FIELD_ADDED)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.DocWriteRequest;
import org.elasticsearch.action.support.ActiveShardCount;
Expand Down Expand Up @@ -232,10 +231,7 @@ public void testSerializeDynamicTemplates() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
out.setTransportVersion(ver);
IllegalArgumentException error = expectThrows(IllegalArgumentException.class, () -> indexRequest.writeTo(out));
assertThat(
error.getMessage(),
equalTo("[dynamic_templates] parameter requires all nodes on " + Version.V_7_13_0 + " or later")
);
assertThat(error.getMessage(), equalTo("[dynamic_templates] parameter requires all nodes on 7.13.0 or later"));
}
// new version
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.Version;
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.cluster.ClusterChangedEvent;
import org.elasticsearch.cluster.metadata.ComponentTemplate;
Expand Down Expand Up @@ -42,9 +41,6 @@
public class LegacyStackTemplateRegistry extends IndexTemplateRegistry {
private static final Logger logger = LogManager.getLogger(LegacyStackTemplateRegistry.class);

// Current version of the registry requires all nodes to be at least 8.9.0.
public static final Version MIN_NODE_VERSION = Version.V_8_9_0;

// The stack template registry version. This number must be incremented when we make changes
// to built-in templates.
public static final int REGISTRY_VERSION = 4;
Expand Down

0 comments on commit 4f2c264

Please sign in to comment.