Skip to content

Commit

Permalink
More accurate error message for datastream and alias (elastic#79027) (e…
Browse files Browse the repository at this point in the history
…lastic#79029)

Alias for datastream is supported since elastic#66163. Currently alias for the
backing indices are still not allowed. As a result, the error messages
are updated to reflect the latest status.
  • Loading branch information
ywangd authored Oct 13, 2021
1 parent 1187088 commit 48582ec
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Exception> maybeException = requestValidators.validateRequest(request, state, concreteIndices);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
);
Expand Down

0 comments on commit 48582ec

Please sign in to comment.