Skip to content

Commit

Permalink
More accurate error message for datastream and alias
Browse files Browse the repository at this point in the history
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 committed Oct 13, 2021
1 parent 42a5e56 commit d1800b4
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 @@ -158,7 +158,7 @@ protected void masterOperation(Task task, final IndicesAliasesRequest request, f
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 @@ -499,7 +499,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 @@ -846,7 +846,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 d1800b4

Please sign in to comment.