[7.x] Minimum node version check before creating data stream (#58424)

This commit is contained in:
Dan Hermann 2020-06-23 07:45:27 -05:00 committed by GitHub
parent 943efb78fd
commit 41e8f584c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -20,6 +20,7 @@ package org.elasticsearch.cluster.metadata;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.admin.indices.create.CreateIndexClusterStateUpdateRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexClusterStateUpdateRequest;
import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.action.support.ActiveShardCount;
@ -125,6 +126,10 @@ public class MetadataCreateDataStreamService {
static ClusterState createDataStream(MetadataCreateIndexService metadataCreateIndexService, static ClusterState createDataStream(MetadataCreateIndexService metadataCreateIndexService,
ClusterState currentState, ClusterState currentState,
CreateDataStreamClusterStateUpdateRequest request) throws Exception { CreateDataStreamClusterStateUpdateRequest request) throws Exception {
if (currentState.nodes().getMinNodeVersion().before(Version.V_7_9_0)) {
throw new IllegalStateException("data streams require minimum node version of " + Version.V_7_9_0);
}
if (currentState.metadata().dataStreams().containsKey(request.name)) { if (currentState.metadata().dataStreams().containsKey(request.name)) {
throw new IllegalArgumentException("data_stream [" + request.name + "] already exists"); throw new IllegalArgumentException("data_stream [" + request.name + "] already exists");
} }