Skip to content

Commit 9bddb49

Browse files
author
elasticsearchmachine
committed
Merge remote-tracking branch 'origin/main' into lucene_snapshot
2 parents a7c952b + 0b09506 commit 9bddb49

File tree

10 files changed

+117
-18
lines changed

10 files changed

+117
-18
lines changed

muted-tests.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,39 @@ tests:
411411
- class: org.elasticsearch.xpack.ilm.actions.SearchableSnapshotActionIT
412412
method: testSearchableSnapshotTotalShardsPerNode
413413
issue: https://github.com/elastic/elasticsearch/issues/126354
414+
- class: org.elasticsearch.xpack.esql.qa.multi_node.EsqlSpecIT
415+
method: test {rerank.Reranker add the _score column when missing ASYNC}
416+
issue: https://github.com/elastic/elasticsearch/issues/126360
417+
- class: org.elasticsearch.xpack.esql.qa.multi_node.EsqlSpecIT
418+
method: test {rerank.Reranker before a limit ASYNC}
419+
issue: https://github.com/elastic/elasticsearch/issues/126361
420+
- class: org.elasticsearch.xpack.esql.qa.multi_node.EsqlSpecIT
421+
method: test {rerank.Reranker using another sort order ASYNC}
422+
issue: https://github.com/elastic/elasticsearch/issues/126362
423+
- class: org.elasticsearch.xpack.esql.qa.multi_node.EsqlSpecIT
424+
method: test {rerank.Reranker using another sort order SYNC}
425+
issue: https://github.com/elastic/elasticsearch/issues/126363
426+
- class: org.elasticsearch.xpack.esql.qa.multi_node.EsqlSpecIT
427+
method: test {rerank.Reranker add the _score column when missing SYNC}
428+
issue: https://github.com/elastic/elasticsearch/issues/126367
429+
- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT
430+
method: test {p0=search.vectors/42_knn_search_bbq_flat/Vector rescoring has same scoring as exact search for kNN section}
431+
issue: https://github.com/elastic/elasticsearch/issues/126368
432+
- class: org.elasticsearch.xpack.esql.qa.multi_node.EsqlSpecIT
433+
method: test {rerank.Reranker using a single field ASYNC}
434+
issue: https://github.com/elastic/elasticsearch/issues/126369
435+
- class: org.elasticsearch.xpack.esql.qa.multi_node.EsqlSpecIT
436+
method: test {rerank.Reranker using a single field SYNC}
437+
issue: https://github.com/elastic/elasticsearch/issues/126370
438+
- class: org.elasticsearch.xpack.esql.qa.multi_node.EsqlSpecIT
439+
method: test {rerank.Reranker using multiple fields ASYNC}
440+
issue: https://github.com/elastic/elasticsearch/issues/126371
441+
- class: org.elasticsearch.smoketest.MlWithSecurityIT
442+
method: test {yaml=ml/start_data_frame_analytics/Test start classification analysis when the dependent variable cardinality is too low}
443+
issue: https://github.com/elastic/elasticsearch/issues/123200
444+
- class: org.elasticsearch.packaging.test.DockerTests
445+
method: test022InstallPluginsFromLocalArchive
446+
issue: https://github.com/elastic/elasticsearch/issues/116866
414447

415448
# Examples:
416449
#

server/src/main/java/org/elasticsearch/action/support/IndexComponentSelector.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static IndexComponentSelector getByKeyOrThrow(@Nullable String key) {
8383
}
8484
IndexComponentSelector selector = getByKey(key);
8585
if (selector == null) {
86-
throw new IllegalArgumentException(
86+
throw new InvalidSelectorException(
8787
"Unknown key of index component selector [" + key + "], available options are: " + KEY_REGISTRY.keySet()
8888
);
8989
}
@@ -107,7 +107,7 @@ public static IndexComponentSelector read(StreamInput in) throws IOException {
107107
static IndexComponentSelector getById(byte id) {
108108
IndexComponentSelector indexComponentSelector = ID_REGISTRY.get(id);
109109
if (indexComponentSelector == null) {
110-
throw new IllegalArgumentException(
110+
throw new InvalidSelectorException(
111111
"Unknown id of index component selector [" + id + "], available options are: " + ID_REGISTRY
112112
);
113113
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.action.support;
11+
12+
/**
13+
* Exception thrown when a :: selector is invalid.
14+
*/
15+
public class InvalidSelectorException extends IllegalArgumentException {
16+
17+
public InvalidSelectorException(String message) {
18+
super(message);
19+
}
20+
21+
public InvalidSelectorException(String message, Throwable cause) {
22+
super(message, cause);
23+
}
24+
25+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.action.support;
11+
12+
/**
13+
* Exception thrown when a :: selector is not supported.
14+
*/
15+
public class UnsupportedSelectorException extends IllegalArgumentException {
16+
17+
public UnsupportedSelectorException(String expression) {
18+
super("Index component selectors are not supported in this context but found selector in expression [" + expression + "]");
19+
}
20+
21+
}

server/src/main/java/org/elasticsearch/cluster/metadata/IndexAbstractionResolver.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import org.elasticsearch.action.support.IndexComponentSelector;
1313
import org.elasticsearch.action.support.IndicesOptions;
14+
import org.elasticsearch.action.support.UnsupportedSelectorException;
1415
import org.elasticsearch.common.regex.Regex;
1516
import org.elasticsearch.core.Nullable;
1617
import org.elasticsearch.core.Tuple;
@@ -57,11 +58,7 @@ public List<String> resolveIndexAbstractions(
5758
Tuple<String, String> expressionAndSelector = IndexNameExpressionResolver.splitSelectorExpression(indexAbstraction);
5859
String selectorString = expressionAndSelector.v2();
5960
if (indicesOptions.allowSelectors() == false && selectorString != null) {
60-
throw new IllegalArgumentException(
61-
"Index component selectors are not supported in this context but found selector in expression ["
62-
+ indexAbstraction
63-
+ "]"
64-
);
61+
throw new UnsupportedSelectorException(indexAbstraction);
6562
}
6663
indexAbstraction = expressionAndSelector.v1();
6764
IndexComponentSelector selector = IndexComponentSelector.getByKeyOrThrow(selectorString);

server/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.action.IndicesRequest;
1616
import org.elasticsearch.action.support.IndexComponentSelector;
1717
import org.elasticsearch.action.support.IndicesOptions;
18+
import org.elasticsearch.action.support.UnsupportedSelectorException;
1819
import org.elasticsearch.cluster.ClusterState;
1920
import org.elasticsearch.cluster.metadata.IndexAbstraction.Type;
2021
import org.elasticsearch.cluster.project.ProjectResolver;
@@ -2394,13 +2395,11 @@ private static IndexComponentSelector resolveAndValidateSelectorString(Supplier<
23942395
* Checks the selectors that have been returned from splitting an expression and throws an exception if any were present.
23952396
* @param expression Original expression
23962397
* @param selector Selectors to validate
2397-
* @throws IllegalArgumentException if selectors are present
2398+
* @throws UnsupportedSelectorException if selectors are present
23982399
*/
23992400
private static void ensureNoSelectorsProvided(String expression, IndexComponentSelector selector) {
24002401
if (selector != null) {
2401-
throw new IllegalArgumentException(
2402-
"Index component selectors are not supported in this context but found selector in expression [" + expression + "]"
2403-
);
2402+
throw new UnsupportedSelectorException(expression);
24042403
}
24052404
}
24062405

x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/AbstractRemoteClusterSecurityFailureStoreRestIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ protected Tuple<String, String> getSingleDataAndFailureIndices(String dataStream
170170
}
171171

172172
protected static void assertSelectorsNotSupported(ResponseException exception) {
173-
assertThat(exception.getResponse().getStatusLine().getStatusCode(), equalTo(403));
173+
assertThat(exception.getResponse().getStatusLine().getStatusCode(), equalTo(400));
174174
assertThat(exception.getMessage(), containsString("Selectors are not yet supported on remote cluster patterns"));
175175
}
176176

x-pack/plugin/security/qa/security-trial/src/javaRestTest/java/org/elasticsearch/xpack/security/failurestore/FailureStoreSecurityRestIT.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1891,7 +1891,10 @@ public void testWriteAndManageOperations() throws IOException {
18911891

18921892
expectThrows(() -> deleteDataStream(MANAGE_FAILURE_STORE_ACCESS, "test1"), 403);
18931893
// selectors aren't supported for deletes so we get a 403
1894-
expectThrows(() -> deleteDataStream(MANAGE_FAILURE_STORE_ACCESS, "test1::failures"), 403);
1894+
expectThrowsBadRequest(
1895+
() -> deleteDataStream(MANAGE_FAILURE_STORE_ACCESS, "test1::failures"),
1896+
containsString("Index component selectors are not supported in this context but found selector in expression [test1::failures]")
1897+
);
18951898

18961899
// manage user can delete data stream
18971900
deleteDataStream(MANAGE_ACCESS, "test1");
@@ -2345,6 +2348,12 @@ private static void expectThrows(ThrowingRunnable runnable, int statusCode) {
23452348
assertThat(ex.getResponse().getStatusLine().getStatusCode(), equalTo(statusCode));
23462349
}
23472350

2351+
private void expectThrowsBadRequest(ThrowingRunnable runnable, Matcher<String> errorMatcher) {
2352+
ResponseException ex = expectThrows(ResponseException.class, runnable);
2353+
assertThat(ex.getResponse().getStatusLine().getStatusCode(), equalTo(400));
2354+
assertThat(ex.getMessage(), errorMatcher);
2355+
}
2356+
23482357
private void expectThrowsUnauthorized(String user, Search search, Matcher<String> errorMatcher) {
23492358
ResponseException ex = expectThrows(ResponseException.class, () -> performRequestMaybeUsingApiKey(user, search.toSearchRequest()));
23502359
assertThat(ex.getResponse().getStatusLine().getStatusCode(), equalTo(403));

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
import org.elasticsearch.action.index.TransportIndexAction;
2929
import org.elasticsearch.action.search.SearchRequest;
3030
import org.elasticsearch.action.support.GroupedActionListener;
31+
import org.elasticsearch.action.support.InvalidSelectorException;
3132
import org.elasticsearch.action.support.SubscribableListener;
33+
import org.elasticsearch.action.support.UnsupportedSelectorException;
3234
import org.elasticsearch.action.support.replication.TransportReplicationAction.ConcreteShardRequest;
3335
import org.elasticsearch.action.update.TransportUpdateAction;
3436
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
@@ -44,6 +46,7 @@
4446
import org.elasticsearch.core.Nullable;
4547
import org.elasticsearch.core.Tuple;
4648
import org.elasticsearch.index.IndexNotFoundException;
49+
import org.elasticsearch.indices.InvalidIndexNameException;
4750
import org.elasticsearch.license.XPackLicenseState;
4851
import org.elasticsearch.threadpool.ThreadPool;
4952
import org.elasticsearch.transport.TransportActionProxy;
@@ -502,6 +505,21 @@ private void authorizeAction(
502505
indicesAndAliasesResolver.resolve(action, request, projectMetadata, authorizedIndices)
503506
),
504507
e -> {
508+
if (e instanceof InvalidIndexNameException
509+
|| e instanceof InvalidSelectorException
510+
|| e instanceof UnsupportedSelectorException) {
511+
logger.debug(
512+
() -> Strings.format(
513+
"failed [%s] action authorization for [%s] due to [%s] exception",
514+
action,
515+
authentication,
516+
e.getClass().getSimpleName()
517+
),
518+
e
519+
);
520+
listener.onFailure(e);
521+
return;
522+
}
505523
auditTrail.accessDenied(requestId, authentication, action, request, authzInfo);
506524
if (e instanceof IndexNotFoundException) {
507525
listener.onFailure(e);

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolver.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.action.search.SearchRequest;
1616
import org.elasticsearch.action.support.IndexComponentSelector;
1717
import org.elasticsearch.action.support.IndicesOptions;
18+
import org.elasticsearch.action.support.UnsupportedSelectorException;
1819
import org.elasticsearch.cluster.metadata.AliasMetadata;
1920
import org.elasticsearch.cluster.metadata.IndexAbstraction;
2021
import org.elasticsearch.cluster.metadata.IndexAbstractionResolver;
@@ -315,11 +316,7 @@ ResolvedIndices resolveIndicesAndAliases(
315316
// First, if a selector is present, check to make sure that selectors are even allowed here
316317
if (indicesOptions.allowSelectors() == false && allIndicesPatternSelector != null) {
317318
String originalIndexExpression = indicesRequest.indices()[0];
318-
throw new IllegalArgumentException(
319-
"Index component selectors are not supported in this context but found selector in expression ["
320-
+ originalIndexExpression
321-
+ "]"
322-
);
319+
throw new UnsupportedSelectorException(originalIndexExpression);
323320
}
324321
if (indicesOptions.expandWildcardExpressions()) {
325322
IndexComponentSelector selector = IndexComponentSelector.getByKeyOrThrow(allIndicesPatternSelector);

0 commit comments

Comments
 (0)