Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary deprecation warning in Get Alias API #82773

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ private void assertAliasIsHiddenInAliasesEndpoint(String indexName, String alias
"this request accesses system indices: ["
+ indexName
+ "], "
+ "but in a future major version, direct access to system indices will be prevented by default",
"this request accesses aliases with names reserved for system indices: [.internal-unmanaged-alias], "
+ "but in a future major version, direct access to system indices and their aliases will not be allowed"
+ "but in a future major version, direct access to system indices will be prevented by default"
)
);
Response response = client().performRequest(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,49 +195,5 @@ private static void checkSystemIndexAccess(
if (netNewSystemIndices.isEmpty() == false) {
throw systemIndices.netNewSystemIndexAccessException(threadContext, netNewSystemIndices);
}
checkSystemAliasAccess(request, systemIndices, systemIndexAccessLevel, threadContext);
}

private static void checkSystemAliasAccess(
GetAliasesRequest request,
SystemIndices systemIndices,
SystemIndexAccessLevel systemIndexAccessLevel,
ThreadContext threadContext
) {
final Predicate<String> systemIndexAccessAllowPredicate;
if (systemIndexAccessLevel == SystemIndexAccessLevel.NONE) {
systemIndexAccessAllowPredicate = name -> true;
} else if (systemIndexAccessLevel == SystemIndexAccessLevel.RESTRICTED) {
systemIndexAccessAllowPredicate = systemIndices.getProductSystemIndexNamePredicate(threadContext).negate();
} else {
throw new IllegalArgumentException("Unexpected system index access level: " + systemIndexAccessLevel);
}

final List<String> systemAliases = new ArrayList<>();
final List<String> netNewSystemAliases = new ArrayList<>();
for (String alias : request.aliases()) {
if (systemIndices.isSystemName(alias)) {
if (systemIndexAccessAllowPredicate.test(alias)) {
if (systemIndices.isNetNewSystemIndex(alias)) {
netNewSystemAliases.add(alias);
} else {
systemAliases.add(alias);
}
}
}
}

if (systemAliases.isEmpty() == false) {
deprecationLogger.warn(
DeprecationCategory.API,
"open_system_alias_access",
"this request accesses aliases with names reserved for system indices: {}, but in a future major version, direct "
+ "access to system indices and their aliases will not be allowed",
systemAliases
);
}
if (netNewSystemAliases.isEmpty() == false) {
throw systemIndices.netNewSystemIndexAccessException(threadContext, netNewSystemAliases);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -239,39 +239,6 @@ public void testDeprecationWarningNotEmittedWhenOnlyNonsystemIndexRequested() {
assertThat(result.get("c").size(), equalTo(1));
}

public void testDeprecationWarningEmittedWhenRequestingNonExistingAliasInSystemPattern() {
ClusterState state = systemIndexTestClusterState();
SystemIndices systemIndices = new SystemIndices(
Collections.singletonMap(
this.getTestName(),
new SystemIndices.Feature(
this.getTestName(),
"test feature",
Collections.singletonList(new SystemIndexDescriptor(".y*", "an index that doesn't exist"))
)
)
);

GetAliasesRequest request = new GetAliasesRequest(".y");
ImmutableOpenMap<String, List<AliasMetadata>> aliases = ImmutableOpenMap.<String, List<AliasMetadata>>builder().build();
final String[] concreteIndices = {};
assertEquals(state.metadata().findAliases(request.aliases(), concreteIndices), aliases);
ImmutableOpenMap<String, List<AliasMetadata>> result = TransportGetAliasesAction.postProcess(
request,
concreteIndices,
aliases,
state,
SystemIndexAccessLevel.NONE,
null,
systemIndices
);
assertThat(result.size(), equalTo(0));
assertWarnings(
"this request accesses aliases with names reserved for system indices: [.y], but in a future major version, direct"
+ " access to system indices and their aliases will not be allowed"
);
}

public void testPostProcessDataStreamAliases() {
var resolver = TestIndexNameExpressionResolver.newInstance();
var tuples = List.of(new Tuple<>("logs-foo", 1), new Tuple<>("logs-bar", 1), new Tuple<>("logs-baz", 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ private void assertGetAliasAPIBehavesAsExpected(String regularIndex, String regu
.setWarningsHandler(
warnings -> List.of(
"this request accesses system indices: [.fleet-artifacts-7], but "
+ "in a future major version, direct access to system indices will be prevented by default",
"this request accesses aliases with names reserved for system indices: [.fleet-artifacts], but in a future major "
+ "version, direct access to system indices and their aliases will not be allowed"
+ "in a future major version, direct access to system indices will be prevented by default"
).equals(warnings) == false
)
.build();
Expand Down