Skip to content

Commit 9be18cb

Browse files
authored
Remove unnecessary deprecation warning in Get Alias API (#82773)
The check removed by this commit checks specifically for requests for aliases that *would* be system aliases, if they existed. I'm not sure why we were doing this, as we don't try to do this anywhere else. The only test that this seems to make fail is the test explicitly checking that behavior, which I don't think is really what we want. So I'm just removing it. Relates #81589
1 parent 7b1fa81 commit 9be18cb

File tree

4 files changed

+2
-83
lines changed

4 files changed

+2
-83
lines changed

qa/system-indices/src/javaRestTest/java/org/elasticsearch/system/indices/SystemAliasIT.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,7 @@ private void assertAliasIsHiddenInAliasesEndpoint(String indexName, String alias
191191
"this request accesses system indices: ["
192192
+ indexName
193193
+ "], "
194-
+ "but in a future major version, direct access to system indices will be prevented by default",
195-
"this request accesses aliases with names reserved for system indices: [.internal-unmanaged-alias], "
196-
+ "but in a future major version, direct access to system indices and their aliases will not be allowed"
194+
+ "but in a future major version, direct access to system indices will be prevented by default"
197195
)
198196
);
199197
Response response = client().performRequest(request);

server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesAction.java

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -195,49 +195,5 @@ private static void checkSystemIndexAccess(
195195
if (netNewSystemIndices.isEmpty() == false) {
196196
throw systemIndices.netNewSystemIndexAccessException(threadContext, netNewSystemIndices);
197197
}
198-
checkSystemAliasAccess(request, systemIndices, systemIndexAccessLevel, threadContext);
199-
}
200-
201-
private static void checkSystemAliasAccess(
202-
GetAliasesRequest request,
203-
SystemIndices systemIndices,
204-
SystemIndexAccessLevel systemIndexAccessLevel,
205-
ThreadContext threadContext
206-
) {
207-
final Predicate<String> systemIndexAccessAllowPredicate;
208-
if (systemIndexAccessLevel == SystemIndexAccessLevel.NONE) {
209-
systemIndexAccessAllowPredicate = name -> true;
210-
} else if (systemIndexAccessLevel == SystemIndexAccessLevel.RESTRICTED) {
211-
systemIndexAccessAllowPredicate = systemIndices.getProductSystemIndexNamePredicate(threadContext).negate();
212-
} else {
213-
throw new IllegalArgumentException("Unexpected system index access level: " + systemIndexAccessLevel);
214-
}
215-
216-
final List<String> systemAliases = new ArrayList<>();
217-
final List<String> netNewSystemAliases = new ArrayList<>();
218-
for (String alias : request.aliases()) {
219-
if (systemIndices.isSystemName(alias)) {
220-
if (systemIndexAccessAllowPredicate.test(alias)) {
221-
if (systemIndices.isNetNewSystemIndex(alias)) {
222-
netNewSystemAliases.add(alias);
223-
} else {
224-
systemAliases.add(alias);
225-
}
226-
}
227-
}
228-
}
229-
230-
if (systemAliases.isEmpty() == false) {
231-
deprecationLogger.warn(
232-
DeprecationCategory.API,
233-
"open_system_alias_access",
234-
"this request accesses aliases with names reserved for system indices: {}, but in a future major version, direct "
235-
+ "access to system indices and their aliases will not be allowed",
236-
systemAliases
237-
);
238-
}
239-
if (netNewSystemAliases.isEmpty() == false) {
240-
throw systemIndices.netNewSystemIndexAccessException(threadContext, netNewSystemAliases);
241-
}
242198
}
243199
}

server/src/test/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesActionTests.java

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -239,39 +239,6 @@ public void testDeprecationWarningNotEmittedWhenOnlyNonsystemIndexRequested() {
239239
assertThat(result.get("c").size(), equalTo(1));
240240
}
241241

242-
public void testDeprecationWarningEmittedWhenRequestingNonExistingAliasInSystemPattern() {
243-
ClusterState state = systemIndexTestClusterState();
244-
SystemIndices systemIndices = new SystemIndices(
245-
Collections.singletonMap(
246-
this.getTestName(),
247-
new SystemIndices.Feature(
248-
this.getTestName(),
249-
"test feature",
250-
Collections.singletonList(new SystemIndexDescriptor(".y*", "an index that doesn't exist"))
251-
)
252-
)
253-
);
254-
255-
GetAliasesRequest request = new GetAliasesRequest(".y");
256-
ImmutableOpenMap<String, List<AliasMetadata>> aliases = ImmutableOpenMap.<String, List<AliasMetadata>>builder().build();
257-
final String[] concreteIndices = {};
258-
assertEquals(state.metadata().findAliases(request.aliases(), concreteIndices), aliases);
259-
ImmutableOpenMap<String, List<AliasMetadata>> result = TransportGetAliasesAction.postProcess(
260-
request,
261-
concreteIndices,
262-
aliases,
263-
state,
264-
SystemIndexAccessLevel.NONE,
265-
null,
266-
systemIndices
267-
);
268-
assertThat(result.size(), equalTo(0));
269-
assertWarnings(
270-
"this request accesses aliases with names reserved for system indices: [.y], but in a future major version, direct"
271-
+ " access to system indices and their aliases will not be allowed"
272-
);
273-
}
274-
275242
public void testPostProcessDataStreamAliases() {
276243
var resolver = TestIndexNameExpressionResolver.newInstance();
277244
var tuples = List.of(new Tuple<>("logs-foo", 1), new Tuple<>("logs-bar", 1), new Tuple<>("logs-baz", 1));

x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/FleetDataStreamIT.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ private void assertGetAliasAPIBehavesAsExpected(String regularIndex, String regu
111111
.setWarningsHandler(
112112
warnings -> List.of(
113113
"this request accesses system indices: [.fleet-artifacts-7], but "
114-
+ "in a future major version, direct access to system indices will be prevented by default",
115-
"this request accesses aliases with names reserved for system indices: [.fleet-artifacts], but in a future major "
116-
+ "version, direct access to system indices and their aliases will not be allowed"
114+
+ "in a future major version, direct access to system indices will be prevented by default"
117115
).equals(warnings) == false
118116
)
119117
.build();

0 commit comments

Comments
 (0)