From 48582ec882e6d7cb790cffcd4f9d188922bcdb29 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Wed, 13 Oct 2021 15:54:07 +1100 Subject: [PATCH] More accurate error message for datastream and alias (#79027) (#79029) Alias for datastream is supported since #66163. Currently alias for the backing indices are still not allowed. As a result, the error messages are updated to reflect the latest status. --- .../admin/indices/alias/TransportIndicesAliasesAction.java | 2 +- .../cluster/metadata/MetadataIndexAliasesService.java | 2 +- .../cluster/metadata/MetadataIndexAliasesServiceTests.java | 2 +- .../java/org/elasticsearch/datastreams/DataStreamIT.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java index 29fc61f93df57..45c9f977a01cd 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java @@ -157,7 +157,7 @@ protected void masterOperation(final IndicesAliasesRequest request, final Cluste if (indexAbstraction.getParentDataStream() != null) { throw new IllegalArgumentException("The provided expressions [" + String.join(",", action.indices()) + "] match a backing index belonging to data stream [" + indexAbstraction.getParentDataStream().getName() - + "]. Data streams and their backing indices don't support aliases."); + + "]. Data stream backing indices don't support aliases."); } } final Optional maybeException = requestValidators.validateRequest(request, state, concreteIndices); diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexAliasesService.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexAliasesService.java index 7c95387e6b4c2..f2c2bab517305 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexAliasesService.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexAliasesService.java @@ -222,7 +222,7 @@ private void validateAliasTargetIsNotDSBackingIndex(ClusterState currentState, A if (indexAbstraction.getParentDataStream() != null) { throw new IllegalArgumentException("The provided index [" + action.getIndex() + "] is a backing index belonging to data stream [" + indexAbstraction.getParentDataStream().getName() - + "]. Data streams and their backing indices don't support alias operations."); + + "]. Data stream backing indices don't support alias operations."); } } } diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexAliasesServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexAliasesServiceTests.java index 14a997c17028b..ad663ad0f71ee 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexAliasesServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexAliasesServiceTests.java @@ -501,7 +501,7 @@ public void testAliasesForDataStreamBackingIndicesNotSupported() { IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> service.applyAliasActions(state, singletonList(new AliasAction.Add(backingIndexName, "test", null, null, null, null, null)))); assertThat(exception.getMessage(), is("The provided index [" + backingIndexName + "] is a backing index belonging to data " + - "stream [foo-stream]. Data streams and their backing indices don't support alias operations.")); + "stream [foo-stream]. Data stream backing indices don't support alias operations.")); } public void testDataStreamAliases() { diff --git a/x-pack/plugin/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java b/x-pack/plugin/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java index b4157e4c4c3cc..5d298ff70b1e0 100644 --- a/x-pack/plugin/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java +++ b/x-pack/plugin/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java @@ -852,7 +852,7 @@ public void testAliasActionsFailOnDataStreamBackingIndices() throws Exception { + backingIndex + "] match a backing index belonging to data stream [" + dataStreamName - + "]. Data streams and their backing indices don't " + + "]. Data stream backing indices don't " + "support aliases." ) );